Examples of MdxConnectionAction


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

  @Override
  protected boolean validateAction() {
    boolean actionValidated = true;
    MdxQueryAction queryAction = null;
    MdxConnectionAction connAction = null;

    try {
      if ( getActionDefinition() instanceof MdxQueryAction ) {
        queryAction = (MdxQueryAction) getActionDefinition();
        actionValidated = isConnectionInfoSpecified( queryAction );

        if ( actionValidated ) {
          if ( queryAction.getQuery() == ActionInputConstant.NULL_INPUT ) {
            error( Messages.getInstance().getErrorString(
              "MDXBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", getActionName() ) ); //$NON-NLS-1$
            actionValidated = false;
          }
        }

        if ( actionValidated ) {
          if ( ( queryAction.getOutputResultSet() == null ) && ( queryAction.getOutputPreparedStatement() == null ) ) {
            error( Messages.getInstance().getErrorString(
              "MDXBaseComponent.ERROR_0003_OUTPUT_NOT_SPECIFIED", getActionName() ) ); //$NON-NLS-1$
            actionValidated = false;
          }
        }
      } else if ( getActionDefinition() instanceof MdxConnectionAction ) {
        connAction = (MdxConnectionAction) getActionDefinition();
        actionValidated = isConnectionInfoSpecified( connAction );
        if ( connAction.getOutputConnection() == null ) {
          error( Messages.getInstance().getErrorString(
            "MDXBaseComponent.ERROR_0003_OUTPUT_NOT_SPECIFIED", getActionName() ) ); //$NON-NLS-1$
          actionValidated = false;
        }
View Full Code Here

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

  protected IPentahoConnection getConnection() {

    // first attempt to get the connection metadata from the catalog service. if that is not successful,
    // get the connection using the original approach.

    MdxConnectionAction connAction = (MdxConnectionAction) getActionDefinition();
    String catalogName = connAction.getCatalog().getStringValue();
    IMondrianCatalogService mondrianCatalogService =
        PentahoSystem.get( IMondrianCatalogService.class, "IMondrianCatalogService", PentahoSessionHolder.getSession() ); //$NON-NLS-1$
    MondrianCatalog catalog = mondrianCatalogService.getCatalog( catalogName, PentahoSessionHolder.getSession() );

    if ( catalog == null ) {
      return getConnectionOrig();
    }

    Util.PropertyList connectProperties = Util.parseConnectString( catalog.getDataSourceInfo() );

    Properties properties = new Properties();

    Iterator<Pair<String, String>> iter = connectProperties.iterator();
    while ( iter.hasNext() ) {
      Pair<String, String> pair = iter.next();
      properties.put( pair.getKey(), pair.getValue() );
    }

    properties.put( "Catalog", catalog.getDefinition() );
    properties.put( "Provider", "mondrian" );
    properties.put( "PoolNeeded", "false" );
    properties.put( RolapConnectionProperties.Locale.name(), LocaleHelper.getLocale().toString() );

    debug( "Mondrian Connection Properties: " + properties.toString() );

    MDXConnection mdxConnection =
        (MDXConnection) PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, properties,
          PentahoSessionHolder.getSession(), this );

    if ( connAction != null ) {
      if ( ( connAction.getExtendedColumnNames() != ActionInputConstant.NULL_INPUT ) ) {
        mdxConnection.setUseExtendedColumnNames( connAction.getExtendedColumnNames().getBooleanValue() );
      }
    }

    return mdxConnection;
  }
View Full Code Here

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

    return mdxConnection;
  }

  protected IPentahoConnection getConnectionOrig() {
    IPentahoConnection localConnection = null;
    MdxConnectionAction connAction = (MdxConnectionAction) getActionDefinition();
    try {
      String mdxConnectionStr = connAction.getMdxConnectionString().getStringValue();
      Properties mdxConnectionProps = (Properties) connAction.getConnectionProps().getValue();
      String jdbcStr = connAction.getConnection().getStringValue();
      String jndiStr = connAction.getJndi().getStringValue();
      String location = connAction.getLocation().getStringValue();
      String role = connAction.getRole().getStringValue();
      String catalog = connAction.getCatalog().getStringValue();

      if ( ( catalog == null ) && ( connAction.getCatalogResource() != null ) ) {
        IActionSequenceResource resource = getResource( connAction.getCatalogResource().getName() );
        catalog = resource.getAddress();
        if ( ( resource.getSourceType() == IActionSequenceResource.URL_RESOURCE )
            && ( catalog.indexOf( "solution:" ) != 0 ) ) { //$NON-NLS-1$
          // Extra step to make sure that remote mondrian models
          // fully qualified aren't munged
          // MB
          if ( !catalog.startsWith( "http:" ) ) { //$NON-NLS-1$
            catalog = "solution:" + catalog; //$NON-NLS-1$
          }
        } else if ( ( resource.getSourceType() == IActionSequenceResource.SOLUTION_FILE_RESOURCE )
            || ( resource.getSourceType() == IActionSequenceResource.FILE_RESOURCE ) ) {
          if ( !catalog.startsWith( "solution:" ) ) {
            catalog = "solution:" + catalog; //$NON-NLS-1$
          }
        }
      }
      if ( catalog == null ) {
        warn( Messages.getInstance().getString( "MDXBaseComponent.ERROR_0007_CATALOG_NOT_DEFINED", getActionName() ) ); //$NON-NLS-1$
      } else {
        if ( mdxConnectionProps != null ) {
          mdxConnectionProps.put( MdxConnectionAction.CATALOG_ELEMENT, catalog );
        }
      }

      String userId = connAction.getUserId().getStringValue();
      String password = connAction.getPassword().getStringValue();
      if ( mdxConnectionProps != null ) {
        localConnection =
            PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, mdxConnectionProps,
                getSession(), this );
      } else {
        if ( mdxConnectionStr != null ) {
          localConnection =
              PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, mdxConnectionStr,
                  getSession(), this );
        } else {
          String connectStr = null;
          if ( jdbcStr != null ) {
            connectStr = jdbcStr + "; Catalog=" + catalog; //$NON-NLS-1$
          } else if ( jndiStr != null ) {

            IDBDatasourceService datasourceService =
                PentahoSystem.getObjectFactory().get( IDBDatasourceService.class, null );
            if ( datasourceService.getDataSource( jndiStr ) == null ) {
              error( Messages.getInstance().getErrorString( "MDXBaseComponent.ERROR_0005_INVALID_CONNECTION" ) ); //$NON-NLS-1$
              return null;
            }

            connectStr = "dataSource=" + jndiStr + "; Catalog=" + catalog; //$NON-NLS-1$ //$NON-NLS-2$
            // Add extra definitions from platform mondrian metadata
            MondrianCatalog mc =
                org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper.getInstance().getCatalog(
                  catalog, getSession() );
            try {
              connectStr += ";" + mc.getDataSourceInfo();
            } catch ( Exception e ) {
              // Just swallow the exception
            }
          }
          if ( role != null ) {
            connectStr += "; Role=" + role; //$NON-NLS-1$
          }
          Properties props = new Properties();
          props.setProperty( IPentahoConnection.CONNECTION, connectStr );
          props.setProperty( IPentahoConnection.PROVIDER, location );
          if ( userId != null ) {
            props.setProperty( IPentahoConnection.USERNAME_KEY, userId );
          }
          if ( password != null ) {
            props.setProperty( IPentahoConnection.PASSWORD_KEY, password );
          }

          localConnection =
              PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, props, getSession(), this );
        }
        if ( localConnection == null ) {
          error( Messages.getInstance().getErrorString( "MDXBaseComponent.ERROR_0005_INVALID_CONNECTION" ) ); //$NON-NLS-1$
          return null;
        }
      }

      if ( localConnection instanceof MDXConnection ) {
        MDXConnection mdxConn = (MDXConnection) localConnection;
        if ( connAction != null ) {
          if ( ( connAction.getExtendedColumnNames() != ActionInputConstant.NULL_INPUT ) ) {
            mdxConn.setUseExtendedColumnNames( connAction.getExtendedColumnNames().getBooleanValue() );
          }
        }
      }
      return localConnection;
    } catch ( Exception e ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.