Package org.pentaho.reporting.engine.classic.core.states

Examples of org.pentaho.reporting.engine.classic.core.states.ReportStateKey


  }

  public static CrosstabSpecification fillOrderedCrosstabSpec(final TableModel model) throws ReportProcessingException
  {
    final CrosstabSpecification spec =
        new OrderedMergeCrosstabSpecification(new ReportStateKey(), new String[]{"Cols"}, new String[]{"Rows"});
    return fillCrosstabSpec(model, spec);
  }
View Full Code Here


  }

  public static CrosstabSpecification fillSortedCrosstabSpec(final TableModel model) throws ReportProcessingException
  {
    final CrosstabSpecification spec =
        new SortedMergeCrosstabSpecification(new ReportStateKey(), new String[]{"Cols"}, new String[]{"Rows"});
    return fillCrosstabSpec(model, spec);
  }
View Full Code Here

    final GlobalMasterRow gmr = GlobalMasterRow.createReportRow
        (prc, new DefaultDataSchemaDefinition(), new ParameterDataRow());
    gmr.requireStructuralProcessing();
    MasterDataRow masterDataRow = gmr.deriveWithQueryData(data);
    final CrosstabSpecification crosstabSpecification = new SortedMergeCrosstabSpecification
        (new ReportStateKey(), new String[]{"Product", "Time"}, new String[] {"Region"});

    int advanceCount = 0;
    logger.debug("Building Crosstab: Cursor: " + String.valueOf(masterDataRow.getReportDataRow().getCursor()));
    crosstabSpecification.startRow();
    crosstabSpecification.add(masterDataRow.getGlobalView());
View Full Code Here

    {
      throw new IllegalStateException();
    }

    // we need to execute the state until it returns ..
    final ReportStateKey processKey = state.getProcessKey();
    ProcessState process = new ProcessState();
    process.initializeForSubreport(markers, index, state);
    while (processKey.equals(process.getProcessKey()) == false)
    {
      process = process.advance();
      if (processKey.equals(process.getProcessKey()))
      {
        throw new IllegalStateException("You cannot switch contexts when not being commited!");
      }
      process = process.commit();
    }
View Full Code Here

    }
    else
    {
      next.setAdvanceHandler(EndReportHandler.HANDLER);
    }
    final ReportStateKey parentStateKey;
    final ReportState parentState = next.getParentSubReportState();
    if (parentState == null)
    {
      parentStateKey = null;
    }
