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

Examples of org.pentaho.reporting.engine.classic.core.states.process.ProcessState


          }
        }
      }

      //progress = state.createStateProgress(progress);
      final ProcessState nextState = state.advance();
      state.setErrorHandler(IgnoreEverythingReportErrorHandler.INSTANCE);
      state = nextState.commit();

      if (errorHandler.isErrorOccured() == true)
      {
        final List childExceptions = Arrays.asList(errorHandler.getErrors());
        errorHandler.clearErrors();
View Full Code Here


    // every report processing starts with an StartState.
    final DefaultProcessingContext processingContext = createProcessingContext();
    final MasterReport report = getReport();
    final OutputFunction lm = createLayoutManager();

    final ProcessState startState = new ProcessState();
    try
    {
      startState.initializeForMasterReport
          (report, processingContext, new InitialLayoutProcess((OutputFunction) lm.getInstance()));
    }
    finally
    {
      activeDataFactory = startState.getProcessHandle();
    }
    ProcessState state = startState;
    final int maxRows = startState.getNumberOfRows();

    // the report processing can be split into 2 separate processes.
    // The first is the ReportPreparation; all function values are resolved and
    // a dummy run is done to calculate the final layout. This dummy run is
    // also necessary to resolve functions which use or depend on the PageCount.

    // the second process is the printing of the report, this is done in the
    // processReport() method.
    processingContext.setPrepareRun(true);

    // now process all function levels.
    // there is at least one level defined, as we added the PageLayouter
    // to the report.
    // the levels are defined from +inf to 0
    // we don't draw and we do not collect states in a StateList yet
    final int[] levels;
    if (state.isStructuralPreprocessingNeeded())
    {
      state = performStructuralPreprocessing(state, processingContext);
      levels = state.getRequiredRuntimeLevels();
    }
    else
    {
      levels = state.getRequiredRuntimeLevels();
    }

    if (levels.length == 0)
    {
      throw new IllegalStateException("Assertation Failed: No functions defined, invalid implementation.");
    }
    processingContext.setProgressLevelCount(levels.length);
    int index = 0;
    int level = levels[index];
    // outer loop: process all function levels
    boolean hasNext;
    do
    {
      processingContext.setProcessingLevel(level);
      processingContext.setProgressLevel(index);

      // if the current level is the output-level, then save the report state.
      // The state is used later to restart the report processing.
      if (level == LayoutProcess.LEVEL_PAGINATE)
      {
        if (isFullStreamingProcessor())
        {
          stateList = new FastPageStateList(this);
        }
        else
        {
          stateList = new DefaultPageStateList(this);
        }
        physicalMapping = new IntList(40);
        logicalMapping = new IntList(20);
        AbstractReportProcessor.logger.debug("Pagination started ..");
        state = processPaginationLevel(state, stateList, maxRows);
      }
      else
      {
        state = processPrepareLevels(state, maxRows);
      }

      // if there is an other level to process, then use the finish state to
      // create a new start state, which will continue the report processing on
      // the next higher level.
      hasNext = (index < (levels.length - 1));
      if (hasNext)
      {
        index += 1;
        level = levels[index];
        processingContext.setProcessingLevel(level);
        processingContext.setProgressLevel(index);
        if (state.isFinish())
        {
          state = state.restart();
          // this is a paranoid check ...
          if (state.getCurrentPage() != ReportState.BEFORE_FIRST_PAGE)
          {
            throw new IllegalStateException("State was not set up properly");
          }
        }
        else
View Full Code Here

  {
    processingContext.setProcessingLevel(Integer.MAX_VALUE);
    processingContext.setProgressLevel(-1);

    final int maxRows = startState.getNumberOfRows();
    ProcessState state = processPrepareLevels(startState, maxRows);
    if (state.isFinish())
    {
      state = state.restart();
      // this is a paranoid check ...
      if (state.getCurrentPage() != ReportState.BEFORE_FIRST_PAGE)
      {
        throw new IllegalStateException("State was not set up properly");
      }
    }
    else
View Full Code Here

    {
      final boolean failOnError = isStrictErrorHandling(getReport().getReportConfiguration());
      final ReportProcessingErrorHandler errorHandler = new CollectingReportErrorHandler();
      final DefaultLayoutPagebreakHandler pagebreakHandler = new DefaultLayoutPagebreakHandler();

      final ProcessState initialReportState = startState.deriveForStorage();
      final PageState initialPageState = new PageState(initialReportState, outputProcessor.getPageCursor());
      pageStates.add(initialPageState);

      final ReportProgressEvent repaginationState = new ReportProgressEvent(this);

      // inner loop: process the complete report, calculate the function values
      // for the current level. Higher level functions are not available in the
      // dataRow.
      final int eventTrigger;
      if (maxRows <= 0)
      {
        eventTrigger = Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT);
      }
      else
      {
        eventTrigger = Math.min(maxRows, Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT));
      }

      ProcessState state = startState.deriveForStorage();
      state.setErrorHandler(errorHandler);
      validate(state);

      int pageEventCount = 0;
      // 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 = state.deriveForPagebreak();
      ProcessState globalState = state.deriveForStorage();

      ReportStateKey rollbackPageState = null;
      boolean isInRollBackMode = false;
      final boolean pagebreaksSupported = isPagebreaksSupported();

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

        checkInterrupted();
        if (lastRow != state.getCurrentDataItem())
        {
          lastRow = state.getCurrentDataItem();
          if (eventCount == 0)
          {
            if (isPagebreaksSupported() && fallBackState != null)
            {
              repaginationState.reuse(ReportProgressEvent.PAGINATING,
                  fallBackState.getCurrentDataItem(), fallBackState.getNumberOfRows(), fallBackState.getCurrentPage(),
                  fallBackState.getProgressLevel(), fallBackState.getProgressLevelCount());
            }
            else
            {
              repaginationState.reuse(ReportProgressEvent.PAGINATING,
                  state.getCurrentDataItem(), state.getNumberOfRows(), state.getCurrentPage(),
                  state.getProgressLevel(), state.getProgressLevelCount());
            }
            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();
View Full Code Here

          "Process Page: Starting with : " + pageState.getReportState().getProcessKey());
    }

    try
    {
      final ProcessState startState = pageState.getReportState();
      outputProcessor.setPageCursor(pageState.getPageCursor());
      final int maxRows = startState.getNumberOfRows();
      final ReportProgressEvent repaginationState = new ReportProgressEvent(this);
      final DefaultLayoutPagebreakHandler pagebreakHandler = new DefaultLayoutPagebreakHandler();
      // inner loop: process the complete report, calculate the function values
      // for the current level. Higher level functions are not available in the
      // dataRow.
      final int eventTrigger;
      if (maxRows <= 0)
      {
        eventTrigger = Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT);
      }
      else
      {
        eventTrigger = Math.min(maxRows, Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT));
      }

      final boolean pagebreaksSupported = isPagebreaksSupported();

      ReportStateKey rollbackPageState = null;

      ProcessState state = startState.deriveForStorage();
      ProcessState fallBackState = state.deriveForPagebreak();
      final ProcessState globalState = state.deriveForStorage();
      state.setErrorHandler(errorHandler);

      boolean isInRollBackMode = false;
      int lastRow = -1;
      int eventCount = 0;
      int pageEventCount = 0;
      while (!state.isFinish())
      {
        checkInterrupted();
        if (lastRow != state.getCurrentDataItem())
        {
          lastRow = state.getCurrentDataItem();
          if (eventCount == 0)
          {
            repaginationState.reuse(ReportProgressEvent.GENERATING_CONTENT,
                state.getCurrentDataItem(), maxRows, state.getCurrentPage(),
                state.getProgressLevel(), state.getProgressLevelCount());
            fireStateUpdate(repaginationState);
            eventCount += 1;
          }
          else
          {
            if (eventCount == eventTrigger)
            {
              eventCount = 0;
            }
            else
            {
              eventCount += 1;
            }
          }
        }

        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())
              {
                if (AbstractReportProcessor.SHOW_ROLLBACKS)
                {
                  logger.debug("Print: Try to generate new fallback state after commit count reached: " + state.getProcessKey());
                }
                realFallbackState = state.deriveForPagebreak();
              }
              else
              {
                realFallbackState = null;
              }
            }
          }
        }
        else
        {
          restoreState = null;
        }

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

        final ReportStateKey nextStateKey = state.getProcessKey();
