Java Code Examples for org.pentaho.reporting.libraries.resourceloader.Resource

The following examples show how to use org.pentaho.reporting.libraries.resourceloader.Resource. These examples are extracted from open source projects. 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
private AbstractReportDefinition loadDefinitionFromFile( final File filename ) {
  try {
    final ResourceKey selectedFile = resourceManager.createKey( filename );
    final Resource directly = resourceManager.create( selectedFile, null, new Class[] { MasterReport.class } );
    final MasterReport resource = (MasterReport) directly.getResource();
    final DocumentBundle bundle = resource.getBundle();
    if ( bundle == null ) {
      // Ok, that should not happen if we work with the engine's parsers, but better safe than sorry.
      final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle( resource.getContentBase() );
      documentBundle.getWriteableDocumentMetaData().setBundleType( ClassicEngineBoot.BUNDLE_TYPE );
      resource.setBundle( documentBundle );
      resource.setContentBase( documentBundle.getBundleMainKey() );
    } else {
      final MemoryDocumentBundle mem = new MemoryDocumentBundle( resource.getContentBase() );
      BundleUtilities.copyStickyInto( mem, bundle );
      BundleUtilities.copyMetaData( mem, bundle );
      resource.setBundle( mem );
      resource.setContentBase( mem.getBundleMainKey() );
    }

    return (AbstractReportDefinition) resource.derive();
  } catch ( Exception ex ) {
    getDesignTimeContext().error( ex );
    return null;
  }
}
 
Example 2
/**
 * Parses an XML file which is loaded using the given file. All needed relative file- and resourcespecification are
 * loaded using the parent directory of the file <code>file</code> as base.
 *
 * @param file
 *          the report template file.
 * @return the parsed report.
 * @throws java.io.IOException
 *           if an I/O error occurs.
 */
public MasterReport parseReport( final File file ) throws IOException, ResourceException {
  if ( file == null ) {
    throw new NullPointerException();
  }
  if ( file.isDirectory() ) {
    throw new IOException( "File is not a directory." );
  }
  final File contentBase = file.getCanonicalFile().getParentFile();
  final ResourceManager resourceManager = new ResourceManager();
  final ResourceKey contextKey = resourceManager.createKey( contentBase );

  // Build the main key. That key also contains all context/parse-time
  // parameters as they will influence the resulting report. It is not
  // wise to keep caching independent from that.
  final HashMap map = new HashMap();
  final Iterator it = this.helperObjects.keySet().iterator();
  while ( it.hasNext() ) {
    final String name = (String) it.next();
    map.put( new FactoryParameterKey( name ), helperObjects.get( name ) );
  }

  final ResourceKey key = resourceManager.createKey( file, map );
  final Resource resource = resourceManager.create( key, contextKey, MasterReport.class );
  return (MasterReport) resource.getResource();
}
 
