use of org.pentaho.actionsequence.dom.IActionResource 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;
}
use of org.pentaho.actionsequence.dom.IActionResource in project pentaho-platform by pentaho.
the class HQLBaseComponent method getCatalog.
/*
* Utility function to get the catalog info from hibernate config.
*/
private String getCatalog() {
IActionResource hibernateConfigRes = ((HQLConnectionAction) getActionDefinition()).getHibernateConfigResource();
String catalog = null;
String resAddress = null;
if (hibernateConfigRes != null) {
String resName = this.applyInputsToFormat(hibernateConfigRes.getName());
IActionSequenceResource resource = getResource(resName);
resAddress = resource.getAddress();
if (resAddress != null) {
catalog = this.applyInputsToFormat(resAddress);
}
}
return catalog;
}
Aggregations