logger.debug("IN");
if (dataset == null) {
logger.warn("SDKDataSet in input is null!!");
return null;
}
GuiGenericDataSet ds = null;
GuiDataSetDetail dsDetail = null;
try {
ds = new GuiGenericDataSet();
if (dataset.getId() != null){
ds.setDsId(dataset.getId());
}
ds.setLabel(dataset.getLabel());
ds.setName(dataset.getName());
ds.setDescription(dataset.getDescription());
//defines correct dataset detail
if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_FILE)){
dsDetail = new FileDataSetDetail();
String fileName = dataset.getFileName();
if(fileName!=null && !fileName.equals("")){
((FileDataSetDetail)dsDetail).setFileName(fileName);
}
}else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_JCLASS)){
dsDetail = new JClassDataSetDetail();
String jclassName = dataset.getJavaClassName();
if(jclassName!=null && !jclassName.equals("")){
((JClassDataSetDetail)dsDetail).setJavaClassName(jclassName);
}
}else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_QUERY)){
dsDetail = new QueryDataSetDetail();
String query = dataset.getJdbcQuery();
Integer dataSourceId = dataset.getJdbcDataSourceId();
if(query!=null && !query.equals("")){
((QueryDataSetDetail)dsDetail).setQuery(query);
}
if(dataSourceId!=null){
IDataSource dataSource = DAOFactory.getDataSourceDAO().loadDataSourceByID(dataSourceId);
if(dataSource!=null){
((QueryDataSetDetail)dsDetail).setDataSourceLabel(dataSource.getLabel());
}
}
}else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_QBE)){
dsDetail = new QbeDataSetDetail();
String sqlQuery = dataset.getJdbcQuery();
String jsonQuery = dataset.getJsonQuery();
Integer dataSourceId = dataset.getJdbcDataSourceId();
String datamarts = dataset.getDatamarts();
((QbeDataSetDetail) dsDetail).setSqlQuery(sqlQuery);
((QbeDataSetDetail) dsDetail).setJsonQuery(jsonQuery);
((QbeDataSetDetail) dsDetail).setDatamarts(datamarts);
IDataSource dataSource = DAOFactory.getDataSourceDAO().loadDataSourceByID(dataSourceId);
if(dataSource!=null){
((QbeDataSetDetail)dsDetail).setDataSourceLabel(dataSource.getLabel());
}
}else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_SCRIPT)){
dsDetail = new ScriptDataSetDetail();
String script = dataset.getScriptText();
String scriptLanguage = dataset.getScriptLanguage();
if(scriptLanguage!=null && !scriptLanguage.equals("")){
((ScriptDataSetDetail)dsDetail).setLanguageScript(scriptLanguage);
}
if(script!=null && !script.equals("")){
((ScriptDataSetDetail)dsDetail).setScript(script);
}
}else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_WS)){
dsDetail = new WSDataSetDetail();
String wsAddress = dataset.getWebServiceAddress();
String wsOperation = dataset.getWebServiceOperation();
if(wsOperation!=null && !wsOperation.equals("")){
((WSDataSetDetail)dsDetail).setOperation(wsOperation);
}
if(wsAddress!=null && !wsAddress.equals("")){
((WSDataSetDetail)dsDetail).setAddress(wsAddress);
}
}
//sets other general GuiDetailDataset object's fields
if(dataset.getPivotColumnName()!=null && !dataset.getPivotColumnName().equals("")){
dsDetail.setPivotColumnName(dataset.getPivotColumnName());
}
if(dataset.getPivotRowName()!=null && !dataset.getPivotRowName().equals("")){
dsDetail.setPivotRowName(dataset.getPivotRowName());
}
if(dataset.getPivotColumnValue()!=null && !dataset.getPivotColumnValue().equals("")){
dsDetail.setPivotColumnValue(dataset.getPivotColumnValue());
}
if(dataset.getNumberingRows()!=null){
dsDetail.setNumRows(dataset.getNumberingRows());
}
//dsDetail.setDsMetadata(dataset.getXXX);
//sets dataset's parameters
String parameters = null;
if (dataset.getParameters() != null) {
parameters = this.fromSDKDataSetParameterArrayToBIDataSetParameterList(dataset.getParameters());
}
dsDetail.setParameters(parameters);
/*
private String dsMetadata=null;
*/
IDomainDAO domainDAO = DAOFactory.getDomainDAO();
// sets dataset's transformer type domain
if (dataset.getTransformer() != null) {
Domain transformer = domainDAO.loadDomainByCodeAndValue("TRANSFORMER_TYPE", dataset.getTransformer());
dsDetail.setTransformerCd(transformer.getValueCd());
dsDetail.setTransformerId(transformer.getValueId());
}
// sets dataset's category domain
if (dataset.getCategory() != null){
Domain category = domainDAO.loadDomainByCodeAndValue("CATEGORY_TYPE", dataset.getCategory());
dsDetail.setCategoryValueName(category.getValueCd());
dsDetail.setCategoryId(category.getValueId());
}
ds.setActiveDetail(dsDetail);
} catch (Exception e) {
logger.error("Error while converting SDKDataSet into GuiGenericDataSet.", e);
logger.debug("Returning null.");
return null;