use of org.pentaho.platform.api.engine.IConditionalExecution in project pentaho-platform by pentaho.
the class RuntimeContext method performActions.
private void performActions(final IActionSequence sequence, final IActionCompleteListener doneListener, final IExecutionListener execListener, final boolean async) throws ActionSequenceException {
IConditionalExecution conditional = sequence.getConditionalExecution();
if (conditional != null) {
try {
if (!conditional.shouldExecute(paramManager.getAllParameters(), RuntimeContext.logger)) {
// audit(MessageTypes.ACTION_SEQUENCE_EXECUTE_CONDITIONAL, MessageTypes.NOT_EXECUTED, "", 0); //$NON-NLS-1$ //$NON-NLS-2$
if (RuntimeContext.debug) {
// $NON-NLS-1$
this.debug(Messages.getInstance().getString("RuntimeContext.INFO_ACTION_NOT_EXECUTED"));
}
status = IRuntimeContext.RUNTIME_STATUS_SUCCESS;
return;
}
} catch (Exception ex) {
// $NON-NLS-1$
currentComponent = "";
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
throw new ActionExecutionException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0032_CONDITIONAL_EXECUTION_FAILED"), // $NON-NLS-1$
ex, session.getName(), instanceId, getActionSequence().getSequenceName(), null);
}
}
List defList = sequence.getActionDefinitionsAndSequences();
Object listItem;
for (Iterator actIt = defList.iterator(); actIt.hasNext(); ) {
listItem = actIt.next();
if (listItem instanceof IActionSequence) {
executeSequence((IActionSequence) listItem, doneListener, execListener, async);
} else if (listItem instanceof ISolutionActionDefinition) {
ISolutionActionDefinition actionDef = (ISolutionActionDefinition) listItem;
currentComponent = actionDef.getComponentName();
paramManager.setCurrentParameters(actionDef);
try {
executeAction(actionDef, parameterProviders, doneListener, execListener, async);
paramManager.addOutputParameters(actionDef);
} catch (ActionSequenceException ex) {
// $NON-NLS-1$
currentComponent = "";
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
throw ex;
}
}
if (promptStatus == IRuntimeContext.PROMPT_NOW) {
break;
}
// $NON-NLS-1$
currentComponent = "";
}
status = IRuntimeContext.RUNTIME_STATUS_SUCCESS;
}
use of org.pentaho.platform.api.engine.IConditionalExecution in project pentaho-platform by pentaho.
the class SequenceDefinition method parseConditionalExecution.
static IConditionalExecution parseConditionalExecution(final Node actionRootNode, final ILogger logger, final String nodePath) {
try {
Node condition = actionRootNode.selectSingleNode(nodePath);
if (condition == null) {
return null;
}
String script = condition.getText();
IConditionalExecution ce = PentahoSystem.get(IConditionalExecution.class, null);
ce.setScript(script);
return ce;
} catch (Exception ex) {
// $NON-NLS-1$
logger.error(Messages.getInstance().getErrorString("SequenceDefinition.ERROR_0005_PARSING_PARAMETERS"), ex);
}
return null;
}
use of org.pentaho.platform.api.engine.IConditionalExecution in project pentaho-platform by pentaho.
the class SequenceDefinition method getNextLoopGroup.
private static IActionSequence getNextLoopGroup(final ISequenceDefinition seqDef, final Node actionsNode, final String solutionPath, final ILogger logger, final int loggingLevel) {
// $NON-NLS-1$
String loopParameterName = XmlDom4JHelper.getNodeText("@loop-on", actionsNode);
// $NON-NLS-1$ //$NON-NLS-2$
boolean loopUsingPeek = "true".equalsIgnoreCase(XmlDom4JHelper.getNodeText("@peek-only", actionsNode));
Node actionDefinitionNode;
ActionDefinition actionDefinition;
List actionDefinitionList = new ArrayList();
// $NON-NLS-1$
List nodeList = actionsNode.selectNodes("*");
Iterator actionDefinitionNodes = nodeList.iterator();
while (actionDefinitionNodes.hasNext()) {
actionDefinitionNode = (Node) actionDefinitionNodes.next();
if (actionDefinitionNode.getName().equals("actions")) {
// $NON-NLS-1$
actionDefinitionList.add(SequenceDefinition.getNextLoopGroup(seqDef, actionDefinitionNode, solutionPath, logger, loggingLevel));
} else if (actionDefinitionNode.getName().equals("action-definition")) {
// $NON-NLS-1$
actionDefinition = new ActionDefinition(actionDefinitionNode, logger);
actionDefinition.setLoggingLevel(loggingLevel);
actionDefinitionList.add(actionDefinition);
}
}
// action sequences with 0 actions are valid, see: JIRA PLATFORM-837
IConditionalExecution conditionalExecution = // $NON-NLS-1$
SequenceDefinition.parseConditionalExecution(actionsNode, logger, "condition");
ActionSequence sequence = new ActionSequence(loopParameterName, seqDef, actionDefinitionList, loopUsingPeek);
sequence.setConditionalExecution(conditionalExecution);
return sequence;
}
Aggregations