View Full Code Here

          }
        }
      }

      //progress = state.createStateProgress(progress);
      final ProcessState nextState = state.advance();
      state.setErrorHandler(IgnoreEverythingReportErrorHandler.INSTANCE);
      state = nextState.commit();

      if (errorHandler.isErrorOccured() == true)
      {
        final List childExceptions = Arrays.asList(errorHandler.getErrors());
        errorHandler.clearErrors();
View Full Code Here

      // every report processing starts with an StartState.
      final DefaultProcessingContext processingContext = createProcessingContext();
      final MasterReport report = getReport();
      final OutputFunction lm = createLayoutManager();

      final ProcessState startState = new ProcessState();
      try
      {
        startState.initializeForMasterReport
            (report, processingContext, (OutputFunction) lm.getInstance());
      }
      finally
      {
        activeDataFactory = startState.getProcessHandle();
      }
      ProcessState state = startState;
      final int maxRows = startState.getNumberOfRows();

      // the report processing can be split into 2 separate processes.
      // The first is the ReportPreparation; all function values are resolved and
      // a dummy run is done to calculate the final layout. This dummy run is
      // also necessary to resolve functions which use or depend on the PageCount.

      // the second process is the printing of the report, this is done in the
      // processReport() method.
      processingContext.setPrepareRun(true);

      // now process all function levels.
      // there is at least one level defined, as we added the PageLayouter
      // to the report.
      // the levels are defined from +inf to 0
      // we don't draw and we do not collect states in a StateList yet
      final int[] levels;
      int index;
      if (state.isStructuralPreprocessingNeeded())
      {
        state = performStructuralPreprocessing(state, processingContext);
        levels = state.getRequiredRuntimeLevels();
        index = 1;
      }
      else
      {
        levels = state.getRequiredRuntimeLevels();
        index = 0;
      }

      if (levels.length == 0)
      {
        throw new IllegalStateException("Assertation Failed: No functions defined, invalid implementation.");
      }
      final PerformanceLoggingStopWatch preDataSw =
                     getPerformanceMonitorContext().createStopWatch(PerformanceTags.REPORT_PREPARE_DATA);
      try
      {
        preDataSw.start();

        processingContext.setProgressLevelCount(levels.length);
        int level = levels[index];
        // outer loop: process all function levels
        boolean hasNext;
        do
        {
          processingContext.setProcessingLevel(level);
          processingContext.setProgressLevel(index);

          // if the current level is the output-level, then save the report state.
          // The state is used later to restart the report processing.
          if (level == LayoutProcess.LEVEL_PAGINATE)
          {
            if (isFullStreamingProcessor())
            {
              stateList = new FastPageStateList(this);
            }
            else
            {
              stateList = new DefaultPageStateList(this);
            }
            physicalMapping = new IntList(40);
            logicalMapping = new IntList(20);
            AbstractReportProcessor.logger.debug("Pagination started ..");
            state = processPaginationLevel(state, stateList, maxRows);
          }
          else
          {
            preDataSw.start();
            state = processPrepareLevels(state, maxRows);
            preDataSw.stop(true);
          }

          // if there is an other level to process, then use the finish state to
          // create a new start state, which will continue the report processing on
          // the next higher level.
          hasNext = (index < (levels.length - 1));
          if (hasNext)
          {
            index += 1;
            level = levels[index];
            processingContext.setProcessingLevel(level);
            processingContext.setProgressLevel(index);
            if (state.isFinish())
            {
              state = state.restart();
            }
            else
            {
              throw new IllegalStateException(
                  "Repaginate did not produce an finish state");
View Full Code Here

      sw.start();
      processingContext.setProcessingLevel(LayoutProcess.LEVEL_STRUCTURAL_PREPROCESSING);
      processingContext.setProgressLevel(-1);

      final int maxRows = startState.getNumberOfRows();
      ProcessState state = processPrepareLevels(startState, maxRows);
      if (state.isFinish())
      {
        state = state.restart();
      }
      else
      {
        throw new IllegalStateException("Repaginate did not produce an finish state");
      }
View Full Code Here

      sw.start();
      final boolean failOnError = isStrictErrorHandling(getReport().getReportConfiguration());
      final ReportProcessingErrorHandler errorHandler = new CollectingReportErrorHandler();
      final DefaultLayoutPagebreakHandler pagebreakHandler = new DefaultLayoutPagebreakHandler();

      final ProcessState initialReportState = startState.deriveForStorage();
      final PageState initialPageState = new PageState(initialReportState, outputProcessor.getPageCursor());
      pageStates.add(initialPageState);

      final ReportProgressEvent repaginationState = new ReportProgressEvent(this);

      // inner loop: process the complete report, calculate the function values
      // for the current level. Higher level functions are not available in the
      // dataRow.
      final int eventTrigger;
      if (maxRows <= 0)
      {
        eventTrigger = Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT);
      }
      else
      {
        eventTrigger = Math.min(maxRows, Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT));
      }

      ProcessState state = startState.deriveForStorage();
      state.setErrorHandler(errorHandler);
      validate(state);

      final OutputProcessorMetaData metaData =
          state.getFlowController().getReportContext().getOutputProcessorMetaData();
      pagebreaksSupported = metaData.isFeatureSupported(OutputProcessorFeature.PAGEBREAKS);

      int pageEventCount = 0;
      // 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();
View Full Code Here

          "Process Page: Starting with : " + pageState.getReportState().getProcessKey());
    }

    try
    {
      final ProcessState startState = pageState.getReportState();
      outputProcessor.setPageCursor(pageState.getPageCursor());
      final int maxRows = startState.getNumberOfRows();
      final ReportProgressEvent repaginationState = new ReportProgressEvent(this);
      final DefaultLayoutPagebreakHandler pagebreakHandler = new DefaultLayoutPagebreakHandler();
      // inner loop: process the complete report, calculate the function values
      // for the current level. Higher level functions are not available in the
      // dataRow.
      final int eventTrigger;
      if (maxRows <= 0)
      {
        eventTrigger = Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT);
      }
      else
      {
        eventTrigger = Math.min(maxRows, Math.max(maxRows / MAX_EVENTS_PER_RUN, MIN_ROWS_PER_EVENT));
      }

      final boolean pagebreaksSupported = isPagebreaksSupported();

      ReportStateKey rollbackPageState = null;

      ProcessState state = startState.deriveForStorage();
      ProcessState fallBackState = pagebreaksSupported ? state.deriveForPagebreak() : null;
      final ProcessState globalState = pagebreaksSupported ? state.deriveForStorage() : null;
      state.setErrorHandler(errorHandler);

      boolean isInRollBackMode = false;
      int lastRow = -1;
      int eventCount = 0;
      int pageEventCount = 0;
      while (!state.isFinish())
      {
        checkInterrupted();
        if (lastRow != state.getCurrentRow())
        {
          lastRow = state.getCurrentRow();
          if (eventCount == 0)
          {
            repaginationState.reuse(ReportProgressEvent.GENERATING_CONTENT, state, calculatePageCount(state));
            fireStateUpdate(repaginationState);
            eventCount += 1;
          }
          else
          {
            if (eventCount == eventTrigger)
            {
              eventCount = 0;
            }
            else
            {
              eventCount += 1;
            }
          }
        }

        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())
              {
                if (AbstractReportProcessor.SHOW_ROLLBACKS)
                {
                  logger.debug("Print: Try to generate new fallback state after commit count reached: " + state.getProcessKey());
                }
                realFallbackState = state.deriveForPagebreak();
              }
              else
              {
                realFallbackState = null;
              }
            }
          }
        }
        else
        {
          restoreState = null;
        }

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

        final ReportStateKey nextStateKey = state.getProcessKey();
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.states.process.ProcessState

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.