Package org.pentaho.actionsequence.dom.actions

Examples of org.pentaho.actionsequence.dom.actions.AbstractRelationalDbAction


    IActionDefinition actionDefinition = getActionDefinition();
    String actionName = getActionName();

    if ( actionDefinition instanceof AbstractRelationalDbAction ) {
      AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) actionDefinition;
      IActionInput query = relationalDbAction.getQuery();
      IActionInput dbUrl = relationalDbAction.getDbUrl();
      IActionInput jndi = relationalDbAction.getJndi();

      IActionInput sharedConnection = relationalDbAction.getSharedConnection();
      if ( query == ActionInputConstant.NULL_INPUT ) {

        error( Messages.getInstance().getErrorString( "SQLBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", actionName ) ); //$NON-NLS-1$
        result = false;
      }
View Full Code Here


  protected boolean executeAction() {
    IActionDefinition actionDefinition = getActionDefinition();
    try {

      if ( actionDefinition instanceof AbstractRelationalDbAction ) {
        AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) actionDefinition;
        // Added by Arijit Chatterjee
        IActionInput queryTimeoutInput = relationalDbAction.getQueryTimeout();
        IActionInput maxRowsInput = relationalDbAction.getMaxRows();
        IActionInput readOnlyInput = relationalDbAction.getReadOnly();

        String baseQuery = getQuery();
        if ( baseQuery == null ) {
          error( Messages.getInstance().getErrorString(
              "SQLBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", actionDefinition.getDescription() ) ); //$NON-NLS-1$
          return false;
        }

        IPreparedComponent sharedConnection = (IPreparedComponent) relationalDbAction.getSharedConnection().getValue();

        if ( readOnlyInput != ActionInputConstant.NULL_INPUT ) {
          this.setReadOnly( readOnlyInput.getBooleanValue() );
        }

        if ( sharedConnection != null ) {
          connectionOwner = false;
          IPentahoConnection conn = sharedConnection.shareConnection();
          if ( conn == null ) {
            error( Messages.getInstance().getErrorString(
                "IPreparedComponent.ERROR_0002_CONNECTION_NOT_AVAILABLE", getActionName() ) ); //$NON-NLS-1$
            return false;
          } else if ( conn.getDatasourceType() == IPentahoConnection.SQL_DATASOURCE ) {
            connection = conn;
          } else {
            error( Messages.getInstance().getErrorString(
                "IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", getActionName() ) ); //$NON-NLS-1$
            return false;
          }
        } else {
          dispose();
          connection = getDatasourceConnection();
        }

        if ( connection == null ) {
          return false;
        }

        // Check if this is a prepared query that will be executed later. If so cache the
        // query and set this component as the output. This query will be run later from a subreport.
        if ( relationalDbAction.getOutputPreparedStatement() != null ) {
          prepareQuery( baseQuery );
          IActionOutput actionOutput = relationalDbAction.getOutputPreparedStatement();
          if ( actionOutput != null ) {
            actionOutput.setValue( this );
          }
          return true;
        }

        // TODO not sure if this should be allowed without connection ownership?
        // int maxRows = relationalDbAction.getMaxRows().getIntValue(-1);
        if ( maxRowsInput != ActionInputConstant.NULL_INPUT ) {
          this.setMaxRows( maxRowsInput.getIntValue() );
        }

        // Added by Arijit Chatterjee.Sets the value of timeout. Default is -1, if parameter not found.
        if ( queryTimeoutInput != ActionInputConstant.NULL_INPUT ) {
          this.setQueryTimeout( queryTimeoutInput.getIntValue() );
        }

        if ( relationalDbAction.getPerformTransform().getBooleanValue( false ) ) {
          runQuery( baseQuery, false ); // The side effect of
          // transform rSet here

          rSet =
              PentahoDataTransmuter.crossTab( rSet, relationalDbAction.getTransformPivotColumn().getIntValue( -1 ) - 1,
                  relationalDbAction.getTransformMeasuresColumn().getIntValue( -1 ) - 1, relationalDbAction
                      .getTransformSortColumn().getIntValue( 0 ) - 1, (Format) relationalDbAction
                      .getTransformPivotDataFormat().getValue(), (Format) relationalDbAction
                      .getTransformSortDataFormat().getValue(), relationalDbAction.getTransformOrderOutputColumns()
                      .getBooleanValue( false ) );

          IActionOutput actionOutput = relationalDbAction.getOutputResultSet();
          if ( actionOutput != null ) {
            actionOutput.setValue( rSet );
          }
          return true;
        } else {
          return runQuery( baseQuery, relationalDbAction.getLive().getBooleanValue( false ) );
        }
      } else if ( actionDefinition instanceof SqlConnectionAction ) {
        SqlConnectionAction sqlConnectionAction = (SqlConnectionAction) actionDefinition;
        dispose();
        connection = getDatasourceConnection();
View Full Code Here

      }

      boolean live = true;
      IActionDefinition actionDefinition = getActionDefinition();
      if ( actionDefinition instanceof AbstractRelationalDbAction ) {
        AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) actionDefinition;
        live = relationalDbAction.getLive().getBooleanValue( false );
      }

      IPentahoResultSet rs = resultSet;

      // BISERVER-5915, BISERVER-5875 - if the live setting is false, return an in memory resultset.
