Skip to end of metadata
Go to start of metadata


package com.selventa.belframework.examples;
import java.util.List;
import com.selventa.belframework.api.KamStore;
import com.selventa.belframework.common.cfg.SystemConfiguration;
import com.selventa.belframework.df.DBConnection;
import com.selventa.belframework.df.DatabaseService;
import com.selventa.belframework.df.DatabaseServiceImpl;
import com.selventa.belframework.kamstore.data.jdbc.KAMCatalogDaoImpl.KamInfo;
/**
* This program demonstrate calling BEL Framework API
* to list available KAMs in the KAM Store. Note: if you
* have not compiled any KAMs into the KAM Store, you will
* not see any KAMs listed.
*/
public class Example1 {
public static void main(String[] args) throws Exception {
//Create a SystemConfiguration object
SystemConfiguration.createSystemConfiguration(null);
SystemConfiguration systemConfiguration = SystemConfiguration.getSystemConfiguration();
// Setup a database connector to the KAM Store.
DatabaseService dbService = new DatabaseServiceImpl();
DBConnection dbConnection = dbService.dbConnection(
systemConfiguration.getKamURL(),
systemConfiguration.getKamUser(),
systemConfiguration.getKamPassword());
// Connect to the KAM Store. This establishes a connection to the
// KAMStore database and sets up the system to read and process
// Kams.
KamStore kamStore = new KamStore(dbConnection);
//Read all available KAMs from the KamStore catalog
List<KamInfo> kamInfos = kamStore.readCatalog();
//Print the name and description of all KAMs
System.out.println("Total number of KAMs in KAM Store: " + kamInfos.size());
for(KamInfo kamInfo : kamInfos) {
System.out.println(String.format("KAM Name: %s, Description: %s",
kamInfo.getName(), kamInfo.getDescription()));
}

// Tearsdown the KamStore. This removes any cached data and queries
kamStore.teardown();
// Close the DBConnection
dbConnection.getConnection().close();
}
}

  • No labels