Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#getCompatibilityLevel()

The following examples show how to use org.pentaho.reporting.engine.classic.core.MasterReport#getCompatibilityLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompatibilityUpdater.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void performUpdate( final SubReport report ) {
  final ReportDefinition reportDefinition = report.getMasterReport();
  if ( reportDefinition == null ) {
    return;
  }

  final MasterReport masterReport = (MasterReport) reportDefinition;
  final Integer versionRaw = masterReport.getCompatibilityLevel();
  if ( versionRaw == null ) {
    version = -1;
  } else {
    version = versionRaw.intValue();
  }
  if ( version == -1 ) {
    return;
  }
  performUpdateInternal( report );
}
 
Example 2
Source File: AbstractReportProcessor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected DefaultProcessingContext createProcessingContext() throws ReportProcessingException {
  final OutputProcessorMetaData metaData = getOutputProcessorMetaData();
  final MasterReport report = getReport();
  final DocumentMetaData documentMetaData;
  final DocumentBundle bundle = report.getBundle();
  if ( bundle != null ) {
    documentMetaData = bundle.getMetaData();
  } else {
    documentMetaData = new MemoryDocumentMetaData();
  }
  final Integer compatibilityLevel = report.getCompatibilityLevel();
  final int cLevel;
  if ( compatibilityLevel == null ) {
    cLevel = -1;
  } else {
    cLevel = compatibilityLevel;
  }
  return new DefaultProcessingContext( metaData, report.getResourceBundleFactory(), report.getConfiguration(), report
      .getResourceManager(), report.getContentBase(), documentMetaData, report.getReportEnvironment(), cLevel );
}
 
Example 3
Source File: DebugReportRunner.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Configuration wrapForCompatibility( final MasterReport processingContext ) {
  final Integer compatibilityLevel = processingContext.getCompatibilityLevel();
  if ( compatibilityLevel == null || compatibilityLevel < 0 ) {
    return processingContext.getConfiguration();
  }

  if ( compatibilityLevel < ClassicEngineBoot.computeVersionId( 3, 999, 999 ) ) {
    // enable strict compatibility mode for reports older than 4.0.
    final HierarchicalConfiguration config = new HierarchicalConfiguration( processingContext.getConfiguration() );
    config.setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.WrapProgressMarkerInSection", "true" );
    config.setConfigProperty( "org.pentaho.reporting.engine.classic.core.legacy.StrictCompatibility", "true" );
    return config;
  }

  // this is a trunk or 4.0 or newer report.
  return processingContext.getConfiguration();
}
 
Example 4
Source File: ReportMigrationInspection.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void inspect( final ReportDesignerContext designerContext,
                     final ReportDocumentContext reportRenderContext,
                     final InspectionResultListener resultHandler ) throws ReportDataFactoryException {
  final MasterReport masterReportElement = reportRenderContext.getContextRoot();
  final Integer compatibilityLevel = masterReportElement.getCompatibilityLevel();
  if ( compatibilityLevel == null ||
    compatibilityLevel == ClassicEngineBoot.VERSION_TRUNK ) {
    // no need to test any compatibility, as this report is a TRUNK report.
    return;
  }

  if ( compatibilityLevel == ClassicEngineBoot.computeCurrentVersionId() ) {
    // this report is the same level as the current version of the engine. No need to check anything.
    return;
  }

  this.compatibilityLevel = compatibilityLevel;
  this.compatibilityText = ClassicEngineBoot.printVersion( compatibilityLevel );
  super.inspect( designerContext, reportRenderContext, resultHandler );
}
 
Example 5
Source File: MigrationDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void performMigration( final ReportDesignerContext designerContext,
                              final ReportDocumentContext reportRenderContext ) {
  this.reportRenderContext = reportRenderContext;

  toVersion = ClassicEngineBoot.computeCurrentVersionId();

  final MasterReport masterReportElement = this.reportRenderContext.getContextRoot();
  final Integer compatibilityLevel = masterReportElement.getCompatibilityLevel();
  if ( compatibilityLevel == null ) {
    fromVersion = toVersion;
  } else {
    fromVersion = compatibilityLevel;
  }

  setupFromReportVersion();
  if ( super.performEdit() == false ) {
    return;
  }

  if ( ( new SaveReportAction() ).saveReport( designerContext, reportRenderContext, this ) == false ) {
    return;
  }

  final CompatibilityUpdater updater = new CompatibilityUpdater();
  updater.performUpdate( reportRenderContext.getContextRoot() );
}
 