Example 3
public void testReport() throws ResourceException {
  final URL url = getClass().getResource( "Prd-3245.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  DebugReportRunner.execGraphics2D( report );

  if ( GraphicsEnvironment.isHeadless() ) {
    return;
  }

  final PreviewDialog previewDialog = new PreviewDialog( report );
  previewDialog.pack();
  previewDialog.setModal( true );
  previewDialog.setVisible( true );
}
 
Example 4
public void testResourceLabelAfterSerialization() throws Exception {
  final File url = GoldTestBase.locateGoldenSampleReport( "Prd-3514.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport org = (MasterReport) directly.getResource();

  final MasterReport report = postProcess( org );

  RelationalGroup relationalGroup = report.getRelationalGroup( 0 );
  GroupHeader header = relationalGroup.getHeader();
  Band band = (Band) header.getElement( 0 );
  Element element = band.getElement( 1 );
  assertTrue( element.getElementType() instanceof ResourceMessageType );
  element.setName( "DateTitleField" );
  //    LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 1);
  LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, header, false, false );
  RenderNode dateTitleField = MatchFactory.findElementByName( logicalPageBox, "DateTitleField" );
  assertNotNull( dateTitleField );
  //    ModelPrinter.INSTANCE.print(logicalPageBox);
}
 
Example 5
public void load( final File file ) {
  try {
    final ResourceManager resourceManager = new ResourceManager();
    final Resource resource = resourceManager.createDirectly( file, DrillDownProfileCollection.class );
    final DrillDownProfileCollection typeCollection = (DrillDownProfileCollection) resource.getResource();
    final DrillDownProfile[] types = typeCollection.getData();
    for ( int i = 0; i < types.length; i++ ) {
      final DrillDownProfile metaData = types[ i ];
      if ( metaData != null ) {
        drillDownProfiles.addElement( metaData );
      }
    }
  } catch ( Exception e ) {
    DrillDownProfileEditor.logger.error( "Failed:", e );
  }
}
 
Example 6
public void testNestedRows() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  final URL target = LayoutIT.class.getResource( "nested-rows.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), false, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each

  // This test works on some invalid assumptions and therefore cannot validate properly.
  // within a canvas context there is no inherent size for elements and thus the labels are not visible at all.

  // new ValidateRunner().startValidation(logicalPageBox);
}
 
Example 7
public void testRunNonStickyEverything() throws Exception {
  final URL url = getClass().getResource( "Prd-2974-2.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.getPageFooter().setSticky( false );
  report.getPageFooter().addElement( createLabel() );
  report.getPageFooter().setName( "Master-Footer" );
  report.getReportHeader().getSubReport( 0 ).getPageFooter().setName( "Subreport-Footer" );
  report.getReportHeader().getSubReport( 0 ).getPageFooter().setSticky( false );
  report.getReportHeader().getSubReport( 0 ).getReportHeader().addElement( createLabel( "ReportHeader-label" ) );

  report.getReportConfiguration().setConfigProperty(
      "org.pentaho.reporting.engine.classic.core.modules.output.pageable.xml.Encoding", "UTF-8" );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  assertNull( MatchFactory.match( logicalPageBox.getFooterArea(), new FooterTextMatcher( "Label" ) ) );
  assertNotNull( MatchFactory.match( logicalPageBox.getFooterArea(), new FooterTextMatcher( "XASDAS" ) ) );
}
 
Example 8
public void testRunSample() throws Exception {
  final URL url = getClass().getResource( "Prd-2863.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.getReportConfiguration().setConfigProperty(
      "org.pentaho.reporting.engine.classic.core.modules.output.pageable.xml.Encoding", "UTF-8" );
  final ByteArrayOutputStream out = new ByteArrayOutputStream();
  XmlPageReportUtil.createXml( report, out );
  final String outText = out.toString( "UTF-8" );

  int count = 0;
  int occurence = -1;
  do {
    occurence = outText.indexOf( ">Label</text>", occurence + 1 );
    if ( occurence > -1 ) {
      count += 1;
    }
  } while ( occurence != -1 );
  assertEquals( 2, count );
}
 
Example 9
public void testLayoutMatrix() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  basereport.setCompatibilityLevel( null );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final URL target = LayoutIT.class.getResource( "layout-matrix.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  new ValidateRunner().startValidation( logicalPageBox );
}
 
Example 10
public void testPre419() throws Exception {
  final URL target = Pre419IT.class.getResource( "Pre-419.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), false, true );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  new ValidateRunner().startValidation( logicalPageBox );

}
 
Example 11
public void testReport() throws Exception {
  final URL url = getClass().getResource( "Prd-3154.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  // having images in the header does not add any information, but slows down the report processing.
  PageHeader pageHeader = report.getPageHeader();
  pageHeader.removeElement( pageHeader.getElement( 5 ) );
  pageHeader.removeElement( pageHeader.getElement( 0 ) );

  List<LogicalPageBox> logicalPageBoxes = DebugReportRunner.layoutPages( report, 0, 1 );
  for ( LogicalPageBox box : logicalPageBoxes ) {
    RenderNode[] elementsByElementType = MatchFactory.findElementsByElementType( box, PageHeaderType.INSTANCE );
    Assert.assertEquals( 1, elementsByElementType.length );
    Assert.assertTrue( elementsByElementType[0] instanceof RenderBox );
    RenderBox ph = (RenderBox) elementsByElementType[0];
    Assert.assertEquals( 4, ph.getChildCount() );
  }
}
 
Example 12
public void testMinChunkWidth() throws Exception {
  if ( DebugReportRunner.isSafeToTestComplexText() == false ) {
    return;
  }

  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  basereport.setCompatibilityLevel( null );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "true" );

  final URL target = LayoutIT.class.getResource( "min-chunkwidth.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, true );

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485 or 400
  // and that only two lines exist for each
  ModelPrinter.INSTANCE.print( logicalPageBox );
  new ValidateRunner( false, true ).startValidation( logicalPageBox );
}
 
Example 13
public void registerFromXml( final URL dataFactoryMetaSource ) throws IOException {
  if ( dataFactoryMetaSource == null ) {
    throw new NullPointerException( "Error: Could not find the data-factory meta-data description file" );
  }

  try {
    final Resource resource =
        resourceManager.createDirectly( dataFactoryMetaSource, DataFactoryMetaDataCollection.class );
    final DataFactoryMetaDataCollection typeCollection = (DataFactoryMetaDataCollection) resource.getResource();
    final DataFactoryMetaData[] types = typeCollection.getFactoryMetaData();
    for ( int i = 0; i < types.length; i++ ) {
      final DataFactoryMetaData metaData = types[i];
      if ( metaData != null ) {
        register( metaData );
      }
    }
  } catch ( Exception e ) {
    DataFactoryRegistry.logger.error( "Failed:", e );
    throw new IOException( "Error: Could not parse the element meta-data description file" );
  }
}
 
Example 14
public void testRunReport() throws Exception {
  final URL url = getClass().getResource( "Prd-3562.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  PrintReportProcessor p = new PrintReportProcessor( report );
  p.paginate();
  assertTrue( p.isPaginated() );
  assertFalse( p.isError() );

  final PageDrawable pageDrawable = p.getPageDrawable( 1 );

  //
  // DebugReportRunner.createPDF(report);

}
 
Example 15
/**
 * Returns the report definition which will be used to generate the report. In this case, the report will be
 * loaded and parsed from a file contained in this package.
 *
 * @return the loaded and parsed report definition to be used in report generation.
 */
private MasterReport getReportDefinition() {
  try {
    // Using the classloader, get the URL to the reportDefinition file
    // NOTE: We will re-use the report definition from SAMPLE1
    final ClassLoader classloader = this.getClass().getClassLoader();
    final URL reportDefinitionURL = classloader
        .getResource( "org/pentaho/reporting/engine/classic/samples/Sample1.prpt" );

    // Parse the report file
    final ResourceManager resourceManager = new ResourceManager();
    final Resource directly = resourceManager.createDirectly( reportDefinitionURL, MasterReport.class );
    return (MasterReport) directly.getResource();
  } catch ( ResourceException e ) {
    e.printStackTrace();
  }
  return null;
}
 
Example 16
public void testReplacedContentRel() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );

  final URL target = LayoutIT.class.getResource( "replaced-content-relative.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  PageFormat pageFormat = report.getPageDefinition().getPageFormat( 0 );
  DebugLog.log( PageFormatFactory.printPageFormat( pageFormat ) );
  final Band containerBand = report.getReportHeader();

  // Each character (regarless of font or font-size) will be 8pt high and 4pt wide.
  // this makes this test independent of the fonts installed on the system we run on.
  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, containerBand, true, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  new ValidateRelativeRunner().startValidation( logicalPageBox );
}
 
Example 17
public void testGoldRun4() throws Exception {
  final File file = GoldTestBase.locateGoldenSampleReport( "Income Statement.xml" );
  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource directly = mgr.createDirectly( file, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( null );

  final Band element = (Band) report.getReportHeader().getElement( 2 );
  element.setName( "Tester" );
  element.getElement( 0 ).setName( "m1" );
  report.getReportHeader().getElement( 3 ).setName( "image" );

  final LogicalPageBox pageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, false );
  //ModelPrinter.INSTANCE.print(pageBox);

  final RenderNode m1 = MatchFactory.findElementByName( pageBox, "m1" );
  assertEquals( StrictGeomUtility.toInternalValue( 234 ), m1.getX() );
  final RenderNode img = MatchFactory.findElementByName( pageBox, "image" );
  assertEquals( StrictGeomUtility.toInternalValue( 0 ), img.getX() );
  assertEquals( StrictGeomUtility.toInternalValue( 234 ), img.getWidth() );
}
 
Example 18
public void testGoldRun5a() throws Exception {
  final File file = GoldTestBase.locateGoldenSampleReport( "Income Statement.xml" );
  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource directly = mgr.createDirectly( file, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( null );

  final Band element = (Band) report.getReportHeader().getElement( 2 );
  element.setName( "Tester" );
  element.getElement( 0 ).setName( "m1" );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader() );
  //ModelPrinter.INSTANCE.print(logicalPageBox);
  final RenderNode m1 = MatchFactory.findElementByName( logicalPageBox, "m1" );
  assertEquals( StrictGeomUtility.toInternalValue( 234 ), m1.getX() );
}
 
Example 19
public void testOverlapWarning() throws Exception {
  final URL url = getClass().getResource( "Prd-2887.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  final Band b1 = (Band) report.getPageHeader().getElement( 0 );
  b1.getElement( 0 ).setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, "Null Field1" );
  b1.getElement( 1 ).setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, "Null Field2" );
  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getPageHeader() );
  //ModelPrinter.print(logicalPageBox);

  final DebugOutputProcessorMetaData metaData = new DebugOutputProcessorMetaData();
  metaData.initialize( report.getConfiguration() );

  final TableLayoutProducer tlb = new TableLayoutProducer( metaData );
  tlb.update( logicalPageBox, false );
  final TableContentProducer tcp = new TestTableContentProducer( tlb.getLayout(), metaData );
  tcp.compute( logicalPageBox, false );
  //    final SheetLayout layout = tlb.getLayout();
}
 
Example 20
public void testBugExists() throws Exception {
  final URL resource = getClass().getResource( "Prd-4626.prpt" );
  assertNotNull( resource );

  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource parsed = mgr.createDirectly( resource, MasterReport.class );
  final MasterReport report = (MasterReport) parsed.getResource();

  final PrintReportProcessor pr = new PrintReportProcessor( report );
  final int numberOfPages = pr.getNumberOfPages();
  assertEquals( 4, numberOfPages );

  final ByteArrayOutputStream out = new ByteArrayOutputStream();
  PdfReportUtil.createPDF( report, out );
}
 
Example 21
public void testPerformance() throws Exception {
  if ( "false".equals( ClassicEngineBoot.getInstance().getGlobalConfig().getConfigProperty
    ( "org.pentaho.reporting.engine.classic.test.ExecuteLongRunningTest" ) ) ) {
    return;
  }
  final URL resource = getClass().getResource( "Prd-4626.prpt" );
  assertNotNull( resource );

  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource parsed = mgr.createDirectly( resource, MasterReport.class );
  final MasterReport report = (MasterReport) parsed.getResource();

  for ( int i = 0; i < 10; i += 1 ) {
    DebugReportRunner.execGraphics2D( report );
  }

  final StopWatch sw = new StopWatch();
  sw.start();
  for ( int i = 0; i < 100; i += 1 ) {
    DebugReportRunner.execGraphics2D( report );
  }
  sw.stop();
  DebugLog.log( sw.toString() );

}
 
Example 22
@Override
public void doPost(
  HttpServletRequest request, 
  HttpServletResponse response)
  throws ServletException, IOException 
{

  try {

    // Getting the report.
    ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    Resource res = manager.createDirectly(
      new URL("file:resources/interactive_report_2.prpt"),
      MasterReport.class);
    MasterReport report = (MasterReport) res.getResource();

    // Mandatory parameter.
    report.getParameterValues().put("LINE", request.getParameter("line"));

    // Conversion to HTML and rendering.
    response.setContentType("text/html");
    HtmlReportUtil.createStreamHTML(report, response.getOutputStream());

  }
  catch (Exception e) 
  {
      e.printStackTrace();
  }
}
 
Example 23
@Override
public void doPost(
  HttpServletRequest request, 
  HttpServletResponse response)
  throws ServletException, IOException 
{

  try {

    // Getting the report.
    ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    Resource res = manager.createDirectly(
      new URL("file:resources/interactive_report_1.prpt"),
      MasterReport.class);
    MasterReport report = (MasterReport) res.getResource(); 

    // Conversion to HTML and rendering.
    response.setContentType("text/html");
    HtmlReportUtil.createStreamHTML(report, response.getOutputStream());

  }
  catch (Exception e) 
  {
      e.printStackTrace();
  }
}
 
Example 24
public void testCrosstabCellSpan() throws Exception {
  final URL url = getClass().getResource( "Crosstab-List.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 4, 0, 0 ) );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  // ModelPrinter.print(logicalPageBox);
}
 
Example 25
@Test
public void testPrd3857Report() throws Exception {
  File file = GoldenSampleGenerator.locateGoldenSampleReport( "Prd-3857-001.prpt" );
  Assert.assertNotNull( file );

  final ResourceManager manager = new ResourceManager();
  manager.registerDefaults();
  final Resource res = manager.createDirectly( file, MasterReport.class );
  final MasterReport report = (MasterReport) res.getResource();

  List<LogicalPageBox> pages = DebugReportRunner.layoutPages( report, 0, 1 );
  assertPageValid( pages, 0 );
  assertPageValid( pages, 1 );
}
 
Example 26
protected Resource createResource( final ResourceKey targetKey, final RootXmlReadHandler handler,
    final Object createdProduct, final Class createdType ) {
  if ( ReportParserUtil.INCLUDE_PARSING_VALUE
      .equals( handler.getHelperObject( ReportParserUtil.INCLUDE_PARSING_KEY ) ) ) {
    return new ReportResource( targetKey, handler.getDependencyCollector(), createdProduct, createdType, false );
  }
  return new ReportResource( targetKey, handler.getDependencyCollector(), createdProduct, createdType, true );
}
 
Example 27
protected Resource createResource( final ResourceKey targetKey,
                                   final RootXmlReadHandler handler,
                                   final Object createdProduct,
                                   final Class createdType ) {
  if ( ReportParserUtil.INCLUDE_PARSING_VALUE
    .equals( handler.getHelperObject( ReportParserUtil.INCLUDE_PARSING_KEY ) ) ) {
    return new ReportResource
      ( targetKey, handler.getDependencyCollector(), createdProduct, createdType, false );
  }
  return new ReportResource
    ( targetKey, handler.getDependencyCollector(), createdProduct, createdType, true );
}
 
Example 28
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context )
  throws ResourceCreationException, ResourceLoadingException {
  if ( parent == null ) {
    throw new ResourceCreationException( "Cannot create resource: Pixie library is not available." );
  }
  return parent.create( caller, data, context );
}
 
Example 29
public void testGroupItemCount() throws Exception {
  final URL url = getClass().getResource( "aggregate-function-test.xml" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.addExpression( new EventMonitorFunction() );
  report.setDataFactory( new TableDataFactory( "default", new AggregateTestDataTableModel() ) );

  report.addExpression( new TotalItemCountVerifyFunction() );
  final RelationalGroup g = report.getGroupByName( "default" );
  if ( g != null ) {
    report.removeGroup( g );
  }

  final TotalItemCountFunction f = new TotalItemCountFunction();
  f.setName( "continent-total-gc" );
  f.setGroup( "Continent Group" );
  f.setDependencyLevel( 1 );
  report.addExpression( f );

  final TotalItemCountFunction f2 = new TotalItemCountFunction();
  f2.setName( "total-gc" );
  f2.setDependencyLevel( 1 );
  report.addExpression( f2 );

  DebugReportRunner.execGraphics2D( report );
}
 
Example 30
static List<LogicalPageBox> loadPages( String file, int expectedPages ) throws Exception {
  ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  Resource resource = resourceManager
    .createDirectly( LayoutValidationUtils.class.getResource( "pagination/" + file ), MasterReport.class );
  MasterReport report = (MasterReport) resource.getResource();

  int[] pages = new int[ expectedPages ];
  for ( int i = 0; i < expectedPages; i++ ) {
    pages[ i ] = i;
  }
  return DebugReportRunner.layoutPagesStrict( report, expectedPages, pages );
}