Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * This program is free software; you can redistribute it and/or modify it under the 
   * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software 
   * Foundation.
   *
   * You should have received a copy of the GNU Lesser General Public License along with this 
   * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html 
   * or from the Free Software Foundation, Inc., 
   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  * See the GNU Lesser General Public License for more details.
  *
  * Copyright 2006 - 2009 Pentaho Corporation.  All rights reserved.
  *
 */
 package org.pentaho.platform.plugin.action.jfreereport.helper;
 
 
 import  org.pentaho.platform.api.engine.IActionSequenceResource;
 import  org.pentaho.platform.api.engine.ISolutionFile;
 import  org.pentaho.platform.api.repository.ISolutionRepository;
 import  org.pentaho.platform.engine.services.actionsequence.ActionSequenceResource;
 import  org.pentaho.reporting.libraries.resourceloader.FactoryParameterKey;
 import  org.pentaho.reporting.libraries.resourceloader.ResourceData;
 import  org.pentaho.reporting.libraries.resourceloader.ResourceKey;
 import  org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException;
 import  org.pentaho.reporting.libraries.resourceloader.ResourceManager;
 import  org.pentaho.reporting.libraries.resourceloader.loader.AbstractResourceData;

This class is implemented to support loading solution files from the pentaho repository into JFreeReport

Author(s):
Will Gorman
 
 public class PentahoResourceData extends AbstractResourceData {
 
   private static final long serialVersionUID = 1806026106310340013L;

  

Deprecated:
replaced with the solution repository key (where applicable)
 
   public static final String PENTAHO_RUNTIME_CONTEXT_KEY = "pentahoRuntimeContext"//$NON-NLS-1$
 
   public static final String PENTAHO_SOLUTION_REPOSITORY_KEY = "pentahoSolutionRepository"//$NON-NLS-1$
 
   private String filename;
 
   private ResourceKey key;
 
   private ISolutionRepository solutionRepository;

  
constructor which takes a resource key for data loading specifics

Parameters:
key resource key
 
   public PentahoResourceData(final ResourceKey keythrows ResourceLoadingException {
     if (key == null) {
       throw new NullPointerException();
     }
 
     this. = key;
     this. = (Stringkey.getIdentifier();
     this. = (ISolutionRepository) key.getFactoryParameters().get(
         new FactoryParameterKey(.));
     if ( == null) {
       throw new ResourceLoadingException(
           "PentahoResourceData: Failed to retrieve solution repository from resource key"); //$NON-NLS-1$
     }
   }

  
gets a resource stream from the runtime context.

Parameters:
caller resource manager
Returns:
input stream
 
   public InputStream getResourceAsStream(final ResourceManager callerthrows ResourceLoadingException {
     final IActionSequenceResource resource = new ActionSequenceResource(
         ""."application/binary", (String.getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
     try {
       return .getResourceInputStream(resourcetrue);
     } catch (FileNotFoundException e) {
       throw new ResourceLoadingException(e.getLocalizedMessage(), e);
     }
   }

  
returns a requested attribute, currently only supporting filename.

Parameters:
key attribute requested
Returns:
attribute value
  public Object getAttribute(final String lookupKey) {
    if (lookupKey.equals(ResourceData.FILENAME)) {
      return ;
    }
    return null;
  }

  
return the version number. We don't have access to file dates or versions so return 0

Parameters:
caller resource manager
Returns:
version
  public long getVersion(final ResourceManager callerthrows ResourceLoadingException {
    final IActionSequenceResource resource = new ActionSequenceResource(
        ""."application/binary", (String.getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
    final ISolutionFile file = .getSolutionFile(resource);
    long version = -1L;
    if (file != null) {
      version = file.getLastModified();
    }
    return version;
  }

  
get the resource key

Returns:
resource key
  public ResourceKey getKey() {
    return ;
  }
New to GrepCode? Check out our FAQ X