* @return the data source
*/
public SpagoBiDataSource getDataSource(String documentId) {
logger.debug("IN.documentId:" + documentId);
SpagoBiDataSource sbds = null;
if (documentId == null)
return null;
// gets data source data from database
try {
BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectById(Integer.valueOf(documentId));
if (obj == null) {
logger.error("The object with id " + documentId + " is not found on the database.");
return null;
}
Integer dsId = null;
if (obj.getDataSourceId() != null) {
dsId = obj.getDataSourceId();
logger.debug("Using document datasource id = " + dsId);
} else {
Engine engine = obj.getEngine();
dsId = engine.getDataSourceId();
logger.debug("Using document's engine datasource id = " + dsId);
}
if (dsId == null) {
logger.error("Data source is not configured neither for document nor for its engine.");
return null;
}
IDataSource ds = DAOFactory.getDataSourceDAO().loadDataSourceByID(dsId);
if (ds == null) {
logger.error("The data source with id " + obj.getDataSourceId() + " is not found on the database.");
return null;
}
Domain dialectHB = DAOFactory.getDomainDAO().loadDomainById(ds.getDialectId());
if (ds == null) {
logger.error("The data source with id " + obj.getDataSourceId() + " is not found on the database.");
return null;
}
sbds = new SpagoBiDataSource();
sbds.setLabel(ds.getLabel());
sbds.setJndiName(ds.getJndi());
sbds.setUrl(ds.getUrlConnection());
sbds.setUser(ds.getUser());
sbds.setPassword(ds.getPwd());
sbds.setDriver(ds.getDriver());
sbds.setHibDialectName(dialectHB.getValueName());
//change
// sbds.setHibDialectClass(dialectHB.getValueDescription());
sbds.setHibDialectClass(dialectHB.getValueCd());
logger.info("read DS: Label="+sbds.getLabel()+" Jndi="+sbds.getJndiName()+" HIB="+sbds.getHibDialectClass());
//gets dialect informations
IDomainDAO domaindao = DAOFactory.getDomainDAO();
Domain doDialect = domaindao.loadDomainById(ds.getDialectId());
sbds.setHibDialectClass(doDialect.getValueCd());
sbds.setHibDialectName(doDialect.getValueName());
sbds.setMultiSchema(ds.getMultiSchema());
sbds.setSchemaAttribute(ds.getSchemaAttribute());
} catch (Exception e) {
logger.error("The data source is not correctly returned", e);
sbds=null;