Package org.pentaho.reporting.libraries.resourceloader

Examples of org.pentaho.reporting.libraries.resourceloader.ResourceKey


    new File("bin/test-tmp").mkdirs();
  }

  public void testLoadSaveFromDisk() throws Exception
  {
    final ResourceKey key = createImageKey();

    final Element element = new Element();
    element.setElementType(new ContentType());
    element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, key);
    // .. save it.
    final MasterReport report = new MasterReport();
    report.getReportHeader().addElement(element);

    saveReport(report, new File("bin/test-tmp/prd-3319-load-save-disk-1.prpt"));

    // load it to establish the context in all resource-keys ..
    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource resource = mgr.createDirectly(new File("bin/test-tmp/prd-3319-load-save-disk-1.prpt"), MasterReport.class);

    // save it once, that changes the bundle ...
    final MasterReport report2 = (MasterReport) resource.getResource();
    saveReport(report2, new File("bin/test-tmp/prd-3319-load-save-disk-2.prpt"));
    // save it twice, that triggers the crash...
    saveReport(report2, new File("bin/test-tmp/prd-3319-load-save-disk-2.prpt"));

    final ProcessingContext processingContext = new DefaultProcessingContext();
    final DebugExpressionRuntime runtime = new DebugExpressionRuntime(new DefaultTableModel(), 0, processingContext);

    final Element reportElement = report2.getReportHeader().getElement(0);
    Object attribute = reportElement.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE);

    assertTrue(attribute instanceof ResourceKey);
    ResourceKey atKey = (ResourceKey) attribute;
    assertEquals("http://127.0.0.1:65535/image.jpg", atKey.getIdentifierAsString());
  }
View Full Code Here


  {
    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);
View Full Code Here

    if (content instanceof CSSConstant)
    {
      if (ContentValues.DOCUMENT_URL.equals(content))
      {
        final ResourceKey baseKey = process.getContextKey();
        final ResourceManager resourceManager = process.getResourceManager();
        final URL url = resourceManager.toURL(baseKey);
        if (url != null)
        {
          return new StaticTextToken(url.toExternalForm());
View Full Code Here

  private String computeReportName(final File reportFile)
  {
    try
    {
      final ResourceKey resourceKey = resourceManager.createKey(reportFile);
      final String reportName = computeNameFromMetadata(resourceManager, resourceKey);
      if (StringUtils.isEmpty(reportName))
      {
        return computeNameFromReport(resourceManager, resourceKey);
      }
View Full Code Here

  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)
      {
View Full Code Here

      if (content instanceof CSSConstant)
      {
        if (ContentValues.DOCUMENT_URL.equals(content))
        {
          final ResourceKey baseKey = process.getContextKey();
          final ResourceManager resourceManager = process.getResourceManager();
          final URL url = resourceManager.toURL(baseKey);
          if (url != null)
          {
            return new StaticTextToken(url.toExternalForm());
View Full Code Here

  {
    final AbstractReportDefinition report = context.getReport();
    final MasterReport masterReport = DesignTimeUtil.getMasterReport(report);

    final ResourceManager resourceManager = masterReport.getResourceManager();
    final ResourceKey contextKey = masterReport.getContentBase();
    final String designTimeFile = filenameField.getText();
    return MondrianUtil.parseSchemaName(resourceManager, contextKey, designTimeFile);
  }
View Full Code Here

          }
          else
          {
            if (value instanceof ResourceKey)
            {
              final ResourceKey reskey = (ResourceKey) value;
              final String identifierAsString = reskey.getIdentifierAsString();
              attList.setAttribute(namespace, name, "resource-key:" + reskey.getSchema() + ":" + identifierAsString);
              this.xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "attribute", attList, XmlWriter.CLOSE);
            }
            else
            {
              XmlDocumentWriter.logger.debug(
View Full Code Here

  private static StyleResolver createStyleResolver(final ReportDefinition reportDefinition,
                                                   final ProcessingContext pc)
  {
    final ResourceManager resourceManager = pc.getResourceManager();
    final ResourceKey contentBase = pc.getContentBase();

    return CSSStyleResolver.createDesignTimeResolver(reportDefinition, resourceManager, contentBase, false);
  }
View Full Code Here

                                              final Class[] type)
      throws FunctionEvaluationException
  {
    // ok, this is going to be expensive. Kids, you dont wanna try this at home ...
    final ResourceManager manager = process.getResourceManager();
    final ResourceKey baseKey = process.getContextKey();
    try
    {
      final ResourceKey key;
      if (value instanceof ResourceKey)
      {
        key = (ResourceKey) value;
      }
      else if (baseKey == null)
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.resourceloader.ResourceKey

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.