Example 6
Source File: BundleMetaFileWriter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeVersionMarker( final WriteableDocumentMetaData writeableMetaData, final MasterReport masterReport ) {
  final int releaseMajor = ParserUtil.parseInt( ClassicEngineInfo.getInstance().getReleaseMajor(), -1 );
  final int releaseMinor = ParserUtil.parseInt( ClassicEngineInfo.getInstance().getReleaseMinor(), -1 );
  final int releasePatch = ParserUtil.parseInt( ClassicEngineInfo.getInstance().getReleaseMilestone(), -1 );
  int versionId = ClassicEngineBoot.computeVersionId( releaseMajor, releaseMinor, releasePatch );
  if ( versionId > 0 && ClassicEngineBoot.VERSION_TRUNK != versionId ) {
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.major",
        releaseMajor );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.minor",
        releaseMinor );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.patch",
        releasePatch );
  } else {
    final Configuration configuration = masterReport.getConfiguration();
    if ( "true"
        .equals( configuration
            .getConfigProperty( "org.pentaho.reporting.engine.classic.core.designtime.PreserveOriginalCompatibilitySettingInTrunk" ) ) ) {
      final Integer reportCompatibility = masterReport.getCompatibilityLevel();
      if ( reportCompatibility != null && reportCompatibility > 0 ) {
        final int patch = reportCompatibility % 1000;
        final int minor = ( reportCompatibility / 1000 ) % 1000;
        final int major = ( reportCompatibility / 1000000 );
        writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.major", major );
        writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.minor", minor );
        writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.patch", patch );
        return;
      }
    }
    // trunk is just the strongest player in town
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.major", 999 );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.minor", 999 );
    writeableMetaData.setBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "prpt-spec.version.patch", 999 );
  }
}
 
Example 7
Source File: LegacyUpdateStructureVisitor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void performUpdate( final MasterReport report ) {
  version = report.getCompatibilityLevel();
  if ( version == -1 ) {
    return;
  }
  super.inspect( report );
}
 
Example 8
Source File: LegacyUpdateStructureVisitor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void performUpdate( final SubReport report ) {
  final ReportDefinition reportDefinition = report.getMasterReport();
  if ( reportDefinition == null ) {
    return;
  }

  final MasterReport masterReport = (MasterReport) reportDefinition;
  version = masterReport.getCompatibilityLevel();
  if ( version == -1 ) {
    return;
  }
  super.inspect( report );
}
 
Example 9
Source File: CompatibilityUpdater.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void performUpdate( final MasterReport report ) {
  final Integer versionRaw = report.getCompatibilityLevel();
  if ( versionRaw == null ) {
    version = -1;
  } else {
    version = versionRaw.intValue();
  }
  if ( version == -1 ) {
    return;
  }
  performUpdateInternal( report );
  report.setCompatibilityLevel( null );
}
 
Example 10
Source File: DefaultProcessingContext.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public DefaultProcessingContext( final MasterReport report, final OutputProcessorMetaData metaData )
  throws ReportProcessingException {
  this( metaData, report.getResourceBundleFactory(), report.getConfiguration(), report.getResourceManager(), report
      .getContentBase(), report.getBundle().getMetaData(), report.getReportEnvironment(), -1 );

  final Integer comLev = report.getCompatibilityLevel();
  if ( comLev != null ) {
    compatibilityLevel = comLev;
  }
}
 
Example 11
Source File: MigrateReportAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void updateCompatibilityLevel( final MasterReport reportDefinition ) {
  final Integer compatibilityLevel = reportDefinition.getCompatibilityLevel();
  if ( compatibilityLevel == null ) {
    setEnabled( false );
    return;
  }
  if ( compatibilityLevel <= 0 ) {
    setEnabled( false );
    return;
  }

  setEnabled( compatibilityLevel < ClassicEngineBoot.computeCurrentVersionId() );
}
 
Example 12
Source File: MigrateReportTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void run() {
  final MasterReport masterReportElement = reportContext.getContextRoot();
  final Integer compatibilityLevel = masterReportElement.getCompatibilityLevel();
  if ( compatibilityLevel == null ) {
    return;
  }
  if ( compatibilityLevel.intValue() > minimumVersionNeeded ) {
    // already done.
    return;
  }

  final Window window = LibSwingUtil.getWindowAncestor( designerContext.getView().getParent() );
  final MigrateConfirmationDialog dialog;
  if ( window instanceof JDialog ) {
    dialog = new MigrateConfirmationDialog( (JDialog) window );
  } else if ( window instanceof JFrame ) {
    dialog = new MigrateConfirmationDialog( (JFrame) window );
  } else {
    dialog = new MigrateConfirmationDialog();
  }

  final UserInput userInput = dialog.performSelection();
  if ( userInput == UserInput.Clear ) {
    masterReportElement.setCompatibilityLevel( null );
  } else if ( userInput == UserInput.Migrate ) {
    MigrateReportAction.migrateReport( designerContext );
  }
}