use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.
the class JFreeReportComponent method getReportFromJar.
private MasterReport getReportFromJar() throws Exception {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
MasterReport report;
org.pentaho.actionsequence.dom.IActionResource reportJar = jFreeReportAction.getReportDefinitionJar().getJar();
final IActionSequenceResource resource = getResource(reportJar.getName());
final ClassLoader loader = ReportUtils.createJarLoader(getSession(), resource);
if (loader == null) {
throw new Exception(Messages.getInstance().getString(// $NON-NLS-1$
"JFreeReportLoadComponent.ERROR_0035_COULD_NOT_CREATE_CLASSLOADER"));
}
String reportLocation = jFreeReportAction.getReportDefinitionJar().getReportLocation();
URL resourceUrl = loader.getResource(reportLocation);
if (resourceUrl == null) {
throw new Exception(// $NON-NLS-1$
Messages.getInstance().getErrorString(// $NON-NLS-1$
"JFreeReport.ERROR_0016_REPORT_RESOURCE_INVALID", reportLocation, resource.getAddress()));
}
try {
ReportGenerator generator = ReportGenerator.getInstance();
// add the runtime context so that PentahoResourceData class can get access to the solution repo
// generator.setObject(PentahoResourceData.PENTAHO_RUNTIME_CONTEXT_KEY, getRuntimeContext());
report = generator.parseReport(resourceUrl, getDefinedResourceURL(resourceUrl));
} catch (Exception ex) {
throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0007_COULD_NOT_PARSE", reportLocation), // $NON-NLS-1$
ex);
}
return report;
}
use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.
the class JFreeReportComponent method getReport.
public MasterReport getReport() throws Exception {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
MasterReport report = getReportFromResource();
if (report == null) {
report = getReportFromInputParam();
if (report == null) {
report = getReportFromJar();
}
}
if ((report != null) && jFreeReportAction.getCreatePrivateCopy().getBooleanValue(false)) {
report = (MasterReport) report.clone();
}
return report;
}
use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.
the class JFreeReportComponent method initReportInputs.
private boolean initReportInputs(final MasterReport report) throws CloneNotSupportedException {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
// Get input parameters, and set them as properties in the report
// object.
IActionInput[] actionInputs = jFreeReportAction.getInputs();
for (IActionInput element : actionInputs) {
String paramName = element.getName();
Object paramValue = element.getValue();
if ((paramValue == null) || "".equals(paramValue)) {
// $NON-NLS-1$
continue;
}
if (paramValue instanceof IPentahoResultSet) {
continue;
}
if (paramValue instanceof TableModel) {
continue;
}
if (AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT.equals(paramName)) {
continue;
}
if (AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_DATAINPUT.equals(paramName)) {
continue;
}
if (AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT.equals(paramName)) {
continue;
}
/*
* WG: Commenting out because this change (SVN: 44880) breaks bi-developers / reporting / subreport.xaction we'll
* need to revisit this when reving to the 4.0 reporting engine.
*
* final ParameterDefinitionEntry[] parameterDefinitions =
* report.getParameterDefinition().getParameterDefinitions(); boolean foundParameter = false; for (int j = 0; j <
* parameterDefinitions.length; j++) { final ParameterDefinitionEntry definition = parameterDefinitions[j]; if
* (paramName.equals(definition.getName())) { foundParameter = true; break; } } if (foundParameter == false) { if
* (report.getParameterDefinition() instanceof ModifiableReportParameterDefinition) { final
* ModifiableReportParameterDefinition parameterDefinition = (ModifiableReportParameterDefinition)
* report.getParameterDefinition(); parameterDefinition.addParameterDefinition(new PlainParameter(paramName)); } }
*/
if (paramValue instanceof Object[]) {
Object[] values = (Object[]) paramValue;
StringBuffer valuesBuffer = new StringBuffer();
// TODO support non-string items
for (int j = 0; j < values.length; j++) {
if (j == 0) {
valuesBuffer.append(values[j].toString());
} else {
valuesBuffer.append(',').append(values[j].toString());
}
}
report.getParameterValues().put(paramName, valuesBuffer.toString());
// report.setProperty(paramName, valuesBuffer.toString());
} else {
report.getParameterValues().put(paramName, paramValue);
// report.setProperty(paramName, paramValue);
}
}
return true;
}
use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.
the class JFreeReportComponent method initReportParams.
private int initReportParams() {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
int result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_PASSED;
// $NON-NLS-1$
final String defaultValue = "";
IActionInput[] actionInputs = jFreeReportAction.getInputs();
for (IActionInput element : actionInputs) {
Object paramValue = element.getValue();
String inputName = element.getName();
if (// $NON-NLS-1$
(paramValue == null) || ("".equals(paramValue))) {
IActionParameter paramParameter = getInputParameter(inputName);
if (paramParameter.getPromptStatus() == IActionParameter.PROMPT_PENDING) {
result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_PROMPT_PENDING;
continue;
}
if (isParameterUIAvailable()) {
// The parameter value was not provided, and we are allowed
// to
// create user interface forms
// $NON-NLS-1$
createFeedbackParameter(inputName, inputName, "", defaultValue, true);
result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_PROMPT_PENDING;
} else {
result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_FAILED;
}
}
}
return result;
}
use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.
the class ReportWizardSpecComponent method getReportSpec.
@SuppressWarnings("deprecation")
public ReportSpec getReportSpec() throws IOException {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
DataSource dataSource = new ActivationHelper.PentahoStreamSourceWrapper(jFreeReportAction.getReportDefinitionDataSource());
ReportSpec reportSpec = null;
reportSpec = loadFromZip(dataSource.getInputStream());
if (reportSpec == null) {
dataSource = new ActivationHelper.PentahoStreamSourceWrapper(jFreeReportAction.getReportDefinitionDataSource());
reportSpec = (ReportSpec) CastorUtility.getInstance().readCastorObject(dataSource.getInputStream(), ReportSpec.class);
}
return reportSpec;
}
Aggregations