View Full Code Here

        if ( this.getReadOnly() ) {
          sqlConnection.setReadOnly( true );
        }
      }

      AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) getActionDefinition();

      IPentahoResultSet resultSet = null;
      boolean isForwardOnly = relationalDbAction.getUseForwardOnlyResultSet().getBooleanValue( false );

      resultSet = doQuery( sqlConnection, query, isForwardOnly );

      if ( sqlConnection.isForcedForwardOnly() ) {
        isForwardOnly = true;
        live = false;
        warn( Messages.getInstance().getString( "SQLBaseComponent.WARN_FALL_BACK_TO_NONSCROLLABLE" ) ); //$NON-NLS-1$
      }

      if ( live ) {

        // set the result set as the output
        rSet = resultSet;

        // After preparation and execution, we need to clear out the
        // prepared parameters.
        preparedParameters.clear();
        if ( resultSet != null ) {
          getMetadata( resultSet, true );
          IActionOutput actionOutput = relationalDbAction.getOutputResultSet();
          if ( actionOutput != null ) {
            actionOutput.setValue( resultSet );
          }
          return true;
        } else {
          // close the connection if owner
          error( Messages.getInstance().getErrorString( "SQLBaseComponent.ERROR_0006_EXECUTE_FAILED",
            getActionName() ) ); //$NON-NLS-1$
          if ( connectionOwner ) {
            connection.close();
          }
          return false;
        }

      } else {
        // execute the query, read the results and cache them
        try {
          // After preparation and execution, we need to clear out the
          // prepared parameters.
          preparedParameters.clear();

          IPentahoResultSet cachedResultSet = resultSet.memoryCopy();
          rSet = cachedResultSet;

          IActionOutput actionOutput = relationalDbAction.getOutputResultSet();
          if ( actionOutput != null ) {
            actionOutput.setValue( cachedResultSet );
          }
        } finally {
          // close the connection if owner
View Full Code Here

        driver = sqlConnectionAction.getDriver().getStringValue();
        userId = sqlConnectionAction.getUserId().getStringValue();
        password = sqlConnectionAction.getPassword().getStringValue();
        connectionInfo = sqlConnectionAction.getDbUrl().getStringValue();
      } else if ( getActionDefinition() instanceof AbstractRelationalDbAction ) {
        AbstractRelationalDbAction relationalDbAction = (AbstractRelationalDbAction) getActionDefinition();
        jndiName = relationalDbAction.getJndi().getStringValue();
        driver = relationalDbAction.getDriver().getStringValue();
        userId = relationalDbAction.getUserId().getStringValue();
        password = relationalDbAction.getPassword().getStringValue();
        connectionInfo = relationalDbAction.getDbUrl().getStringValue();
      }
      if ( jndiName != null ) {
        localConnection =
            PentahoConnectionFactory.getConnection( IPentahoConnection.SQL_DATASOURCE, jndiName, getSession(), this );
      }
View Full Code Here

TOP

Related Classes of org.pentaho.actionsequence.dom.actions.AbstractRelationalDbAction

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.