* @param hibDataSet The hybernate data set
* @return The corrispondent <code>DataSet</code> object
* @throws EMFUserError
*/
public IDataSet toIDataSet(SbiDataSetHistory hibDataSet) throws EMFUserError{
IDataSet ds = null;
if(hibDataSet instanceof SbiFileDataSet){
ds = new FileDataSet();
((FileDataSet)ds).setFileName(((SbiFileDataSet)hibDataSet).getFileName());
ds.setDsType(DataSetConstants.FILE);
}
if(hibDataSet instanceof SbiQueryDataSet){
ds=new JDBCDataSet();
((JDBCDataSet)ds).setQuery(((SbiQueryDataSet)hibDataSet).getQuery());
SbiDataSource sbids=((SbiQueryDataSet)hibDataSet).getDataSource();
if(sbids!=null){
DataSourceDAOHibImpl dataSourceDao=new DataSourceDAOHibImpl();
IDataSource dataSource=dataSourceDao.toDataSource(sbids);
((JDBCDataSet)ds).setDataSource(dataSource);
}
ds.setDsType(DataSetConstants.QUERY);
}
if(hibDataSet instanceof SbiWSDataSet){
ds=new WebServiceDataSet();
((WebServiceDataSet)ds).setAddress(((SbiWSDataSet)hibDataSet).getAdress());
((WebServiceDataSet)ds).setOperation(((SbiWSDataSet)hibDataSet).getOperation());
ds.setDsType(DataSetConstants.WEB_SERVICE);
}
if(hibDataSet instanceof SbiScriptDataSet){
ds=new ScriptDataSet();
((ScriptDataSet)ds).setScript(((SbiScriptDataSet)hibDataSet).getScript());
((ScriptDataSet)ds).setLanguageScript(((SbiScriptDataSet)hibDataSet).getLanguageScript());
ds.setDsType(DataSetConstants.SCRIPT);
}
if(hibDataSet instanceof SbiJClassDataSet){
ds=new JavaClassDataSet();
((JavaClassDataSet)ds).setClassName(((SbiJClassDataSet)hibDataSet).getJavaClassName());
ds.setDsType(DataSetConstants.JAVA_CLASS);
}
if (hibDataSet instanceof SbiQbeDataSet) {
ds = new QbeDataSet();
SbiQbeDataSet aSbiQbeDataSet = (SbiQbeDataSet) hibDataSet;
QbeDataSet qbeDataset = (QbeDataSet) ds;
qbeDataset.setJsonQuery(aSbiQbeDataSet.getJsonQuery());
qbeDataset.setDatamarts(aSbiQbeDataSet.getDatamarts());
SbiDataSource sbids = aSbiQbeDataSet.getDataSource();
if (sbids!=null){
DataSourceDAOHibImpl dataSourceDao = new DataSourceDAOHibImpl();
IDataSource dataSource = dataSourceDao.toDataSource(sbids);
qbeDataset.setDataSource(dataSource);
}
ds.setDsType(DataSetConstants.QBE);
}
if(ds!=null){
if(hibDataSet.getSbiDsConfig()!=null){
ds.setId(hibDataSet.getSbiDsConfig().getDsId());
ds.setName(hibDataSet.getSbiDsConfig().getName());
ds.setLabel(hibDataSet.getSbiDsConfig().getLabel());
ds.setDescription(hibDataSet.getSbiDsConfig().getDescription());
}
ds.setTransformerId((hibDataSet.getTransformer()==null)?null:hibDataSet.getTransformer().getValueId());
ds.setPivotColumnName(hibDataSet.getPivotColumnName());
ds.setPivotRowName(hibDataSet.getPivotRowName());
ds.setPivotColumnValue(hibDataSet.getPivotColumnValue());
ds.setNumRows(hibDataSet.isNumRows());
ds.setParameters(hibDataSet.getParameters());
ds.setDsMetadata(hibDataSet.getDsMetadata());
if(ds.getPivotColumnName() != null
&& ds.getPivotColumnValue() != null
&& ds.getPivotRowName() != null){
ds.setDataStoreTransformer(
new PivotDataSetTransformer(ds.getPivotColumnName(), ds.getPivotColumnValue(), ds.getPivotRowName(), ds.isNumRows()));
}
}
return ds;
}