Search in sources :

Example 1 with FactoryParameterKey

use of org.pentaho.reporting.libraries.resourceloader.FactoryParameterKey in project pentaho-platform by pentaho.

the class JFreeReportComponent method parseReport.

private MasterReport parseReport(final IActionSequenceResource resource) {
    try {
        // define the resource url so that PentahoResourceLoader recognizes the path.
        String resourceUrl = PentahoResourceLoader.SOLUTION_SCHEMA_NAME + PentahoResourceLoader.SCHEMA_SEPARATOR + resource.getAddress();
        String fullyQualifiedServerURL = PentahoSystem.getApplicationContext().getFullyQualifiedServerURL();
        HashMap<FactoryParameterKey, Object> helperObjects = new HashMap<FactoryParameterKey, Object>();
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        helperObjects.put(new FactoryParameterKey("pentahoBaseURL"), fullyQualifiedServerURL);
        // trim out the server and port
        helperObjects.put(new FactoryParameterKey("serverBaseURL"), getBaseServerURL(fullyQualifiedServerURL));
        // $NON-NLS-1$
        helperObjects.put(new FactoryParameterKey("solutionRoot"), // $NON-NLS-1$ //$NON-NLS-2$
        PentahoSystem.getApplicationContext().getSolutionPath(""));
        // get the host:port portion only
        // $NON-NLS-1$
        helperObjects.put(new FactoryParameterKey("hostColonPort"), getHostColonPort(fullyQualifiedServerURL));
        // get the requestContextPath
        helperObjects.put(new FactoryParameterKey("requestContextPath"), // $NON-NLS-1$
        PentahoRequestContextHolder.getRequestContext().getContextPath());
        Iterator it = getInputNames().iterator();
        while (it.hasNext()) {
            try {
                String inputName = (String) it.next();
                // on how the report definition would be parsed
                if (AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT.equals(inputName)) {
                    continue;
                }
                String inputValue = getInputStringValue(inputName);
                helperObjects.put(new FactoryParameterKey(inputName), inputValue);
            } catch (Exception e) {
            // ignore
            }
        }
        ResourceManager resourceManager = new ResourceManager();
        resourceManager.registerDefaults();
        ResourceKey contextKey = resourceManager.createKey(resourceUrl, helperObjects);
        ResourceKey key = resourceManager.createKey(resourceUrl, helperObjects);
        return ReportGenerator.getInstance().parseReport(resourceManager, key, contextKey);
    } catch (Exception ex) {
        error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0007_COULD_NOT_PARSE", resource.getAddress()), // $NON-NLS-1$
        ex);
        return null;
    }
}
Also used : FactoryParameterKey(org.pentaho.reporting.libraries.resourceloader.FactoryParameterKey) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ResourceManager(org.pentaho.reporting.libraries.resourceloader.ResourceManager) PrintException(javax.print.PrintException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ContentIOException(org.pentaho.reporting.libraries.repository.ContentIOException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) ResourceException(org.pentaho.reporting.libraries.resourceloader.ResourceException) IOException(java.io.IOException) ResourceKey(org.pentaho.reporting.libraries.resourceloader.ResourceKey)

Example 2 with FactoryParameterKey

use of org.pentaho.reporting.libraries.resourceloader.FactoryParameterKey in project pentaho-platform by pentaho.

the class JFreeReportLoadComponent method parseReport.

/**
 * Parses the report, using the given ActionResource as initial report definition.
 *
 * @param resource
 * @return
 */
private MasterReport parseReport(final IActionSequenceResource resource) {
    try {
        // define the resource url so that PentahoResourceLoader recognizes the path.
        String resourceUrl = PentahoResourceLoader.SOLUTION_SCHEMA_NAME + PentahoResourceLoader.SCHEMA_SEPARATOR + resource.getAddress();
        String fullyQualifiedServerUrl = PentahoSystem.getApplicationContext().getFullyQualifiedServerURL();
        HashMap helperObjects = new HashMap();
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        helperObjects.put(new FactoryParameterKey("pentahoBaseURL"), fullyQualifiedServerUrl);
        // trim out the server and port
        // $NON-NLS-1$
        helperObjects.put(new FactoryParameterKey("serverBaseURL"), getBaseServerURL(fullyQualifiedServerUrl));
        helperObjects.put(new FactoryParameterKey("solutionRoot"), // $NON-NLS-1$ //$NON-NLS-2$
        PentahoSystem.getApplicationContext().getSolutionPath(""));
        // get the host:port portion only
        // $NON-NLS-1$
        helperObjects.put(new FactoryParameterKey("hostColonPort"), getHostColonPort(fullyQualifiedServerUrl));
        // get the requestContextPath
        helperObjects.put(new FactoryParameterKey("requestContextPath"), // $NON-NLS-1$
        PentahoRequestContextHolder.getRequestContext().getContextPath());
        Iterator it = getInputNames().iterator();
        while (it.hasNext()) {
            try {
                String inputName = (String) it.next();
                String inputValue = getInputStringValue(inputName);
                helperObjects.put(new FactoryParameterKey(inputName), inputValue);
            } catch (Exception e) {
            // ignore
            }
        }
        ResourceManager resourceManager = new ResourceManager();
        resourceManager.registerDefaults();
        ResourceKey contextKey = resourceManager.createKey(resourceUrl, helperObjects);
        ResourceKey key = resourceManager.createKey(resourceUrl, helperObjects);
        return ReportGenerator.getInstance().parseReport(resourceManager, key, contextKey);
    } catch (Exception ex) {
        error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0007_COULD_NOT_PARSE", resource.getAddress()), // $NON-NLS-1$
        ex);
        return null;
    }
}
Also used : HashMap(java.util.HashMap) FactoryParameterKey(org.pentaho.reporting.libraries.resourceloader.FactoryParameterKey) Iterator(java.util.Iterator) ResourceManager(org.pentaho.reporting.libraries.resourceloader.ResourceManager) ResourceException(org.pentaho.reporting.libraries.resourceloader.ResourceException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ResourceKey(org.pentaho.reporting.libraries.resourceloader.ResourceKey)

Aggregations

IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 FactoryParameterKey (org.pentaho.reporting.libraries.resourceloader.FactoryParameterKey)2 ResourceException (org.pentaho.reporting.libraries.resourceloader.ResourceException)2 ResourceKey (org.pentaho.reporting.libraries.resourceloader.ResourceKey)2 ResourceManager (org.pentaho.reporting.libraries.resourceloader.ResourceManager)2 FileNotFoundException (java.io.FileNotFoundException)1 PrintException (javax.print.PrintException)1 ReportProcessingException (org.pentaho.reporting.engine.classic.core.ReportProcessingException)1 ContentIOException (org.pentaho.reporting.libraries.repository.ContentIOException)1