protected DAS initializeDAS(String config, ConnectionInfo connectionInfo, String table, String pkColumns) throws MissingConfigFileException {
//load the config file
//System.out.println("Initializing DAS");
ConfigHelper configHelper;
if(config == null) {
//no config information
configHelper = new ConfigHelper();
} else {
//initialize the config helper by loading config file
configHelper = new ConfigHelper(this.getConfigStream(config));
}
//add additional connectionInfo if provided in the SCA Composite file
if( connectionInfo != null) {
String dataSource = connectionInfo.getDataSource();
if(dataSource != null && dataSource.length() > 0) {
configHelper.addConnectionInfo(dataSource);
} else {
String driverClass = connectionInfo.getConnectionProperties().getDriverClass();
String connectionURL = connectionInfo.getConnectionProperties().getDatabaseURL();
String userName = connectionInfo.getConnectionProperties().getUsername();
String password = connectionInfo.getConnectionProperties().getPassword();
int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();
configHelper.addConnectionInfo(driverClass, connectionURL, userName, password, loginTimeout);
}
}
if(table != null && pkColumns != null) {
MappingWrapper configWrapper = new MappingWrapper(configHelper.getConfig());
List<String> pkColsList = DataAccessEngine.getKeys(pkColumns);
for(int i=0; i<pkColsList.size(); i++) {
configWrapper.addPrimaryKey(table+"."+pkColsList.get(i), pkColsList.get(i));
}
}
DAS das = DAS.FACTORY.createDAS(configHelper.getConfig());
return das;
}