Package org.pentaho.actionsequence.dom

Examples of org.pentaho.actionsequence.dom.ActionSequenceDocument


    parameterProviders.put( IParameterProvider.SCOPE_REQUEST, parameterProvider );

    SimpleOutputHandler outputHandler = new SimpleOutputHandler( out, true );
    outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_DEFAULT );

    ActionSequenceDocument doc = createActionSequenceDocument( defaultParameterMap.keySet(), contentLinkingTemplate );
    runActionSequence( pentahoSession, parameterProviders, outputHandler, doc );

    try {
      out.flush();
      out.close();
View Full Code Here


   *          set of parameter names that appear in the MQL query
   * @return doc
   */
  protected ActionSequenceDocument createActionSequenceDocument( final Set<String> parameterNameSet,
      String contentLinkingTemplate ) {
    ActionSequenceDocument actionSequenceDocument = new ActionSequenceDocument();
    actionSequenceDocument.setTitle( "chartbeans_mql.xaction" ); //$NON-NLS-1$
    actionSequenceDocument.setVersion( "1" ); //$NON-NLS-1$
    actionSequenceDocument.setLoggingLevel( "debug" ); //$NON-NLS-1$
    actionSequenceDocument.setAuthor( "Dashboard" ); //$NON-NLS-1$
    actionSequenceDocument.setDescription( "Generate a chart through ChartBeans from an MQL statement." ); //$NON-NLS-1$
    actionSequenceDocument.setHelp( "Pass in an MQL statement that returns a table of three columns. The first column " //$NON-NLS-1$
        + "is the series, the second is the category and the third is the data." ); //$NON-NLS-1$
    actionSequenceDocument.setHelp( "" ); //$NON-NLS-1$
    actionSequenceDocument.setResultType( "rule" ); //$NON-NLS-1$

    IActionSequenceInput queryInput = actionSequenceDocument.createInput( "query", STRING_TYPE ); //$NON-NLS-1$
    IActionSequenceInput chartModelJsonInput = actionSequenceDocument.createInput( "chart-model-json", STRING_TYPE ); //$NON-NLS-1$
    IActionSequenceInput chartWidthInput = actionSequenceDocument.createInput( "chart-width", INTEGER_TYPE ); //$NON-NLS-1$
    chartWidthInput.addSource( REQUEST_INPUT_SOURCE, "chart-width" ); //$NON-NLS-1$
    chartWidthInput.setDefaultValue( "1" ); //$NON-NLS-1$
    IActionSequenceInput chartHeightInput = actionSequenceDocument.createInput( "chart-height", INTEGER_TYPE ); //$NON-NLS-1$
    chartHeightInput.addSource( REQUEST_INPUT_SOURCE, "chart-height" ); //$NON-NLS-1$
    chartHeightInput.setDefaultValue( "1" ); //$NON-NLS-1$
    IActionSequenceInput seriesColumnInput = actionSequenceDocument.createInput( "series-column", STRING_TYPE ); //$NON-NLS-1$
    seriesColumnInput.setDefaultValue( "1" ); //$NON-NLS-1$
    IActionSequenceInput categoryColumnInput = actionSequenceDocument.createInput( "category-column", STRING_TYPE ); //$NON-NLS-1$
    // set a default value of empty string to avoid an error when rendering pie charts (which don't have a category
    // column
    categoryColumnInput.setDefaultValue( "2" ); //$NON-NLS-1$
    IActionSequenceInput valueColumnInput = actionSequenceDocument.createInput( "value-column", STRING_TYPE ); //$NON-NLS-1$
    valueColumnInput.setDefaultValue( "0" ); //$NON-NLS-1$
    IActionSequenceInput scalingFactorInput = actionSequenceDocument.createInput( "scaling-factor", STRING_TYPE ); //$NON-NLS-1$

    // add inputs from parameterNameSet; these parameters will appear as placeholders in the query input
    for ( String parameterName : parameterNameSet ) {
      IActionSequenceInput input =
          actionSequenceDocument.createInput( ActionDefinitionEncoder.encodeBlankSpaces( parameterName ), STRING_TYPE );
      IActionSequenceInputSource[] sources = input.getSources();
      if ( sources.length > 0 ) {
        input.getSources()[0].setName( parameterName );
      } else {
        input.addSource( "request", parameterName );
      }
    }

    IActionSequenceOutput outputStreamOutput = actionSequenceDocument.createOutput( "outputstream", CONTENT_TYPE ); //$NON-NLS-1$
    outputStreamOutput.addDestination( RESPONSE_OUTPUT_DESTINATION, "content" ); //$NON-NLS-1$

    MQLAction mqlAction = (MQLAction) actionSequenceDocument.addAction( MQLAction.class );
    mqlAction.setActionInputValue( "query", queryInput ); //$NON-NLS-1$

    // add inputs from parameterNameSet to this action
    for ( String parameterName : parameterNameSet ) {
      mqlAction.addInput( ActionDefinitionEncoder.encodeBlankSpaces( parameterName ), STRING_TYPE );
    }

    mqlAction.setOutputResultSet( "chartdata" ); //$NON-NLS-1$
    mqlAction.setComponentDefinition( "live", Boolean.TRUE.toString() ); //$NON-NLS-1$
    mqlAction.setComponentDefinition( "display-names", Boolean.FALSE.toString() ); //$NON-NLS-1$

    ActionDefinition pojoAction = (ActionDefinition) actionSequenceDocument.addAction( ActionDefinition.class );
    pojoAction.setComponentName( "ChartBeansComponent" ); //$NON-NLS-1$
    if ( contentLinkingTemplate != null ) {
      pojoAction.setComponentDefinition( "contentLinkingTemplate", contentLinkingTemplate );
    }
    pojoAction.setActionInputValue( "chart-model-json", chartModelJsonInput ); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.pentaho.actionsequence.dom.ActionSequenceDocument

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.