Package org.pentaho.reporting.libraries.resourceloader

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


    this(reportSchemaDefinition, context, createDefaultResourceManager());
  }

  private static ResourceManager createDefaultResourceManager()
  {
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    return resourceManager;
  }
View Full Code Here


    if (metaDataSource == null)
    {
      throw new NullPointerException("Error: Could not find the element meta-data description file");
    }

    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    try
    {
      final Resource resource = resourceManager.createDirectly(metaDataSource, ElementTypeCollection.class);
      final ElementTypeCollection typeCollection = (ElementTypeCollection) resource.getResource();
      final ElementMetaData[] types = typeCollection.getElementTypes();
      for (int i = 0; i < types.length; i++)
      {
        final ElementMetaData metaData = types[i];
View Full Code Here

    {
      throw new NullPointerException("Error: Could not find the expression meta-data description file");
    }
    try
    {
      final ResourceManager resourceManager = new ResourceManager();
      resourceManager.registerDefaults();
      final Resource resource = resourceManager.createDirectly(expressionMetaSource,
          ExpressionMetaDataCollection.class);
      final ExpressionMetaDataCollection typeCollection = (ExpressionMetaDataCollection) resource.getResource();
      final ExpressionMetaData[] types = typeCollection.getExpressionMetaData();
      for (int i = 0; i < types.length; i++)
      {
View Full Code Here

      {
        return null;
      }
      try
      {
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(url, DrawableWrapper.class);
        return resource.getResource();
      }
      catch (ResourceException e)
      {
        if (DrawableLoadFilter.logger.isDebugEnabled())
        {
          DrawableLoadFilter.logger.debug("Error while loading the drawable from " + url, e);
        }
        else if (DrawableLoadFilter.logger.isWarnEnabled())
        {
          DrawableLoadFilter.logger.warn("Error while loading the drawable from " + url + ": " + e.getMessage());
        }
        failureCache.add(urlString);
        return null;
      }
    }
    else if (o instanceof byte[])
    {
      try
      {
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(o, DrawableWrapper.class);
        return resource.getResource();
      }
      catch (ResourceException e)
      {
        if (DrawableLoadFilter.logger.isDebugEnabled())
        {
          DrawableLoadFilter.logger.debug("Error while loading the drawable from byte[]", e);
        }
        else if (DrawableLoadFilter.logger.isWarnEnabled())
        {
          DrawableLoadFilter.logger.warn("Error while loading the drawable from byte[]: " + e.getMessage());
        }
        return null;
      }
    }
    else if (o instanceof Blob)
    {
      try
      {
        final Blob b = (Blob) o;
        final byte[] data = b.getBytes(1, (int) b.length());
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(data, DrawableWrapper.class);
        return resource.getResource();
      }
      catch (Exception e)
      {
        if (DrawableLoadFilter.logger.isDebugEnabled())
View Full Code Here

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

    final URL target = LineBreakTest.class.getResource("linebreak-test.xml"); //$NON-NLS-1$
    final ResourceManager rm = new ResourceManager();
    rm.registerDefaults();
    final Resource directly = rm.createDirectly(target, MasterReport.class);
    final MasterReport report = (MasterReport) directly.getResource();

    final DebugRenderer debugLayoutSystem = new DebugRenderer();
    debugLayoutSystem.startReport(report);
    debugLayoutSystem.startSection(Renderer.TYPE_NORMALFLOW);
View Full Code Here

    {
      throw new NullPointerException("Error: Could not find the data-factory meta-data description file");
    }
    try
    {
      final ResourceManager resourceManager = new ResourceManager();
      resourceManager.registerDefaults();
      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++)
      {
View Full Code Here

      // 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();
      resourceManager.registerDefaults();
      final Resource directly = resourceManager.createDirectly(reportDefinitionURL, MasterReport.class);
      return (MasterReport) directly.getResource();
    }
    catch (ResourceException e)
    {
      e.printStackTrace();
View Full Code Here

    }
    if (o instanceof byte[])
    {
      try
      {
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(o, Image.class);
        return new DefaultImageReference(resource);
      }
      catch (ResourceException e)
      {
        if (ImageLoadFilter.logger.isDebugEnabled())
        {
          ImageLoadFilter.logger.debug("Error while loading the image from a blob", e);
        }
        else if (ImageLoadFilter.logger.isWarnEnabled())
        {
          ImageLoadFilter.logger.warn("Error while loading the image from a blob: " + e.getMessage());
        }
        return null;
      }
    }
    else if (o instanceof Blob)
    {
      try
      {
        final Blob b = (Blob) o;
        final byte[] data = IOUtils.getInstance().readBlob(b);
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(data, Image.class);
        return new DefaultImageReference(resource);
      }
      catch (Exception e)
      {
        if (ImageLoadFilter.logger.isDebugEnabled())
        {
          ImageLoadFilter.logger.debug("Error while loading the image from a blob", e);
        }
        else if (ImageLoadFilter.logger.isWarnEnabled())
        {
          ImageLoadFilter.logger.warn("Error while loading the image from a blob: " + e.getMessage());
        }
        return null;
      }
    }
    else if (o instanceof URL)
    {
      // a valid url is found, lookup the url in the cache, maybe the image is loaded and
      // still there.
      final URL url = (URL) o;
      final String urlText = String.valueOf(url);
      if (failureCache.contains(urlText))
      {
        return null;
      }
      try
      {
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(url, Image.class);
        return new DefaultImageReference(resource);
      }
      catch (ResourceException e)
      {
        if (ImageLoadFilter.logger.isDebugEnabled())
View Full Code Here

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

    if (href == null)
    {
      throw new ParseException("Required attribute 'src' is missing", getLocator());
    }

    final ResourceManager resourceManager = getRootHandler().getResourceManager();
    final ResourceKey context = getRootHandler().getContext();
    try
    {
      final ResourceKey resourceKey = resourceManager.deriveKey(context, href);
      final Resource resource = resourceManager.create(resourceKey, null, GlobalMetaDefinition.class);
      result = (GlobalMetaDefinition) resource.getResource();
    }
    catch (ResourceException e)
    {
      throw new ParseException("Failed to parse included global definitions", e, getLocator());
View Full Code Here

TOP

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

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.