use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class RuntimeContext method getInputParameterStringValue.
public String getInputParameterStringValue(final String name) {
String value = null;
IActionParameter actionParameter = paramManager.getCurrentInput(name);
if (actionParameter == null) {
// TODO need to know from the action definition if this is ok or not
warn(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", name, // $NON-NLS-1$
actionSequence.getSequenceName()));
} else {
value = actionParameter.getStringValue();
}
return value;
}
use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class ParameterManager method getReturnParameters.
/**
* Returns a mapping of output parameters and the value and destination.
*
* @param actionSequence
* The Action Sequence definition to use
*
* @return a map with the param name as the key and a ReturnParameter containing the data.
*/
public Map getReturnParameters() {
ListOrderedMap returnMap = new ListOrderedMap();
// Iterate for each output defined
for (Iterator it = sequenceOutputDefs.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry) it.next();
String outputName = (String) entry.getKey();
IActionParameter outputParam = (IActionParameter) entry.getValue();
if (!outputParam.isOutputParameter()) {
continue;
}
// The output Action Parameter objects do not have values - they are just the definition
// Pull the value from allParams
IActionParameter inputParam = (IActionParameter) allParams.get(outputName);
if (inputParam == null) {
returnMap.put(outputParam.getName(), null);
} else {
for (Iterator varIt = outputParam.getVariables().iterator(); varIt.hasNext(); ) {
ActionParameterSource src = (ActionParameterSource) varIt.next();
returnMap.put(outputParam.getName(), new ReturnParameter(src.getSourceName(), src.getValue(), inputParam.getValue()));
}
}
}
return (returnMap);
}
use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class ParameterManager method addOutputParameters.
public boolean addOutputParameters(final ISolutionActionDefinition actionDefinition) {
String key;
for (Iterator it = actionDefinition.getActionOutputDefinitions().keySet().iterator(); it.hasNext(); ) {
key = (String) it.next();
IActionParameter outputParam = (IActionParameter) currentOutputs.get(key);
key = actionDefinition.getMappedOutputName(key);
// If we already have a parameter with this name, set the value and reuse the definition.
IActionParameter param = (IActionParameter) allParams.get(key);
if (param != null) {
if (param != outputParam) {
// This is a trap for catching temp params that didn't get deleted at the end
// of
// the last loop
param.dispose();
param.setValue(outputParam.getValue());
}
} else {
addToAllInputs(key, outputParam);
}
}
return (true);
}
use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class RuntimeContext method getOutputItem.
public IContentItem getOutputItem(final String outputName, final String mimeType, final String extension) {
// TODO support content output versions in the action definition
IActionParameter outputParameter = getOutputParameter(outputName);
if (outputParameter == null) {
warn(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, // $NON-NLS-1$
actionSequence.getSequenceName()));
return null;
}
// $NON-NLS-1$
String filePath = "~/workspace/" + FilenameUtils.getBaseName(getSolutionPath()) + extension;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String contentName = "contentrepo:" + filePath;
if (!IActionParameter.TYPE_CONTENT.equals(outputParameter.getType())) {
// $NON-NLS-1$
warn(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0023_INVALID_OUTPUT_STREAM", outputName));
return null;
}
try {
IContentOutputHandler output = PentahoSystem.getOutputDestinationFromContentRef(contentName, session);
if (output != null) {
// TODO get this info
output.setInstanceId(instanceId);
output.setSolutionPath(filePath);
output.setMimeType(mimeType);
output.setSession(session);
IContentItem contentItem = output.getFileOutputContentItem();
setOutputValue(outputName, contentItem);
return contentItem;
}
} catch (Exception e) {
// ignored
}
return null;
}
use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class RuntimeContext method setOutputValue.
public void setOutputValue(final String name, final Object output) {
IActionParameter actionParameter = paramManager.getCurrentOutput(name);
if (actionParameter == null) {
throw new InvalidParameterException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", name, // $NON-NLS-1$
actionSequence.getSequenceName()));
}
actionParameter.setValue(output);
if (output instanceof String) {
runtimeData.setStringProperty(name, (String) output);
} else if (output instanceof Date) {
runtimeData.setDateProperty(name, (Date) output);
} else if (output instanceof Long) {
runtimeData.setLongProperty(name, (Long) output);
} else if (output instanceof List) {
runtimeData.setListProperty(name, (List) output);
} else if (output instanceof Map) {
runtimeData.setMapProperty(name, (Map) output);
} else if (output instanceof IContentItem) {
runtimeData.setStringProperty(name, ((IContentItem) output).getPath());
}
}
Aggregations