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;
}
}
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;
}
}
Aggregations