use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class JFreeReportComponent method getInputParamDataFactory.
private PentahoTableDataFactory getInputParamDataFactory() {
PentahoTableDataFactory factory = null;
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
ActionInput reportDataParam = (ActionInput) jFreeReportAction.getData();
Object dataObject = reportDataParam != null ? reportDataParam.getValue() : null;
if ((dataObject instanceof IPentahoResultSet) || (dataObject instanceof TableModel)) {
factory = new PentahoTableDataFactory();
if (dataObject instanceof IPentahoResultSet) {
IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
if (resultset.isScrollable()) {
resultset.beforeFirst();
} else {
// $NON-NLS-1$
debug("ResultSet is not scrollable. Copying into memory");
IPentahoResultSet memSet = resultset.memoryCopy();
resultset.close();
resultset = memSet;
}
factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(resultset));
} else if (dataObject instanceof TableModel) {
factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, (TableModel) dataObject);
}
IActionInput[] subreportQueries = jFreeReportAction.getSubreportQueryParams();
for (IActionInput element : subreportQueries) {
dataObject = element.getValue();
if (dataObject instanceof IPreparedComponent) {
factory.addPreparedComponent(element.getName(), (IPreparedComponent) dataObject);
} else if (dataObject instanceof IPentahoResultSet) {
final IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
resultset.beforeFirst();
factory.addTable(element.getName(), new PentahoTableModel(resultset));
} else if (dataObject instanceof TableModel) {
factory.addTable(element.getName(), (TableModel) dataObject);
}
}
}
return factory;
}
use of org.pentaho.actionsequence.dom.IActionInput 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.IActionInput 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.IActionInput in project pentaho-platform by pentaho.
the class UtilityComponent method executeFormatAction.
private boolean executeFormatAction(final FormatMsgAction formatMsgAction) {
boolean result = true;
String formatString = formatMsgAction.getFormatString().getStringValue();
IActionOutput actionOutput = formatMsgAction.getOutputString();
IActionInput[] msgInputs = formatMsgAction.getMsgInputs();
ArrayList formatArgs = new ArrayList();
for (IActionInput element : msgInputs) {
formatArgs.add(element.getStringValue());
}
try {
MessageFormat mf = new MessageFormat(formatString);
String theResult = mf.format(formatArgs.toArray());
if (actionOutput != null) {
actionOutput.setValue(theResult);
}
} catch (Exception ex) {
result = false;
}
return result;
}
use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class ActionDelegate method executeAction.
/**
* Wires up inputs outputs and resources to an Action and executes it.
*/
@Override
protected boolean executeAction() throws Throwable {
//
// Set inputs
//
InputErrorCallback errorCallback = new InputErrorCallback();
for (IActionInput input : getActionDefinition().getInputs()) {
Object inputValue = input.getValue();
if (input instanceof ActionInputConstant) {
// if the input is coming from the component definition section,
// do parameter replacement on the string and the result of that
// is the input value
inputValue = input.getStringValue(true);
}
errorCallback.setValue(inputValue);
actionHarness.setValue(input.getName(), inputValue, errorCallback, COMPATIBILITY_FORMATTER, ALTERNATE_INDEX_FORMATTER);
}
//
// Set resources
//
ResourceCallback resourceCallback = new ResourceCallback();
for (IActionResource res : getActionDefinition().getResources()) {
actionHarness.setValue(res.getName(), res.getInputStream(), resourceCallback, COMPATIBILITY_FORMATTER, ALTERNATE_INDEX_FORMATTER);
}
//
// Provide output stream for the streaming action. We are going to look for all outputs where
// type = "content", and derive output streams to hand to the IStreamingAction.
//
Map<String, IContentItem> outputContentItems = new HashMap<String, IContentItem>();
StreamOutputErrorCallback streamingOutputCallback = new StreamOutputErrorCallback();
OuputStreamGenerator outputStreamGenerator = new OuputStreamGenerator(outputContentItems);
IActionOutput[] contentOutputs = getActionDefinition().getOutputs(ActionSequenceDocument.CONTENT_TYPE);
if (contentOutputs.length > 0) {
for (IActionOutput contentOutput : contentOutputs) {
outputStreamGenerator.setContentOutput(contentOutput);
actionHarness.setValue(contentOutput.getName(), outputStreamGenerator, streamingOutputCallback, STREAM_APPENDER_FORMATTER, COMPATIBILITY_FORMATTER, ALTERNATE_INDEX_FORMATTER);
}
}
//
if (actionBean instanceof IAction) {
((IAction) actionBean).execute();
}
//
for (IActionOutput output : actionDefintionOutputs) {
String outputName = output.getName();
outputName = COMPATIBILITY_FORMATTER.format(outputName);
// if streaming output, add it to the context and don't try to get it from the Action bean
if (outputContentItems.containsKey(outputName)) {
IContentItem contentItem = outputContentItems.get(outputName);
if (!(contentItem instanceof SimpleContentItem)) {
// this is a special output for streaming actions and does not require a bean accessor
output.setValue(contentItem);
}
} else if (actionHarness.isReadable(outputName)) {
Object outputVal = actionHarness.getValue(outputName);
output.setValue(outputVal);
} else {
if (loggingLevel <= ILogger.WARN) {
warn(// $NON-NLS-1$
Messages.getInstance().getString(// $NON-NLS-1$
"ActionDelegate.WARN_OUTPUT_NOT_READABLE", outputName, output.getType(), actionBean.getClass().getSimpleName()));
}
}
}
return true;
}
Aggregations