Package it.eng.spagobi.tools.datasource.bo

Examples of it.eng.spagobi.tools.datasource.bo.IDataSource


     * @return the database connection
     */
    private Connection getConnection(String requestConnectionName,HttpSession session,IEngUserProfile profile,String documentId) {
  logger.debug("IN.documentId:"+documentId);
  DataSourceServiceProxy proxyDS = new DataSourceServiceProxy((String)profile.getUserUniqueIdentifier(),session);
  IDataSource ds =null;
  if (requestConnectionName!=null){
      ds = proxyDS.getDataSourceByLabel(requestConnectionName);
  }else{
      ds = proxyDS.getDataSource(documentId);
  }
 
  String schema=null;
  try {
    if (ds.checkIsMultiSchema()){
      String attrname=ds.getSchemaAttribute();
      if (attrname!=null) schema = (String)profile.getUserAttribute(attrname);
    }
  } catch (EMFInternalError e) {
    logger.error("Cannot retrive ENTE", e);
  }

  if (ds==null) {
      logger.warn("Data Source IS NULL. There are problems reading DataSource informations");
      return null;
  }
  // get connection
  Connection conn = null;
 
  try {
    conn = ds.toSpagoBiDataSource().readConnection(schema);
  } catch (Exception e) {
    logger.error("Cannot retrive connection", e);
  }
 
  return conn;
View Full Code Here


   
 
  public void doService( EngineStartServletIOManager servletIOManager ) throws SpagoBIEngineException {
   
    GeoReportEngineInstance engineInstance;
    IDataSource dataSource;
        IDataSet dataSet;
    RequestDispatcher requestDispatcher;
   
        
        logger.debug("IN");
       
        try {
          // log some contextual infos
          logger.debug("User: [" + servletIOManager.getUserId() + "]");
          logger.debug("Document: [" + servletIOManager.getDocumentId() + "]");
         
          dataSource = servletIOManager.getDataSource();
          logger.debug("Datasource: [" + (dataSource == null? dataSource: dataSource.getLabel()) + "]");
          
          dataSet = servletIOManager.getDataSet();
          logger.debug("Dataset: [" + (dataSet == null? dataSource: dataSet.getName()) + "]");
         
          // create a new engine instance
View Full Code Here

      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;
  }
View Full Code Here

      }
      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;
View Full Code Here

  logger.debug("IN");
  SpagoBiDataSource sbds = new SpagoBiDataSource();

  // gets data source data from database
  try {
      IDataSource ds = DAOFactory.getDataSourceDAO().loadDataSourceByLabel(dsLabel);
      if (ds == null) {
    logger.warn("The data source with label " + dsLabel + " is not found on the database.");
    return null;
      }
      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.setMultiSchema(ds.getMultiSchema());
      sbds.setSchemaAttribute(ds.getSchemaAttribute());
     
    //gets dialect informations
      IDomainDAO domaindao = DAOFactory.getDomainDAO();
      Domain doDialect = domaindao.loadDomainById(ds.getDialectId());
      sbds.setHibDialectClass(doDialect.getValueCd());
      sbds.setHibDialectName(doDialect.getValueName());
     
  } catch (Exception e) {
      logger.error("The data source is not correctly returned", e);
View Full Code Here

    return null;
      }

      Iterator dsIt = lstDs.iterator();
      while (dsIt.hasNext()) {
    IDataSource ds = (IDataSource) dsIt.next();
    SpagoBiDataSource sbds = new SpagoBiDataSource();
    sbds.setJndiName(ds.getJndi());
    sbds.setUrl(ds.getUrlConnection());
    sbds.setUser(ds.getUser());
    sbds.setPassword(ds.getPwd());
    sbds.setDriver(ds.getDriver());
    //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());
     
    tmpList.add(sbds);
      }
  } catch (Exception e) {
      logger.error("The data sources are not correctly returned", e);
View Full Code Here

         
          } else {
            // case of FormEngine
           
            JDBCDataSet dataset = new JDBCDataSet();
            IDataSource datasource = (IDataSource) this.getEnv().get( EngineConstants.ENV_DATASOURCE );
            dataset.setDataSource(datasource);
            dataset.setUserProfileAttributes(UserProfileUtils.getProfileAttributes( (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));
            dataset.setQuery(sqlQuery);
            logger.debug("Executing query ...");
            dataset.loadData();
View Full Code Here

   *
   * @see it.eng.spagobi.tools.datasource.dao.IDataSourceDAO#loadDataSourceByLabel(string)
   */ 
  public IDataSource loadDataSourceByLabel(String label) throws EMFUserError {
    logger.debug("IN");
    IDataSource biDS = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
      tmpSession = getSession();
      tx = tmpSession.beginTransaction();
View Full Code Here

      String schema = null;
        String attrname = null;
   
        String datasourceLabel = this.getAttributeAsString(DATASOURCE_LABEL);
       
        IDataSource dataSource = getDataSourceServiceProxy().getDataSourceByLabel( datasourceLabel );   
        if (dataSource.checkIsMultiSchema()){
            logger.debug("Datasource [" + dataSource.getLabel() + "] is defined on multi schema");
            try {           
                logger.debug("Retriving target schema for datasource [" + dataSource.getLabel() + "]");
                attrname = dataSource.getSchemaAttribute();
                logger.debug("Datasource's schema attribute name is equals to [" + attrname + "]");                                
                Assert.assertNotNull(attrname, "Datasource's schema attribute name cannot be null in order to retrive the target schema");
                schema = (String)getUserProfile().getUserAttribute(attrname);
                Assert.assertNotNull(schema, "Impossible to retrive the value of attribute [" + attrname + "] form user profile");
                dataSource.setJndi( dataSource.getJndi() + schema);
                logger.debug("Target schema for datasource  [" + dataSource.getLabel() + "] is [" + dataSource.getJndi()+ "]");
            } catch (Throwable t) {
                throw new SpagoBIEngineRuntimeException("Impossible to retrive target schema for datasource [" + dataSource.getLabel() + "]", t);
            }
            logger.debug("Target schema for datasource  [" + dataSource.getLabel() + "] retrieved succesfully");
        }           

    return dataSource;
    }
View Full Code Here

    }

    if(iDataSet instanceof JDBCDataSet){     
      dsActiveDetail=new QueryDataSetDetail();
      ((QueryDataSetDetail)dsActiveDetail).setQuery((String)(((JDBCDataSet)iDataSet).getQuery()));
      IDataSource iDataSource=((JDBCDataSet)iDataSet).getDataSource();
      if(iDataSource!=null){
        String dataSourceLabel = iDataSource.getLabel();
        ((QueryDataSetDetail)dsActiveDetail).setDataSourceLabel(dataSourceLabel);
      }
      dsActiveDetail.setDsType(JDBC_DS_TYPE);
    }
   
    if(iDataSet instanceof QbeDataSet){     
      dsActiveDetail = new QbeDataSetDetail();
      QbeDataSetDetail aQbeDataSetDetail = (QbeDataSetDetail) dsActiveDetail;
      QbeDataSet aQbeDataSet = (QbeDataSet) iDataSet;
      aQbeDataSetDetail.setJsonQuery(aQbeDataSet.getJsonQuery());
      aQbeDataSetDetail.setDatamarts(aQbeDataSet.getDatamarts());
      IDataSource iDataSource = aQbeDataSet.getDataSource();
      if (iDataSource!=null){
        String dataSourceLabel = iDataSource.getLabel();
        aQbeDataSetDetail.setDataSourceLabel(dataSourceLabel);
      }
      dsActiveDetail.setDsType(QBE_DS_TYPE);
    }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.datasource.bo.IDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.