org.pentaho.reporting.libraries.resourceloader.ResourceManager Java Examples

The following examples show how to use org.pentaho.reporting.libraries.resourceloader.ResourceManager. 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: Prd4965IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testSampleReport() throws Exception {
  URL res = getClass().getResource( "Prd-4965.prpt" );
  MasterReport report = (MasterReport) new ResourceManager().createDirectly( res, MasterReport.class ).getResource();
  LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  RenderNode[] mrs = MatchFactory.findElementsByName( logicalPageBox, "mr" );
  Assert.assertEquals( 2, mrs.length );
  Assert.assertTrue( mrs[0] instanceof ParagraphRenderBox );
  Assert.assertTrue( mrs[1] instanceof RenderableText );

  RenderNode[] sr0s = MatchFactory.findElementsByName( logicalPageBox, "sr-1" );
  Assert.assertEquals( 2, sr0s.length );
  Assert.assertTrue( sr0s[0] instanceof ParagraphRenderBox );
  Assert.assertTrue( sr0s[1] instanceof RenderableText );

  RenderNode[] sr1s = MatchFactory.findElementsByName( logicalPageBox, "sr-2" );
  Assert.assertEquals( 2, sr1s.length );
  Assert.assertTrue( sr1s[0] instanceof ParagraphRenderBox );
  Assert.assertTrue( sr1s[1] instanceof RenderableText );

}
 
Example #2
Source File: Sample1.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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.
 */
