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

The following examples show how to use org.pentaho.reporting.engine.classic.core.MasterReport#setDefinitionSource() . 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: MasterReportXmlResourceFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected Object finishResult( final Object res, final ResourceManager manager, final ResourceData data,
    final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException {
  final MasterReport report = (MasterReport) res;
  if ( report == null ) {
    throw new ResourceCreationException( "Report has not been parsed." );
  }

  if ( context != null ) {
    report.setContentBase( context );
  } else {
    report.setContentBase( data.getKey() );
  }
  report.setDefinitionSource( data.getKey() );
  report.setResourceManager( manager );
  report.updateLegacyConfiguration();
  return report;

}
 
Example 2
Source File: Prd3319IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method does what the report designer does on save.
 *
 * @param report
 * @param file
 * @throws Exception
 */
private void saveReport( final MasterReport report, final File file ) throws Exception {
  BundleWriter.writeReportToZipFile( report, file );
  final ResourceManager resourceManager = report.getResourceManager();
  final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class );
  final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
  final ResourceKey bundleKey = bundle.getBundleKey();

  final MemoryDocumentBundle mem = new MemoryDocumentBundle();
  BundleUtilities.copyStickyInto( mem, bundle );
  BundleUtilities.copyMetaData( mem, bundle );
  report.setBundle( mem );
  report.setContentBase( mem.getBundleMainKey() );
  report.setDefinitionSource( bundleKey );
}
 
Example 3
Source File: Prd3159IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method does what the report designer does on save.
 *
 * @param report
 * @param file
 * @throws Exception
 */
private void saveReport( final MasterReport report, final File file ) throws Exception {
  BundleWriter.writeReportToZipFile( report, file );
  final ResourceManager resourceManager = report.getResourceManager();
  final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class );
  final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
  final ResourceKey bundleKey = bundle.getBundleKey();

  final MemoryDocumentBundle mem = new MemoryDocumentBundle();
  BundleUtilities.copyStickyInto( mem, bundle );
  BundleUtilities.copyMetaData( mem, bundle );
  report.setBundle( mem );
  report.setContentBase( mem.getBundleMainKey() );
  report.setDefinitionSource( bundleKey );
}
 
Example 4
Source File: Prd3795IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method does what the report designer does on save.
 */
private void saveReport( final MasterReport report, final File file ) throws Exception {
  BundleWriter.writeReportToZipFile( report, file );
  final ResourceManager resourceManager = report.getResourceManager();
  final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class );
  final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
  final ResourceKey bundleKey = bundle.getBundleKey();

  final MemoryDocumentBundle mem = new MemoryDocumentBundle();
  BundleUtilities.copyStickyInto( mem, bundle );
  BundleUtilities.copyMetaData( mem, bundle );
  report.setBundle( mem );
  report.setContentBase( mem.getBundleMainKey() );
  report.setDefinitionSource( bundleKey );
}
 
Example 5
Source File: AbstractSaveReportAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean saveReport( final ReportDesignerContext context, final ReportDocumentContext activeContext,
                           final Component parent ) {
  final MasterReport report = activeContext.getContextRoot();

  // Get the current file target
  File target = getTarget( report, parent );
  if ( target == null ) {
    return false;
  }

  // if no name has been set for the report, default to the name of the file
  String attPath;
  try {
    attPath = target.getCanonicalPath();
  } catch ( IOException ioe ) {
    // then let's not set the save path attribute to the *canonical path*
    attPath = target.getAbsolutePath();
  }

  // Write the report to the filename
  if ( SaveReportUtilities.saveReport( context, activeContext, target ) ) {
    try {
      // change report save path only in case save success. see PRD-5567
      report
        .setAttribute( ReportDesignerBoot.DESIGNER_NAMESPACE, ReportDesignerBoot.LAST_FILENAME, attPath );

      // Update the definition source to be the location from which the file is saved
      final ResourceManager resourceManager = report.getResourceManager();
      final Resource bundleResource = resourceManager.createDirectly( target, DocumentBundle.class );
      final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
      final ResourceKey bundleKey = bundle.getBundleKey();
      report.setDefinitionSource( bundleKey );
      report.setContentBase( bundleKey );
      report.setResourceManager( bundle.getResourceManager() );
      activeContext.resetChangeTracker();
    } catch ( ResourceException e ) {
      UncaughtExceptionsModel.getInstance().addException( e );
    }
    return true;
  }

  final ExceptionDialog exceptionDialog;
  final Window window = LibSwingUtil.getWindowAncestor( parent );
  if ( window instanceof Dialog ) {
    exceptionDialog = new ExceptionDialog( (Dialog) window );
  } else if ( window instanceof Frame ) {
    exceptionDialog = new ExceptionDialog( (Frame) window );
  } else {
    exceptionDialog = new ExceptionDialog();
  }
  exceptionDialog.showDialog();
  return false;
}