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

Examples of org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController


  public ProcessState commit(final ProcessState next) throws ReportProcessingException
  {
    final Group group = next.getReport().getGroup(next.getCurrentGroupIndex());

    next.advanceCursor();
    final DefaultFlowController fc = next.getFlowController().performAdvance();
    final DefaultFlowController cfc = fc.performCommit();
    if (ProcessState.isLastItemInGroup(group, fc.getMasterRow(), cfc.getMasterRow()))
    {
      next.setFlowController(fc);
      next.setAdvanceHandler(EndDetailsHandler.HANDLER);
    }
    else
View Full Code Here


    next.setInItemGroup(true);

    // fast forward to the end of the facts ..
    while (true)
    {
      final DefaultFlowController fc = next.getFlowController().performAdvance();
      final Group group = next.getReport().getGroup(next.getCurrentGroupIndex());
      final DefaultFlowController cfc = fc.performCommit();
      if (ProcessState.isLastItemInGroup(group, fc.getMasterRow(), cfc.getMasterRow()))
      {
        next.setFlowController(fc);
        next.setAdvanceHandler(PrintSummaryEndCrosstabColumnAxisHandler.HANDLER);
        break;
      }
View Full Code Here

  }

  public ProcessState commit(final ProcessState next) throws ReportProcessingException
  {
    next.leaveGroup();
    final DefaultFlowController fc = next.getFlowController();
    final boolean advanceRequested = fc.isAdvanceRequested();
    final boolean advanceable = fc.getMasterRow().isAdvanceable();
    if (isRootGroup(next))
    {
      // there is no parent group. So if there is more data, print the next header for this group,
      // else print the report-footer and finish the report processing.
      if (advanceRequested && advanceable)
      {
        final DefaultFlowController cfc = fc.performCommit();
        next.setFlowController(cfc);
        next.setAdvanceHandler(BeginGroupHandler.HANDLER);
        return next;
      }
      else
      {
        next.setAdvanceHandler(ReportFooterHandler.HANDLER);
        return next;
      }
    }

    if (advanceRequested == false || advanceable == false)
    {
      // This happens for empty - reports. Empty-Reports are never advanceable, therefore we can
      // reach an non-advance state where inner group-footers are printed.
      next.setAdvanceHandler(EndGroupBodyHandler.HANDLER);
      return next;
    }

    // This group is not the outer-most group ..
    final Group group = next.getReport().getGroup(next.getCurrentGroupIndex());
    final DefaultFlowController cfc = fc.performCommit();
    if (ProcessState.isLastItemInGroup(group, fc.getMasterRow(), cfc.getMasterRow()))
    {
      // continue with an other EndGroup-State ...
      next.setAdvanceHandler(EndGroupBodyHandler.HANDLER);
      return next;
    }
View Full Code Here

    this.processHandle = new InternalProcessHandle(dataFactoryManager, performanceMonitorContext);
    this.crosstabColumnSequenceCounter = new LongSequence(10, -1);
    this.groupSequenceCounter = new LongSequence(10, -1);
    this.groupSequenceCounter.set(0, -1);

    final DefaultFlowController startFlowController =
        new DefaultFlowController(processingContext, report.getDataSchemaDefinition(),
            StateUtilities.computeParameterValueSet(report, parameterValues), performanceMonitorContext);

    final MasterReportProcessPreprocessor processPreprocessor = new MasterReportProcessPreprocessor(startFlowController);
    final MasterReport processedReport = processPreprocessor.invokePreDataProcessing(report);
    final DefaultFlowController flowController = processPreprocessor.getFlowController();

    final Object dataCacheEnabledRaw =
        processedReport.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.DATA_CACHE);
    final boolean dataCacheEnabled = designtime == false && Boolean.FALSE.equals(dataCacheEnabledRaw) == false;

    final DataFactory sortingDataFactory =
        new SortingDataFactory(lookupDataFactory(processedReport), performanceMonitorContext);
    final CachingDataFactory dataFactory = new CachingDataFactory(sortingDataFactory, dataCacheEnabled);
    dataFactory.initialize(new ProcessingDataFactoryContext(processingContext, dataFactory));

    final FunctionStorageKey functionStorageKey = FunctionStorageKey.createKey(null, processedReport);
    this.dataFactoryManager.store(functionStorageKey, dataFactory, true);
    // eval query, query-limit and query-timeout
    this.flowController = flowController;
    final Integer queryLimitDefault = IntegerCache.getInteger(processedReport.getQueryLimit());
    final Integer queryTimeoutDefault = IntegerCache.getInteger(processedReport.getQueryTimeout());

    final String queryDefined = designtime ? "design-time-query" : processedReport.getQuery();
    final Object queryRaw = evaluateExpression(processedReport.getAttributeExpression(AttributeNames.Internal.NAMESPACE,
        AttributeNames.Internal.QUERY), queryDefined);
    final Object queryLimitRaw = evaluateExpression(processedReport.getAttributeExpression(AttributeNames.Internal.NAMESPACE,
        AttributeNames.Internal.QUERY_LIMIT), queryLimitDefault);
    final Object queryTimeoutRaw = evaluateExpression(processedReport.getAttributeExpression(AttributeNames.Internal.NAMESPACE,
        AttributeNames.Internal.QUERY_TIMEOUT), queryTimeoutDefault);
    final List<SortConstraint> sortOrder = lookupSortOrder(processedReport);

    this.query = (String) ConverterRegistry.convert(queryRaw, String.class, processedReport.getQuery());
    this.queryLimit = (Integer) ConverterRegistry.convert(queryLimitRaw, Integer.class, queryLimitDefault);
    this.queryTimeout = (Integer) ConverterRegistry.convert(queryTimeoutRaw, Integer.class, queryTimeoutDefault);

    DefaultFlowController postQueryFlowController = flowController.performQuery
        (dataFactory, query, queryLimit.intValue(), queryTimeout.intValue(),
            processingContext.getResourceBundleFactory(), sortOrder);

    final MasterReportProcessPreprocessor postProcessor = new MasterReportProcessPreprocessor(postQueryFlowController);
    final MasterReport fullReport = postProcessor.invokePreProcessing(processedReport);
    postQueryFlowController = postProcessor.getFlowController();

    if (isStructureRunNeeded(processedReport) == false)
    {
      // Perform a static analysis on whether there is an External-element or Inline-Subreports or Crosstabs
      // if none, return unchanged
      this.structuralPreprocessingNeeded = false;
    }
    else
    {
      // otherwise process the report one time to walk through all eligible states. Record all subreports,
      // and then compute the runlevels based on what we have in the caches.
      this.structuralPreprocessingNeeded = true;
      this.processLevels.add(LayoutProcess.LEVEL_STRUCTURAL_PREPROCESSING);
      postQueryFlowController.requireStructuralProcessing();
    }

    final Expression[] expressions;
    if (designtime)
    {
      expressions = new Expression[0];
    }
    else
    {
      expressions = fullReport.getExpressions().getExpressions();
    }

    this.flowController = postQueryFlowController.activateExpressions(expressions, false);
    this.report = new ReportDefinitionImpl(fullReport, fullReport.getPageDefinition());
    this.layoutProcess = new SubLayoutProcess(layoutProcess,
        computeStructureFunctions(fullReport.getStructureFunctions(),
            getFlowController().getReportContext().getOutputProcessorMetaData()), fullReport.getObjectID());
View Full Code Here

      initialSubReport = subreportFromMarker.derive(true);
      initialSubReport.reconnectParent(subreportFromMarker.getParentSection());
      needPreProcessing = true;
    }

    final DefaultFlowController parentStateFlowController = parentState.getFlowController();
    final ResourceBundleFactory resourceBundleFactory = parentState.getResourceBundleFactory();

    if (isSubReportInvisible(initialSubReport, parentStateFlowController))
    {
      // make it a minimum effort report, but still enter the loop.
      final ReportDefinition parentReport = parentState.getReport();
      final SubReport dummyReport = new SubReport(functionStorageKey.getReportId());
      this.report = new ReportDefinitionImpl(dummyReport, parentReport.getPageDefinition(), subreportFromMarker.getParentSection());
      this.flowController = parentStateFlowController.derive();
      this.advanceHandler = EndSubReportHandler.HANDLER;
      this.layoutProcess = new SubLayoutProcess
          (parentState.layoutProcess, computeStructureFunctions(initialSubReport.getStructureFunctions(),
              flowController.getReportContext().getOutputProcessorMetaData()), this.report.getObjectID());
    }
    else
    {
      DataFactory dataFactory = dataFactoryManager.restore(functionStorageKey, isReportsShareConnections(initialSubReport));

      final DefaultFlowController postPreProcessingFlowController;
      final SubReport preDataSubReport;
      if (dataFactory == null)
      {
        final SubReportProcessPreprocessor preprocessor = new SubReportProcessPreprocessor(parentStateFlowController);
        preDataSubReport = preprocessor.invokePreDataProcessing(initialSubReport);
        postPreProcessingFlowController = preprocessor.getFlowController();

        final DataFactory subreportDf = lookupDataFactory(preDataSubReport);
        final boolean dataCacheEnabled = isCacheEnabled(preDataSubReport);
        if (subreportDf == null)
        {
          // subreport does not define a own factory, we reuse the parent's data-factory in the master-row.
          dataFactory = new EmptyDataFactory();
        }
        else
        {
          // subreport comes with an own factory, so open the gates ..
          final DataFactory sortingDataFactory = new SortingDataFactory(subreportDf, performanceMonitorContext);
          final CachingDataFactory cdataFactory = new CachingDataFactory(sortingDataFactory, dataCacheEnabled);
          final ProcessingContext context = postPreProcessingFlowController.getReportContext();
          cdataFactory.initialize(new ProcessingDataFactoryContext(context, cdataFactory));
          dataFactoryManager.store(functionStorageKey, cdataFactory, isReportsShareConnections(preDataSubReport));
          dataFactory = cdataFactory;
        }
      }
      else
      {
        preDataSubReport = initialSubReport;
        postPreProcessingFlowController = parentStateFlowController;
      }

      // And now initialize the sub-report.
      final ParameterMapping[] inputMappings = preDataSubReport.getInputMappings();
      final ParameterMapping[] exportMappings = preDataSubReport.getExportMappings();

      // eval query, query-limit and query-timeout
      this.flowController = postPreProcessingFlowController.performInitSubreport
          (dataFactory, inputMappings, resourceBundleFactory);
      final Integer queryLimitDefault = IntegerCache.getInteger(preDataSubReport.getQueryLimit());
      final Integer queryTimeoutDefault = IntegerCache.getInteger(preDataSubReport.getQueryTimeout());

      final Object queryRaw = evaluateExpression(preDataSubReport.getAttributeExpression(AttributeNames.Internal.NAMESPACE,
          AttributeNames.Internal.QUERY), preDataSubReport.getQuery());
      final Object queryLimitRaw = evaluateExpression(preDataSubReport.getAttributeExpression(AttributeNames.Internal.NAMESPACE,
          AttributeNames.Internal.QUERY_LIMIT), queryLimitDefault);
      final Object queryTimeoutRaw = evaluateExpression(preDataSubReport.getAttributeExpression(AttributeNames.Internal.NAMESPACE,
          AttributeNames.Internal.QUERY_TIMEOUT), queryTimeoutDefault);
      final String queryDefined = designtime ? "design-time-query" : preDataSubReport.getQuery();
      this.query = (String) ConverterRegistry.convert(queryRaw, String.class, queryDefined);
      this.queryLimit = (Integer) ConverterRegistry.convert(queryLimitRaw, Integer.class, queryLimitDefault);
      this.queryTimeout = (Integer) ConverterRegistry.convert(queryTimeoutRaw, Integer.class, queryTimeoutDefault);
      final List<SortConstraint> sortOrder = lookupSortOrder(preDataSubReport);


      DefaultFlowController postQueryFlowController = flowController.performSubReportQuery
          (query, queryLimit.intValue(), queryTimeout.intValue(), exportMappings, sortOrder);
      final ProxyDataSchemaDefinition schemaDefinition =
          new ProxyDataSchemaDefinition(preDataSubReport.getDataSchemaDefinition(),
              postQueryFlowController.getMasterRow().getDataSchemaDefinition());
      postQueryFlowController = postQueryFlowController.updateDataSchema(schemaDefinition);

      SubReport fullReport = preDataSubReport;
      DefaultFlowController fullFlowController = postQueryFlowController;
      if (needPreProcessing)
      {
        final SubReportProcessPreprocessor preprocessor = new SubReportProcessPreprocessor(postQueryFlowController);
        fullReport = preprocessor.invokePreProcessing(preDataSubReport);
        fullFlowController = preprocessor.getFlowController();
        subReportStorage.store(functionStorageKey, fullReport);
      }

      this.report = new ReportDefinitionImpl(fullReport, fullReport.getPageDefinition(), subreportFromMarker.getParentSection());


      final Expression[] structureFunctions = getStructureFunctionStorage().restore(functionStorageKey);
      if (structureFunctions != null)
      {
        final StructureFunction[] functions = new StructureFunction[structureFunctions.length];
        //noinspection SuspiciousSystemArraycopy
        System.arraycopy(structureFunctions, 0, functions, 0, structureFunctions.length);
        this.layoutProcess = new SubLayoutProcess(parentState.layoutProcess, functions, this.report.getObjectID());
      }
      else
      {
        final StructureFunction[] functions = computeStructureFunctions(fullReport.getStructureFunctions(),
            fullFlowController.getReportContext().getOutputProcessorMetaData());
        this.layoutProcess = new SubLayoutProcess(parentState.layoutProcess, functions, this.report.getObjectID());
      }

      boolean preserve = true;
      Expression[] expressions = getFunctionStorage().restore(functionStorageKey);
      if (expressions == null)
      {
        // ok, it seems we have entered a new subreport ..
        // we use the expressions from the report itself ..
        if (designtime)
        {
          expressions = new Expression[0];
        }
        else
        {
          expressions = fullReport.getExpressions().getExpressions();
        }
        preserve = false;
      }

      this.flowController = fullFlowController.activateExpressions(expressions, preserve);
      this.flowController = this.flowController.refreshDataRow();

      // now a bunch of paranoid assertions, just in case I missed something.
      if (this.report.getParentSection() == null)
      {
View Full Code Here

    if (dataFactory == null)
    {
      throw new ReportProcessingException("No data factory on restart()? Somewhere we went wrong.");
    }

    final DefaultFlowController fc = state.getFlowController();
    final DefaultFlowController cfc = fc.restart();
    final DefaultFlowController qfc = cfc.performQuery
        (dataFactory, query, queryLimit.intValue(), queryTimeout.intValue(), fc.getMasterRow().getResourceBundleFactory());
    final Expression[] expressions = getFunctionStorage().restore
        (FunctionStorageKey.createKey(null, state.getReport()));
    final DefaultFlowController efc = qfc.activateExpressions(expressions, true);
    state.setFlowController(efc);
    state.sequenceCounter += 1;
    state.processKey = state.createKey();
    return state;
  }
View Full Code Here

  }

  public ProcessState commit(final ProcessState next) throws ReportProcessingException
  {
    next.leaveGroup();
    final DefaultFlowController fc = next.getFlowController();
    final boolean advanceRequested = fc.isAdvanceRequested();
    final boolean advanceable = fc.getMasterRow().isAdvanceable();
    if (isRootGroup(next))
    {
      throw new ReportProcessingException("This report is invalid. A CR-Row-Group cannot be a root group.");
    }

    final Group parentGroup = next.getReport().getGroup(next.getCurrentGroupIndex());
    if (advanceRequested == false || advanceable == false)
    {
      // This happens for empty - reports. Empty-Reports are never advanceable, therefore we can
      // reach an non-advance state where inner group-footers are printed.
      if (parentGroup instanceof CrosstabRowGroup)
      {
        next.setPostSummaryRowAdvanceHandler(EndCrosstabRowBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabGroup)
      {
        next.setPostSummaryRowAdvanceHandler(EndCrosstabBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabOtherGroup)
      {
        next.setPostSummaryRowAdvanceHandler(EndCrosstabOtherBodyHandler.HANDLER);
      }
      else
      {
        throw new ReportProcessingException("This report is invalid.");
      }
      next.setAdvanceHandler(PrintSummaryRowStartReportHandler.HANDLER);
      return next;
    }

    // This group is not the outer-most group ..
    final DefaultFlowController cfc = fc.performCommit();
    if (ProcessState.isLastItemInGroup(parentGroup, fc.getMasterRow(), cfc.getMasterRow()))
    {
      // print summary group ..

      // continue with an other EndGroup-State ...
      if (parentGroup instanceof CrosstabRowGroup)
      {
        next.setPostSummaryRowAdvanceHandler(EndCrosstabRowBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabGroup)
      {
        next.setPostSummaryRowAdvanceHandler(EndCrosstabBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabOtherGroup)
      {
        next.setPostSummaryRowAdvanceHandler(EndCrosstabOtherBodyHandler.HANDLER);
      }
      else
      {
        throw new ReportProcessingException("This report is invalid.");
      }
      next.setAdvanceHandler(PrintSummaryRowStartReportHandler.HANDLER);
      return next;
    }
    else
    {
      // The parent group is not finished, so finalize the createRollbackInformation.
      // more data in parent group, print the next header
      final DefaultFlowController rfc = cfc.resetRowCursor();
      next.setFlowController(rfc);
      next.setAdvanceHandler(BeginCrosstabRowAxisHandler.HANDLER);
      return next;
    }
  }
View Full Code Here

    return state.deriveForAdvance();
  }

  public ProcessState commit(final ProcessState next) throws ReportProcessingException
  {
    final DefaultFlowController fc = next.getFlowController().performAdvance();
    final Group group = next.getReport().getGroup(next.getCurrentGroupIndex());
    final DefaultFlowController cfc = fc.performCommit();
    if (ProcessState.isLastItemInGroup(group, fc.getMasterRow(), cfc.getMasterRow()))
    {
      next.setFlowController(fc);
      next.setAdvanceHandler(EndCrosstabFactHandler.HANDLER);
    }
    else
View Full Code Here

  }

  public ProcessState commit(final ProcessState next) throws ReportProcessingException
  {
    next.leaveGroup();
    final DefaultFlowController fc = next.getFlowController();
    final boolean advanceRequested = fc.isAdvanceRequested();
    final boolean advanceable = fc.getMasterRow().isAdvanceable();
    if (isRootGroup(next))
    {
      throw new ReportProcessingException("This report is invalid. A CR-Col-Group cannot be a root group.");
    }

    final Group parentGroup = next.getReport().getGroup(next.getCurrentGroupIndex());
    if (advanceRequested == false || advanceable == false)
    {
      // This happens for empty - reports. Empty-Reports are never advanceable, therefore we can
      // reach an non-advance state where inner group-footers are printed.
      if (parentGroup instanceof CrosstabRowGroup)
      {
        next.setAdvanceHandler(EndCrosstabRowBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabColumnGroup)
      {
        next.setAdvanceHandler(EndCrosstabColumnBodyHandler.HANDLER);
      }
      else
      {
        throw new ReportProcessingException("This report is invalid.");
      }
      return next;
    }

    // This group is not the outer-most group ..
    final DefaultFlowController cfc = fc.performCommit();
    if (ProcessState.isLastItemInGroup(parentGroup, fc.getMasterRow(), cfc.getMasterRow()))
    {
      // continue with an other EndGroup-State ...
      if (parentGroup instanceof CrosstabRowGroup)
      {
        next.setAdvanceHandler(EndCrosstabRowBodyHandler.HANDLER);
View Full Code Here

  }

  public ProcessState commit(final ProcessState next) throws ReportProcessingException
  {
    next.leaveGroup();
    final DefaultFlowController fc = next.getFlowController();
    final boolean advanceRequested = fc.isAdvanceRequested();
    final boolean advanceable = fc.getMasterRow().isAdvanceable();
    if (isRootGroup(next))
    {
      throw new ReportProcessingException("This report is invalid. A CR-Other-Group cannot be a root group.");
    }

    final Group parentGroup = next.getReport().getGroup(next.getCurrentGroupIndex());
    if (advanceRequested == false || advanceable == false)
    {
      // This happens for empty - reports. Empty-Reports are never advanceable, therefore we can
      // reach an non-advance state where inner group-footers are printed.
      if (parentGroup instanceof CrosstabGroup)
      {
        next.setAdvanceHandler(EndCrosstabBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabOtherGroup)
      {
        next.setAdvanceHandler(EndCrosstabOtherBodyHandler.HANDLER);
      }
      else
      {
        throw new ReportProcessingException("This report is invalid.");
      }
      return next;
    }

    // This group is not the outer-most group ..
    final DefaultFlowController cfc = fc.performCommit();
    if (ProcessState.isLastItemInGroup(parentGroup, fc.getMasterRow(), cfc.getMasterRow()))
    {
      // continue with an other EndGroup-State ...
      if (parentGroup instanceof CrosstabGroup)
      {
        next.setAdvanceHandler(EndCrosstabBodyHandler.HANDLER);
      }
      else if (parentGroup instanceof CrosstabOtherGroup)
      {
        next.setAdvanceHandler(EndCrosstabOtherBodyHandler.HANDLER);
      }
      else
      {
        throw new ReportProcessingException("This report is invalid.");
      }
      return next;
    }
    else
    {
      // The parent group is not finished, so finalize the createRollbackInformation.
      // more data in parent group, print the next header
      final DefaultFlowController rfc = cfc.resetRowCursor();
      next.setFlowController(rfc);
      next.setAdvanceHandler(BeginCrosstabOtherAxisHandler.HANDLER);
      return next;
    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController

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.