public MasterReport getReportDefinition() {
  try {
    // Using the classloader, get the URL to the reportDefinition file
    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 #3
Source File: Prd5316IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testReportRunCache() throws Exception {
  Assert.assertEquals( EhCacheDataCache.class.getName(), cache );
  Assert.assertEquals( TestCacheBackend.class.getName(), ClassicEngineBoot.getInstance().getGlobalConfig()
      .getConfigProperty( DataCache.class.getName() ) );

  MasterReport resource =
      (MasterReport) new ResourceManager().createDirectly( getClass().getResource( "Prd-5316.prpt" ),
          MasterReport.class ).getResource();
  DebugReportRunner.execGraphics2D( resource );
  DebugReportRunner.execGraphics2D( resource );
  DebugReportRunner.execGraphics2D( resource );

  TestCacheBackend cacheInstance = (TestCacheBackend) DataCacheFactory.getCache();
  Assert.assertEquals( 1, cacheInstance.getCache().size() );
  Assert.assertEquals( 1, cacheInstance.putCount );
  Assert.assertEquals( 3, cacheInstance.getCount );
}
 
Example #4
Source File: TemporaryDataSchemaModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public DataSchema getDataSchema() {
  if ( dataSchema == null ) {
    final ParameterDataRow parameterRow = computeParameterData();
    final ParameterDefinitionEntry[] parameterDefinitions = computeParameterDefinitionEntries();

    final ResourceManager resourceManager = getMasterReportElement().getResourceManager();
    final DataSchemaCompiler dataSchemaCompiler =
      new DataSchemaCompiler( getDataSchemaDefinition(), getDataAttributeContext(), resourceManager );

    try {
      final TableModel reportData = new DefaultTableModel();
      final Expression[] expressions = getReport().getExpressions().getExpressions();
      final ReportEnvironment reportEnvironment = getMasterReportElement().getReportEnvironment();
      dataSchema = dataSchemaCompiler.compile
        ( reportData, expressions, parameterRow, parameterDefinitions, reportEnvironment );

    } catch ( final ReportDataFactoryException e ) {
      dataSchema = new DefaultDataSchema();
    }
  }

  return dataSchema;
}
 
Example #5
Source File: URLResourceLoaderTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * This is a happy path "round-trip" test which should demonstrate the serializing and deserializing a resource key
 * should produce the same key
 */
public void testSerializeDeserializeRoundtrip() throws Exception {
  final URLResourceLoader resourceLoader = new URLResourceLoader();
  final Map<ParameterKey, Object> factoryParams = new HashMap<ParameterKey, Object>();
  final ResourceManager manager = new ResourceManager();
  manager.registerDefaults();

  factoryParams.put( new FactoryParameterKey( "this" ), "that" );
  factoryParams.put( new FactoryParameterKey( "null" ), null );
  final ResourceKey originalKey = manager.createKey( URL1, factoryParams );

  final String serializedVersion = resourceLoader.serialize( null, originalKey );
  final ResourceKey duplicateKey = resourceLoader.deserialize( null, serializedVersion );
  assertNotNull( duplicateKey );
  assertTrue( originalKey.equals( duplicateKey ) );
}
 
Example #6
Source File: Prd3245IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #7
Source File: RotationTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testTxt() throws ResourceException {
  URL url = getClass().getResource( "BACKLOG-6818.prpt" );

  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();

  try ( ByteArrayOutputStream stream = new ByteArrayOutputStream() ) {
    PlainTextReportUtil.createPlainText( report, stream );
    final byte[] bytes = stream.toByteArray();
    assertNotNull( bytes );
    assertTrue( bytes.length > 0 );
    assertTrue( StringUtils.isNotBlank( new String( bytes, "UTF-8" ) ) );
  } catch ( final IOException | ReportProcessingException e ) {
    fail();
  }
}
 
Example #8
Source File: DataFactoryScriptSupportIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testQueryOnly() throws ReportDataFactoryException {
  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();

  final DataFactoryScriptingSupport support = new DataFactoryScriptingSupport();
  support.initialize( new TableDataFactory(),
      new DesignTimeDataFactoryContext( ClassicEngineBoot.getInstance().getGlobalConfig(), mgr, new ResourceKey(
          "dummy", "dummy", new HashMap() ), new DefaultResourceBundleFactory() ) );
  support.setQuery( "test", "test-query", null, null );
  support.setQuery( "test-script", "test-query-2", "JavaScript", queryScript2 );

  assertEquals( "test-query", support.computeQuery( "test", new ParameterDataRow() ) );
  assertEqualsArray( null, support.computeAdditionalQueryFields( "test", new ParameterDataRow() ) );
  assertEquals( "result", support.computeQuery( "test-script", new ParameterDataRow() ) );
  assertEqualsArray( null, support.computeAdditionalQueryFields( "test-script", new ParameterDataRow() ) );
  support.shutdown();
}
 
Example #9
Source File: RotationTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testHTML() throws ResourceException, IOException {

  URL url = getClass().getResource( "BACKLOG-6818.prpt" );

  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();

  try ( ByteArrayOutputStream stream = new ByteArrayOutputStream() ) {
    HtmlReportUtil.createStreamHTML( report, stream );

    final String html = new String( stream.toByteArray(), "UTF-8" );
    int k = 1;
    for ( int i = 1; i < 5; i++, k = -k ) {
      final Pattern pattern = Pattern.compile( "(.*id=\"test" + i + "\".*style=\")(.*)(\".*)" );
      final Matcher matcher = pattern.matcher( html );
      if ( matcher.find() ) {
        final String group = matcher.group( 2 );
        assertTrue( group.contains( k > 0 ? TextRotation.D_90.getCss() : TextRotation.D_270.getCss() ) );
      }
    }
  } catch ( final IOException | ReportProcessingException e ) {
    fail();
  }
}
 
Example #10
Source File: Prd4634Test.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testPageFooter() throws Exception {
  final URL resource = getClass().getResource( "Prd-4634.prpt" );
  assertNotNull( resource );

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

  final GlobalAuthenticationStore globalAuthenticationStore = new GlobalAuthenticationStore();
  final ReportRenderContext reportContext =
    new ReportRenderContext( report, report, null, globalAuthenticationStore );
  final TestRootBandRenderer r = new TestRootBandRenderer( report.getPageFooter(), reportContext );

  final ValidateTextGraphics graphics2D = new ValidateTextGraphics( 468, 108 );
  assertTrue( graphics2D.hitClip( 10, 10, 1, 1 ) );
  r.draw( graphics2D );
}
 
Example #11
Source File: StraightToPNG.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Reads the report from the specified template file.
 *
 * @param templateURL the template location.
 * @return a report.
 * @throws ParseException if the report could not be parsed.
 */
private MasterReport parseReport(final URL templateURL)
    throws ParseException
{
  try
  {
    final ResourceManager mgr = new ResourceManager();
    final Resource resource = mgr.createDirectly(templateURL, MasterReport.class);
    final MasterReport report = (MasterReport) resource.getResource();
    // this demo adds the image at runtime just to show how this could be
    // done. Usually such images get referenced from the XML itself without
    // using manual coding.
    final URL imageURL = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/gorilla.jpg", StraightToPNG.class);
    final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    report.getParameterValues().put("logo", image);
    return report;
  }
  catch (Exception e)
  {
    throw new ParseException("Failed to parse the report", e);
  }
}
 
Example #12
Source File: Prd3620IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testDialog() throws Exception {
  if ( GraphicsEnvironment.isHeadless() ) {
    return;
  }

  final URL url = getClass().getResource( "Prd-3620-small.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 PreviewDialog dialog = new PreviewDialog( report );
  dialog.setModal( true );
  dialog.pack();
  dialog.setVisible( true );
}
 
Example #13
Source File: StraightToPDF.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Reads the report from the specified template file.
 *
 * @param templateURL the template location.
 * @return a report.
 * @throws ParseException if the report could not be parsed.
 */
private MasterReport parseReport(final URL templateURL)
    throws ParseException
{
  try
  {
    final ResourceManager mgr = new ResourceManager();
    final Resource resource = mgr.createDirectly(templateURL, MasterReport.class);
    final MasterReport report = (MasterReport) resource.getResource();
    final URL imageURL = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/gorilla.jpg", StraightToPDF.class);
    final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    report.getParameterValues().put("logo", image);

    return report;
  }
  catch (Exception e)
  {
    throw new ParseException("Failed to parse the report", e);
  }
}
 
Example #14
Source File: MetaDataReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Starts parsing.
 *
 * @param attrs
 *          the attributes.
 * @throws SAXException
 *           if there is a parsing error.
 */
protected void startParsing( final Attributes attrs ) throws SAXException {
  super.startParsing( attrs );

  final ResourceManager resourceManager = getRootHandler().getResourceManager();
  final ResourceKey context = getRootHandler().getContext();

  final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
  final Iterator keys = configuration.findPropertyKeys( ElementMetaDataParser.GLOBAL_INCLUDES_PREFIX );
  while ( keys.hasNext() ) {
    final String key = (String) keys.next();
    final String href = configuration.getConfigProperty( key );
    if ( StringUtils.isEmpty( href, true ) ) {
      continue;
    }

    try {
      final ResourceKey resourceKey = resourceManager.deriveKey( context, href );
      final Resource resource = resourceManager.create( resourceKey, null, GlobalMetaDefinition.class );
      globalMetaDefinition.merge( (GlobalMetaDefinition) resource.getResource() );
    } catch ( ResourceException e ) {
      logger.warn( "Failed to parse included global definitions: " + getLocator(), e );
    }
  }

}
 
Example #15
Source File: Prd5321IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testTextRendering() throws Exception {
  URL resource = getClass().getResource( "Prd-5321.prpt" );
  ResourceManager mgr = new ResourceManager();
  MasterReport report = (MasterReport) mgr.createDirectly( resource, MasterReport.class ).getResource();
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  ModelPrinter.INSTANCE.print( logicalPageBox );

  Assert.assertEquals( 6,
      MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_BOX_PARAGRAPH ).length );
  Assert.assertEquals( 13,
      MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT ).length );

  TestPdfLogicalPageDrawable pdf = createDrawableForTest( report, logicalPageBox );
  pdf.draw();
  Assert.assertEquals( 13, pdf.textRendering );
}
 
Example #16
Source File: BigDataKettleFactoryTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected DataFactory createDataFactory( final String query ) throws ReportDataFactoryException {
  try {
    URL res = getClass().getResource( "embedded-row-gen.ktr" );
    assertNotNull( res );

    ResourceManager mgr = new ResourceManager();
    ResourceKey key = mgr.createKey( res );
    final byte[] resource = mgr.load( key ).getResource( mgr );
    final EmbeddedKettleTransformationProducer producer =
      new EmbeddedKettleTransformationProducer( new FormulaArgument[ 0 ], new FormulaParameter[ 0 ], "dummy-id",
        resource );

    final KettleDataFactory kettleDataFactory = new KettleDataFactory();
    kettleDataFactory.initialize( new DesignTimeDataFactoryContext() );
    kettleDataFactory.setQuery( DEFAULT, producer );
    return kettleDataFactory;
  } catch ( ResourceException re ) {
    throw new ReportDataFactoryException( "Failed to load raw-data", re );
  }
}
 
Example #17
Source File: FunctionUtilities.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static ResourceKey createURI( final String uri, final DocumentContext layoutProcess ) {
  try {
    final ResourceKey base = layoutProcess.getContextKey();
    final ResourceManager resourceManager =
      layoutProcess.getResourceManager();

    if ( base != null ) {
      try {
        return resourceManager.deriveKey( base, uri );
      } catch ( ResourceKeyCreationException ex ) {
        // ignore ..
      }
    }
    return resourceManager.createKey( uri );
  } catch ( Exception e ) {
    return null;
  }
}
 
Example #18
Source File: ZipResourceBundleLoader.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Tries to load the bundle. If the key does not point to a usable resource-bundle, this method returns null. The
 * Exception is only thrown if the bundle is not readable because of IO-Errors.
 * <p/>
 * A resource-bundle loader should only load the bundle for the key itself, never for any of the derived subkeys. It
 * is the ResourceManager's responsibility to search the key's hierachy for the correct key.
 *
 * @param key the resource key pointing to the bundle.
 * @return the loaded bundle or null, if the resource was not understood.
 * @throws ResourceLoadingException if something goes wrong.
 */
public ResourceBundleData loadBundle( final ResourceManager resourceManager,
                                      final ResourceKey key ) throws ResourceLoadingException {
  if ( resourceManager == null ) {
    throw new NullPointerException();
  }
  if ( key == null ) {
    throw new NullPointerException();
  }

  try {
    final ResourceData rawData = resourceManager.loadRawData( key );
    // A zip bundle can be recognized by using simple finger-printing
    final byte[] buffer = new byte[ 2 ];
    rawData.getResource( resourceManager, buffer, 0, 2 );
    if ( buffer[ 0 ] != 'P' || buffer[ 1 ] != 'K' ) {
      return null;
    }

    final InputStream stream = rawData.getResourceAsStream( resourceManager );
    try {
      final ZipReadRepository zipReadRepository = new ZipReadRepository( stream );
      final String bundleType = BundleUtilities.getBundleType( zipReadRepository );
      final String bundleMapping = BundleUtilities.getBundleMapping( bundleType );

      final HashMap<FactoryParameterKey, Object> map = new HashMap<FactoryParameterKey, Object>();
      map.put( new FactoryParameterKey( "repository" ), zipReadRepository );
      map.put( new FactoryParameterKey( "repository-loader" ), this );

      final ResourceKey mainKey = new ResourceKey( key, ZipResourceBundleLoader.class.getName(), bundleMapping, map );
      return new RepositoryResourceBundleData( key, zipReadRepository, mainKey, false );
    } finally {
      stream.close();
    }
  } catch ( UnrecognizedLoaderException e ) {
    return null;
  } catch ( IOException ioe ) {
    throw new ResourceLoadingException( "IOError during load", ioe );
  }
}
 
Example #19
Source File: RichTextSpecProducer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public RichTextSpecProducer( final OutputProcessorMetaData metaData, final ResourceManager resourceManager ) {
  ArgumentNullException.validate( "metaData", metaData );
  ArgumentNullException.validate( "resourceManager", resourceManager );

  this.metaData = metaData;
  imageProducer = new RichTextImageProducer( metaData, resourceManager );
}
 
Example #20
Source File: Backlog7181IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testCsvFast() throws Exception {
  URL url = getClass().getResource( "BACKLOG-7181.prpt" );
  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();
  org.pentaho.reporting.engine.classic.core.testsupport.DebugReportRunner.createTestOutputFile();

  try ( ByteArrayOutputStream stream = new ByteArrayOutputStream() ) {
    FastCsvReportUtil.process( report, stream );
    final byte[] bytes = stream.toByteArray();
    Assert.assertNotNull( bytes );
    Assert.assertTrue( bytes.length > 0 );
  }

}
 
Example #21
Source File: ExtraFooterIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testExtraFooterOnMigration() throws Exception {
  final File file = GoldTestBase.locateGoldenSampleReport( "Prd-2974-2.prpt" );
  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource directly = mgr.createDirectly( file, MasterReport.class );
  final MasterReport report = tuneForMigrationMode( (MasterReport) directly.getResource() );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  // ModelPrinter.print(logicalPageBox);
  final RenderBox srb = (RenderBox) logicalPageBox.getFooterArea().getFirstChild();
  assertTrue( srb.getFirstChild() instanceof ProgressMarkerRenderBox );
}
 
Example #22
Source File: Pre458IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testWatermarkCrash() throws Exception {
  final URL url = getClass().getResource( "Pre-458.xml" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport resource = (MasterReport) directly.getResource();

  DebugReportRunner.executeAll( resource );
}
 
Example #23
Source File: EmbeddedKettleTransformationProducer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object getQueryHash( final ResourceManager resourceManager, final ResourceKey resourceKey ) {
  final ArrayList<Object> retval = internalGetQueryHash();
  retval.add( pluginId );
  if ( rawBytes != null ) {
    retval.add( DigestUtils.sha256Hex( rawBytes ) );
  } else {
    retval.add( Boolean.FALSE );
  }
  return retval;
}
 
Example #24
Source File: PdfEncryptionValidateIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testSaveEncrypted() throws Exception {
  final URL url = getClass().getResource( "pdf-encryption-validate.xml" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final byte[] b = createPDF( report );
  final PdfReader reader = new PdfReader( b, DocWriter.getISOBytes( "Duck" ) );
  assertTrue( reader.isEncrypted() );
}
 
Example #25
Source File: ColumnSummaryIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testPageBreakOnCT() throws Exception {
  final URL url = getClass().getResource( "agg-error.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 ReportElement crosstabCell = report.getChildElementByType( CrosstabCellType.INSTANCE );
  // report.setAttribute(AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.QUERY_LIMIT, 100);
  // crosstabCell.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.CROSSTAB_DETAIL_MODE,
  // CrosstabDetailMode.first);

  // ModelPrinter.print(DebugReportRunner.layoutPage(report, 0));
  DebugReportRunner.showDialog( report );
}
 
Example #26
Source File: MasterReport.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * A helper method that deserializes a object from the given stream.
 *
 * @param stream
 *          the stream from which to read the object data.
 * @throws IOException
 *           if an IO error occured.
 * @throws ClassNotFoundException
 *           if an referenced class cannot be found.
 */
private void readObject( final ObjectInputStream stream ) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();

  updateResourceBundleFactoryInternal();

  reportConfiguration.reconnectConfiguration( ClassicEngineBoot.getInstance().getGlobalConfig() );
  addReportModelListener( new DocumentBundleChangeHandler() );

  try {
    final String bundleType = (String) stream.readObject();

    final byte[] bundleRawZip = (byte[]) stream.readObject();
    final ResourceManager mgr = getResourceManager();
    final Resource bundleResource = mgr.createDirectly( bundleRawZip, DocumentBundle.class );
    final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();

    final MemoryDocumentBundle mem = new MemoryDocumentBundle( getContentBase() );
    BundleUtilities.copyStickyInto( mem, bundle );
    BundleUtilities.copyInto( mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(), true );
    BundleUtilities.copyMetaData( mem, bundle );
    mem.getWriteableDocumentMetaData().setBundleType( bundleType );
    setBundle( mem );
  } catch ( ResourceException e ) {
    throw new IOException( e );
  }
}
 
Example #27
Source File: CSSParserTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testParseStyleRule() throws Exception {
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();

  StyleSheetParserUtil.getInstance().parseStyleRule
    ( null, "* { width: 10% }", null, null, resourceManager, StyleKeyRegistry.getRegistry() );
}
 
Example #28
Source File: JPEGImageFactoryModule.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Resource create( final ResourceManager caller,
                        final ResourceData data,
                        final ResourceKey context )
  throws ResourceLoadingException {
  final long version = data.getVersion( caller );
  final Image image =
    Toolkit.getDefaultToolkit().createImage( data.getResource( caller ) );
  return new SimpleResource( data.getKey(), image, Image.class, version );
}
 
Example #29
Source File: XPathTableModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private NodeList evaluateNodeList( final XPath xpath, final String xpathQuery,
                                   final ResourceData xmlResourceData, final ResourceManager resourceManager )
  throws XPathExpressionException, ResourceLoadingException, IOException {
  final InputStream stream = xmlResourceData.getResourceAsStream( resourceManager );
  try {
    return (NodeList) xpath.evaluate( xpathQuery, new InputSource( stream ), XPathConstants.NODESET );
  } finally {
    stream.close();
  }
}
 
Example #30
Source File: InteractiveHtmlDemo.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public MasterReport createReport() throws ReportDefinitionException
{
  try
  {
    final ResourceManager resourceManager = new ResourceManager();
    final Resource directly = resourceManager.createDirectly(getReportDefinitionSource(), MasterReport.class);
    return (MasterReport) directly.getResource();
  }
  catch (Exception rde)
  {
    throw new ReportDefinitionException("Failed", rde);
  }
}