View Full Code Here

     * @param event The event.
     */
    public void reportInitialized(final ReportEvent event)
    {
      // identifies the report we are working with. Useful for debugging!
      ReportStateKey subReportStateKey = event.getState().getProcessKey();
      ReportStateKey parentReportStateKey = event.getState().getParentSubReportState().getProcessKey();
//      System.out.println ("SubReport: " + subReportStateKey);
//      System.out.println ("Parent: " + parentReportStateKey);

      final ReportHeader reportHeader = event.getState().getReport().getReportHeader();
      final Element element = reportHeader.getElement(0); // this should be the chart
View Full Code Here

    this.currentGroupIndex = ReportState.BEFORE_FIRST_GROUP;
    this.currentPresentationGroupIndex = ReportState.BEFORE_FIRST_GROUP;
    this.functionStorage = new FunctionStorage();
    this.structureFunctionStorage = new FunctionStorage();
    this.sequenceCounter = 0;
    this.processKey = new ReportStateKey
        (null, ReportState.BEFORE_FIRST_ROW, 0, ReportState.BEFORE_FIRST_GROUP, -1, sequenceCounter, false, false);
    this.dataFactoryManager = new DataFactoryManager();
    this.subReportStorage = new SubReportStorage();
    this.processHandle = new InternalProcessHandle(dataFactoryManager, performanceMonitorContext);
    this.crosstabColumnSequenceCounter = new LongSequence(10, -1);
View Full Code Here

    {
      throw new IllegalStateException();
    }
    state.setAdvanceHandler(BeginReportHandler.HANDLER);

    final ReportStateKey parentStateKey;
    final ReportState parentState = this.getParentSubReportState();
    if (parentState == null)
    {
      parentStateKey = null;
    }
View Full Code Here

  private ReportStateKey createKey()
  {
    final ProcessState parent = (ProcessState) getParentState();
    if (parent != null)
    {
      return new ReportStateKey(parent.createKey(),
          getCurrentRow(), getEventCode(),
          getCurrentGroupIndex(), getCurrentSubReport(),
          sequenceCounter, advanceHandler.isRestoreHandler(),
          isInlineProcess());
    }

    return new ReportStateKey(null, getCurrentRow(),
        getEventCode(), getCurrentGroupIndex(), getCurrentSubReport(),
        sequenceCounter, advanceHandler.isRestoreHandler(), false);
  }
View Full Code Here

      // First and last derive of a page must be a storage derivate - this clones everything and does
      // not rely on the more complicated transactional layouting ..
      ProcessState fallBackState = pagebreaksSupported ? state.deriveForPagebreak() : null;
      ProcessState globalState = pagebreaksSupported ? state.deriveForStorage() : null;

      ReportStateKey rollbackPageState = null;
      boolean isInRollBackMode = false;

      int eventCount = 0;
      int lastRow = -1;
      while (!state.isFinish())
      {
        int logPageCount = outputProcessor.getLogicalPageCount();
        int physPageCount = outputProcessor.getPhysicalPageCount();

        checkInterrupted();
        if (lastRow != state.getCurrentRow())
        {
          lastRow = state.getCurrentRow();
          if (eventCount == 0)
          {
            if (isPagebreaksSupported() && fallBackState != null)
            {
              repaginationState.reuse(ReportProgressEvent.PAGINATING, fallBackState, calculatePageCount(fallBackState));
            }
            else
            {
              repaginationState.reuse(ReportProgressEvent.PAGINATING, state, calculatePageCount(state));
            }
            fireStateUpdate(repaginationState);
            eventCount += 1;
          }
          else
          {
            if (eventCount == eventTrigger)
            {
              eventCount = 0;
            }
            else
            {
              eventCount += 1;
            }
          }
        }

        // Do not try to layout on a artificial state. Those states are not valid on
        // generating page events and cannot be trusted.
        ProcessState realFallbackState = fallBackState;
        final ProcessState restoreState;
        if (pagebreaksSupported && state.isArtifcialState() == false)
        {
          restoreState = fallBackState;
          if (isInRollBackMode == false)
          {
            if (pageEventCount >= AbstractReportProcessor.COMMIT_RATE)
            {
              final OutputFunction outputFunction = state.getLayoutProcess().getOutputFunction();
              if (outputFunction.createRollbackInformation())
              {
                realFallbackState = state.deriveForPagebreak();
                if (AbstractReportProcessor.SHOW_ROLLBACKS)
                {
                  logger.debug("Paginate: Try to generate new fallback state after commit count reached: " + state.getProcessKey());
                }
                validate(state);
              }
              else
              {
                realFallbackState = null;
              }
            }
          }
        }
        else
        {
          restoreState = null;
        }

        final ProcessState nextState = state.advance();
        state.setErrorHandler(IgnoreEverythingReportErrorHandler.INSTANCE);
        state = nextState;
        validate(state);

        final ReportStateKey nextStateKey = state.getProcessKey();

        if (errorHandler.isErrorOccured() == true)
        {
          final List childExceptions = Arrays.asList(errorHandler.getErrors());
          errorHandler.clearErrors();
          final ReportEventException exception =
              new ReportEventException("Failed to dispatch an event.", childExceptions);
          if (failOnError)
          {
            throw exception;
          }
          else
          {
            AbstractReportProcessor.logger.error("Failed to dispatch an event.", exception);
          }
        }

        if (state.isArtifcialState())
        {
          if (AbstractReportProcessor.SHOW_ROLLBACKS)
          {
            logger.debug("Paginate: Silent commit as we are in an artificial state: " + state.getProcessKey());
          }
          state = state.commit();
          if (AbstractReportProcessor.SHOW_ROLLBACKS)
          {
            logger.debug("Paginate: Post Silent commit as we are in an artificial state: " + state.getProcessKey());
          }
          continue;
        }

        final OutputFunction outputFunction = state.getLayoutProcess().getOutputFunction();
        if (outputFunction instanceof DefaultOutputFunction == false)
        {
          state = state.commit();
          if (state.isFinish() && pageStates.size() == 1)
          {
            physicalMapping.add(0);
            logicalMapping.add(0);
          }
          continue;
        }

        final DefaultOutputFunction lm = (DefaultOutputFunction) outputFunction;
        final Renderer renderer = lm.getRenderer();
        renderer.setStateKey(state.getProcessKey());
        pagebreakHandler.setReportState(state);

        boolean assertExpectPagebreak = false;
        if (isInRollBackMode)
        {
          if (nextStateKey.equals(rollbackPageState))
          {
            // reached the border case. We have to insert a manual pagebreak here or at least
            // we have to force the renderer to end the page right now.
            if (AbstractReportProcessor.SHOW_ROLLBACKS)
            {
              AbstractReportProcessor.logger.debug(
                  "Paginate: Found real pagebreak position. This might be the last state we process: " + rollbackPageState);
              AbstractReportProcessor.logger.debug(
                  "Paginate:   (Current state process key)           : " + state.getProcessKey());
              AbstractReportProcessor.logger.debug(
                  "Paginate:   (Handler)                             : " + state.getAdvanceHandler().getClass().getName());
            }
            assertExpectPagebreak = true;
            renderer.addPagebreak();
          }
        }

        final Renderer.LayoutResult pagebreakEncountered = renderer.validatePages();
        if (AbstractReportProcessor.SHOW_ROLLBACKS)
        {
          AbstractReportProcessor.logger.debug("Paginate: Validate Page returned " + pagebreakEncountered);
          if (assertExpectPagebreak == true && pagebreakEncountered != Renderer.LayoutResult.LAYOUT_PAGEBREAK)
          {
            AbstractReportProcessor.logger.debug("Paginate: Missed the pagebreak. This smells fishy!");
          }
        }

        if (pagebreakEncountered != Renderer.LayoutResult.LAYOUT_UNVALIDATABLE)
        {
          if (pagebreaksSupported && state.isArtifcialState() == false)
          {
            if (isInRollBackMode == false)
            {
              if (pageEventCount >= AbstractReportProcessor.COMMIT_RATE)
              {
                if (AbstractReportProcessor.SHOW_ROLLBACKS)
                {
                  logger.debug("Paginate: Try to apply new fallback state after commit count reached: " + state.getProcessKey());
                  logger.debug("Paginate:        : " + renderer.getLastStateKey());
                }

                fallBackState = realFallbackState;
                pageEventCount = 0;
              }
              else
              {
                if (AbstractReportProcessor.SHOW_ROLLBACKS)
                {
                  logger.debug("Paginate: Increase counter: " + state.getProcessKey());
                }
                pageEventCount += 1;
              }
            }
          }
        }
        else if (AbstractReportProcessor.SHOW_ROLLBACKS)
        {
          if (pagebreaksSupported && state.isArtifcialState() == false)
          {
            if (isInRollBackMode == false)
            {
              logger.debug("Paginate: SKIP : " + state.getProcessKey());
            }
          }
        }

        if (pagebreakEncountered == Renderer.LayoutResult.LAYOUT_PAGEBREAK)
        {
          final boolean onGoingPageBreak;

//          renderer.print();
          final ReportStateKey lastVisibleStateKey = renderer.getLastStateKey();
          if (isPagebreaksSupported() &&
              isInRollBackMode == false &&
              lastVisibleStateKey != null &&
              renderer.isOpen())
          {
            if (lastVisibleStateKey.equals(nextStateKey) == false &&
                lastVisibleStateKey.getSequenceCounter() > globalState.getProcessKey().getSequenceCounter())
            {
              // Roll back to the last known to be good position and process the states up to, but not
              // including the current state. This way, we can fire the page-events *before* this band
              // gets printed.
              rollbackPageState = lastVisibleStateKey;

              final ReportStateKey restoreStateProcessKey = restoreState.getProcessKey();
              if (AbstractReportProcessor.SHOW_ROLLBACKS)
              {
                AbstractReportProcessor.logger.debug(
                    "Paginate: Encountered bad break, need to roll-back: " + rollbackPageState);
                AbstractReportProcessor.logger.debug(
                    "Paginate:    Next StateKey                        : " + state.getProcessKey());
                AbstractReportProcessor.logger.debug(
                    "Paginate:    Restored Key                         : " + restoreStateProcessKey);
                AbstractReportProcessor.logger.debug(
                    "Paginate:    Position in event chain              : " + restoreState.getSequenceCounter());
              }
              if (lastVisibleStateKey.getSequenceCounter() < restoreStateProcessKey.getSequenceCounter())
              {
                if (AbstractReportProcessor.SHOW_ROLLBACKS)
                {
                  AbstractReportProcessor.logger.debug(
                      "Paginate: Fall back to start of page              : " + globalState.getProcessKey());
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.states.ReportStateKey

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.