ds=new JDBCDataSet();
String query = getAttributeAsString(DataSetConstants.QUERY);
String dataSourceLabel = getAttributeAsString(DataSetConstants.DATA_SOURCE);
((JDBCDataSet)ds).setQuery(query);
if(dataSourceLabel!=null && !dataSourceLabel.equals("")){
IDataSource dataSource;
try {
dataSource = DAOFactory.getDataSourceDAO().loadDataSourceByLabel(dataSourceLabel);
if(dataSource!=null){
((JDBCDataSet)ds).setDataSource(dataSource);
}
} catch (EMFUserError e) {
logger.error("Error while retrieving Datasource with label="+dataSourceLabel,e);
e.printStackTrace();
}
}
}
if(dsType.equalsIgnoreCase(DataSetConstants.DS_WS)){
ds=new WebServiceDataSet();
String wsAddress = getAttributeAsString(DataSetConstants.WS_ADDRESS);
String wsOperation = getAttributeAsString(DataSetConstants.WS_OPERATION);
((WebServiceDataSet)ds).setAddress(wsAddress);
((WebServiceDataSet)ds).setOperation(wsOperation);
}
if(dsType.equalsIgnoreCase(DataSetConstants.DS_SCRIPT)){
ds=new ScriptDataSet();
String script = getAttributeAsString(DataSetConstants.SCRIPT);
String scriptLanguage = getAttributeAsString(DataSetConstants.SCRIPT_LANGUAGE);
((ScriptDataSet)ds).setScript(script);
((ScriptDataSet)ds).setLanguageScript(scriptLanguage);
}
if(dsType.equalsIgnoreCase(DataSetConstants.DS_JCLASS)){
ds=new JavaClassDataSet();
String jclassName = getAttributeAsString(DataSetConstants.JCLASS_NAME);
((JavaClassDataSet)ds).setClassName(jclassName);
}
if(dsType.equalsIgnoreCase(DataSetConstants.DS_QBE)){
ds = new QbeDataSet();
QbeDataSet qbeDataSet = (QbeDataSet) ds;
String qbeDatamarts = getAttributeAsString(DataSetConstants.QBE_DATAMARTS);
String dataSourceLabel = getAttributeAsString(DataSetConstants.QBE_DATA_SOURCE);
String jsonQuery = getAttributeAsString(DataSetConstants.QBE_JSON_QUERY);
qbeDataSet.setJsonQuery(jsonQuery);
qbeDataSet.setDatamarts(qbeDatamarts);
IDataSource dataSource = DAOFactory.getDataSourceDAO().loadDataSourceByLabel(dataSourceLabel);
qbeDataSet.setDataSource(dataSource);
}
return ds;
}