Package org.pentaho.actionsequence.dom.actions

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


     *
     * public OnTheFlyJFreeReportGenerator(String path, IPentahoResultSet set, List groupLabels, List widths,
     * OutputStream stream) ------ public void process()
     */

    JFreeReportGenAction genAction = null;

    if ( !( getActionDefinition() instanceof JFreeReportGenAction ) ) {
      error( Messages.getInstance().getErrorString(
          "JFreeReportGeneratorComponent.ERROR_0001_UNKNOWN_ACTION_TYPE", getActionDefinition().getElement().asXML() ) ); //$NON-NLS-1$
      return false;
    } else {
      genAction = (JFreeReportGenAction) getActionDefinition();

      resultSet = (IPentahoResultSet) genAction.getResultSet().getValue();
      Node componentNode = null;
      String settingsFromActionSequence = null;
      try {
        settingsFromActionSequence = genAction.getComponentSettings().getStringValue();
      } catch ( Exception ex ) {
        //ignore
      }
      if ( settingsFromActionSequence != null ) {
        try {
          Document settingsDoc =
              XmlDom4JHelper.getDocFromString( settingsFromActionSequence, new PentahoEntityResolver() );
          componentNode = settingsDoc.getRootElement();
        } catch ( Exception e ) {
          error( "Could not get settings from action sequence document", e ); //$NON-NLS-1$
          return false;
        }
      } else {
        componentNode = getComponentDefinition();
      }
      try {
        compPath = genAction.getTemplatePath().getStringValue();
        path = PentahoSystem.getApplicationContext().getSolutionPath( compPath );
        orientation = genAction.getOrientation().getStringValue();
        nullString = genAction.getNullString().getStringValue();
        horizontalOffset = genAction.getHorizontalOffset().getIntValue( horizontalOffset );
        reportName = genAction.getReportName().getStringValue();
        createSubTotals = genAction.getCreateSubTotals().getBooleanValue( false );
        createGrandTotals = genAction.getCreateGrandTotals().getBooleanValue( false );
        createRowBanding = genAction.getCreateRowBanding().getBooleanValue( false );
        createTotalColumn = genAction.getCreateTotalColumn().getBooleanValue( false );
        totalColumnName = genAction.getTotalColumnName().getStringValue();
        totalColumnWidth = genAction.getTotalColumnWidth().getIntValue( totalColumnWidth );
        totalColumnFormat = genAction.getTotalColumnFormat().getStringValue();
        rowBandingColor = genAction.getRowBandingColor().getStringValue();
        spacerWidth = genAction.getSpacerWidth().getIntValue( spacerWidth );
        columnHeaderBackgroundColor = genAction.getColumnHeaderBackgroundColor().getStringValue();
        columnHeaderForegroundColor = genAction.getColumnHeaderForegroundColor().getStringValue();
        columnHeaderFontFace = genAction.getColumnHeaderFontFace().getStringValue();
        columnHeaderFontSize = genAction.getColumnHeaderFontSize().getStringValue();
        columnHeaderGap = genAction.getColumnHeaderGap().getIntValue( columnHeaderGap );
      } catch ( Exception e ) {
        e.printStackTrace();
      }

      // Get the group display labels
      List groupLabelNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.GROUP_LABELS_PROP
              + "/" + JFreeReportGeneratorComponent.GROUP_LABEL_PROP ); //$NON-NLS-1$
      if ( groupLabelNodes != null ) {
        groupLabels = new String[groupLabelNodes.size()];
        for ( int i = 0; i < groupLabels.length; i++ ) {
          groupLabels[i] = ( (Node) groupLabelNodes.get( i ) ).getText();
        }
      }
      // Get the grouped columns indices
      List groupedColumnsIndicesNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.GROUPED_COLUMNS_PROP
              + "/" + JFreeReportGeneratorComponent.GROUPED_COLUMN_INDICES_PROP ); //$NON-NLS-1$
      if ( groupedColumnsIndicesNodes != null ) {
        groupIndices = new int[groupedColumnsIndicesNodes.size()];
        for ( int i = 0; i < groupIndices.length; i++ ) {
          groupIndices[i] = Integer.parseInt( ( (Node) groupedColumnsIndicesNodes.get( i ) ).getText() ) - 1;
          // I am zero based, this is not
        }
      }
      // get display names
      List displayNameNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.COLUMN_NAMES_PROP
              + "/" + JFreeReportGeneratorComponent.COLUMN_NAME_PROP ); //$NON-NLS-1$
      if ( displayNameNodes != null ) {
        displayNames = new String[displayNameNodes.size()];
        for ( int i = 0; i < displayNames.length; i++ ) {
          displayNames[i] = ( (Node) displayNameNodes.get( i ) ).getText();
        }
      }
      // get column alignments
      List columnAlignmentNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.COLUMN_ALIGNMENTS_PROP
              + "/" + JFreeReportGeneratorComponent.COLUMN_ALIGNMENT_PROP ); //$NON-NLS-1$
      if ( columnAlignmentNodes != null ) {
        columnAlignments = new String[columnAlignmentNodes.size()];
        for ( int i = 0; i < columnAlignments.length; i++ ) {
          columnAlignments[i] = ( (Node) columnAlignmentNodes.get( i ) ).getText();
        }
      }
      // Get the column widths
      List widthNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.COLUMN_WIDTHS_PROP
              + "/" + JFreeReportGeneratorComponent.WIDTH_PROP ); //$NON-NLS-1$
      if ( widthNodes != null ) {
        widths = new int[widthNodes.size()];
        for ( int i = 0; i < widths.length; i++ ) {
          widths[i] = Integer.valueOf( ( (Node) widthNodes.get( i ) ).getText() ).intValue();
        }
      }
      // Get the column item hides
      List itemHideNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.ITEM_HIDES_PROP
              + "/" + JFreeReportGeneratorComponent.ITEM_HIDE_PROP ); //$NON-NLS-1$
      if ( itemHideNodes != null ) {
        itemHides = new boolean[itemHideNodes.size()];
        for ( int i = 0; i < itemHides.length; i++ ) {
          itemHides[i] = Boolean.valueOf( ( (Node) itemHideNodes.get( i ) ).getText() ).booleanValue();
        }
      }
      // Get the column formats
      List formatNodes =
          componentNode.selectNodes( JFreeReportGeneratorComponent.COLUMN_FORMATS_PROP
              + "/" + JFreeReportGeneratorComponent.FORMAT_PROP ); //$NON-NLS-1$
      if ( formatNodes != null ) {
        formats = new String[formatNodes.size()];
        for ( int i = 0; i < formats.length; i++ ) {
          formats[i] = ( (Node) formatNodes.get( i ) ).getText();
        }
      }
    }
    String reportDefinition = process();
    if ( reportDefinition != null ) {
      if ( genAction.getOutputReportDefinition() != null ) {
        genAction.getOutputReportDefinition().setValue( reportDefinition );
      } else {
        // This is to support the old way where
        // we did not check if report-definition existed in the output section
        setOutputValue( JFreeReportGenAction.REPORT_DEFINITION, reportDefinition );
      }
View Full Code Here

TOP

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

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.