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

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


     * @param documentId document id
     *
     * @return SpagoBiDataSource object
     */
    public IDataSource getDataSource(String documentId) {
      IDataSource dataSource = null;
      SpagoBiDataSource dataSourceConfig = null;
   
      logger.debug("IN.documentId="+documentId);
    if (documentId==null || documentId.length()==0){
        logger.error("documentId is NULL");
View Full Code Here


     * @param label document label
     *
     * @return SpagoBiDataSource object
     */
    public IDataSource getDataSourceByLabel(String label) {
      IDataSource dataSource = null;
      SpagoBiDataSource dataSourceConfig = null;
   
     
      logger.debug("IN.label="+label);
    if (label==null || label.length()==0){
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 (exportedDataSources == null || exportedDataSources.size() == 0) return false;
      IDataSourceDAO datasourceDAO = DAOFactory.getDataSourceDAO();
      List currentDataSources = datasourceDAO.loadAllDataSources();
      Iterator exportedDataSourcesIt = exportedDataSources.iterator();
      while (exportedDataSourcesIt.hasNext()) {
        IDataSource exportedDataSource = (IDataSource) exportedDataSourcesIt.next();
        String associatedDataSourceLabel = this.getUserAssociation().getAssociatedDataSource(exportedDataSource.getLabel());
        if (associatedDataSourceLabel == null || associatedDataSourceLabel.trim().equals("")) return true;
        Iterator currentDataSourcesIt = currentDataSources.iterator();
        boolean associatedDataSourceLabelExists = false;
        while (currentDataSourcesIt.hasNext()) {
          IDataSource currentDataSource = (IDataSource) currentDataSourcesIt.next();
          if (currentDataSource.getLabel().equals(associatedDataSourceLabel)) {
            associatedDataSourceLabelExists = true;
            metaAss.insertCoupleDataSources(new Integer(exportedDataSource.getDsId()), new Integer(currentDataSource.getDsId()));
            break;
          }
        }
        if (!associatedDataSourceLabelExists) return true;
      }
View Full Code Here

    public QbeDataSet(SpagoBiDataSet dataSetConfig) {

      this.setDatamarts(dataSetConfig.getDatamarts());
      this.setJsonQuery(dataSetConfig.getJsonQuery());
     
    IDataSource dataSource = DataSourceFactory.getDataSource( dataSetConfig.getDataSource() ) ;
    this.setDataSource(dataSource);
   
  }
View Full Code Here

      Assert.assertTrue(!StringUtilities.isEmpty( user ), "Parameter [" + USER_ID + "] cannot be null or empty");
     
      callback = getAttributeAsString( CALLBACK );
      logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
     
      IDataSource ds = consoleEngineInstance.getDataSource();           
      DataSourceUtilities utility = new DataSourceUtilities(ds);
      //gets hashmap with all parameters     
      Map<String , Object> params;
      params = getAttributesAsMap()
      JSONObject metaParams = getAttributeAsJSONObject( "metaParams" );
View Full Code Here

    Integer idService = null;
    String resourceName = null; // es. 'azienda_0'
    String pid = null; // es. 'azienda_0'
    String formatDate = null; //es. dd-mm-yyyy HH:mi:ss
   
    IDataSource dataSource;
   
    Connection conn;
    PreparedStatement stmt;
    String sql;    
   
    Double idServiceInstanceParam = null;
    Integer idServiceParam = null;
    //Date sysDate = null;
    Timestamp sysDate = null;
    String pidParam = null;
    Integer resourceIdParam = null;
   

    logger.debug("IN");
    Monitor monitor =MonitorFactory.start("SpagoBI_Console.NotifyStartAction.service")

    conn = null;
    stmt = null;
    try {
      super.service(request,response);
   
     
      //check for mandatory parameters            
      user = getAttributeAsString( USER_ID );
      logger.debug("Parameter [" + USER_ID + "] is equals to [" + user + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( user ), "Parameter [" + USER_ID + "] cannot be null or empty");
     
      idService = this.getAttributeAsInteger( ID_SERVICE );
      logger.debug("Parameter [" + ID_SERVICE + "] is equals to [" + idService + "]");     
      Assert.assertNotNull(idService, "Parameter [" + ID_SERVICE + "] cannot be null or empty");
     
      pid = getAttributeAsString( PID );
      logger.debug("Parameter [" + PID + "] is equals to [" + pid + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( pid ), "Parameter [" + PID + "] cannot be null or empty");
     
      resourceName = getAttributeAsString( RESOURCE_NAME );
      logger.debug("Parameter [" + RESOURCE_NAME + "] is equals to [" + resourceName + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( resourceName ), "Parameter [" + RESOURCE_NAME + "] cannot be null or empty");
     
      formatDate = getAttributeAsString( FORMAT_DATE );
      logger.debug("Parameter [" + FORMAT_DATE + "] is equals to [" + formatDate + "]");     

     
      dataSource = getConsoleEngineInstance().getDataSource()
      conn = dataSource.getConnection();
      conn.setAutoCommit(false);

     
      sql = "INSERT INTO SERVICE_INSTANCE "
          + "(ID_SERVICE_INSTANCE, " +          // 1
View Full Code Here

    } else {
      confSB = (SourceBean)conf;
    }
   
    if(confSB != null) {
      IDataSource dataSource = null;
      String query = null;
      IDataSet dataSet = null;
     
      dataSet = (IDataSet)datamartProvider.getEnv().get(EngineConstants.ENV_DATASET);
      if(dataSet != null) {
View Full Code Here

   * @return the data source
   *
   * @throws GeoEngineException the geo engine exception
   */
  public static IDataSource getDataSource(SourceBean confSB) throws GeoEngineException {
    IDataSource dataSource = null;
   
    SourceBean datasourceSB = (SourceBean)confSB.getAttribute(GeoEngineConstants.DATASOURCE_TAG);
    if(datasourceSB == null) {
      logger.warn("Cannot find datasource configuration settings: tag name " + GeoEngineConstants.DATASOURCE_TAG);
      logger.info("Datasource configuration settings must be injected at execution time");
      return null;
    }
   
    dataSource = new DataSource();
   
    String type = (String)datasourceSB.getAttribute(GeoEngineConstants.DATASET_TYPE_ATTRIBUTE);       
    if("connection".equalsIgnoreCase(type)) {
      dataSource.setJndi( (String)datasourceSB.getAttribute(GeoEngineConstants.DATASET_NAME_ATTRIBUTE) );
      dataSource.setDriver( (String)datasourceSB.getAttribute(GeoEngineConstants.DATASET_DRIVER_ATTRIBUTER) );
      dataSource.setPwd( (String)datasourceSB.getAttribute(GeoEngineConstants.DATASET_PWD_ATTRIBUTE) );
      dataSource.setUser( (String)datasourceSB.getAttribute(GeoEngineConstants.DATASET_USER_ATTRIBUTE) );
      dataSource.setUrlConnection( (String)datasourceSB.getAttribute(GeoEngineConstants.DATASET_URL_ATTRIBUTE) );
    }
   
    logger.debug("Datasource jndi name: " + dataSource.getJndi());
    logger.debug("Datasource driver: " + dataSource.getDriver());
    logger.debug("Datasource password: " + dataSource.getPwd());   
    logger.debug("Datasource user: " + dataSource.getUser());
    logger.debug("Datasource url: " + dataSource.getUrlConnection());
   
    if(dataSource.getJndi() != null) {
      logger.info("Datasource is of type jndi connection. Referenced jndi resource is " + dataSource.getJndi());
    } else if (dataSource.getDriver() == null || dataSource.getUrlConnection() == null){
      logger.error("Missing driver name or url in datasource configuration settings");
      throw new GeoEngineException("Missing driver name or url in datasource configuration settings");
    }
   
    return dataSource;
View Full Code Here

     *
     * @return the database connection
     */
    private Connection getConnection(String requestConnectionName,HttpSession session,IEngUserProfile profile,String documentId) {
      logger.debug("IN");
      IDataSource ds = null;

    DataSourceServiceProxy proxyDS = new DataSourceServiceProxy((String)profile.getUserUniqueIdentifier(),session);
    if(requestConnectionName == null){
      //get document's datasource
      ds = proxyDS.getDataSource(documentId);
    }else{
      //get datasource by label
      ds = proxyDS.getDataSourceByLabel(requestConnectionName);
    }
    if(ds != null){
      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);
        return conn;
      } catch (Exception e) {
        logger.error("Cannot retrive connection", e);
      }
    }
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.