com.massimo.tools.scriptrunner.control
Class IfTask
java.lang.Object
com.massimo.tools.scriptrunner.AbstractTask
com.massimo.tools.scriptrunner.control.AbstractCompoundTask
com.massimo.tools.scriptrunner.control.IfTask
- All Implemented Interfaces:
- Task
public class IfTask
- extends AbstractCompoundTask
Conditional execution of a single child task.
Introduces the attributes
ifname
and
ifvalue.
The ifname attribute must exist. The optional ifvalue attribute will be a list of values.
If the value of the property named by ifname matches one of the ifvalue list, the contained task will be executed.
If ifvalue is not set, the contained task will be executed if the ifname property is set to any value.
If the ifname property is not in the ifvalue list, this Task will still return Task.SUCCESS.
Methods inherited from class com.massimo.tools.scriptrunner.AbstractTask |
getBooleanProperty, getCurrentWorkingDirectory, getDefinition, getIntProperty, getName, getParent, getProperties, getStartProcessingRow, getText, getType, isIgnoreableError, isIgnoreableError, isInterrupted, isLogProgress, postProcess, preProcess, process, resultCodeToString, substituteParameters, toString, validate, validateConnections, validateParameters |
IfTask
public IfTask(Task parent,
String type,
Element definition,
Map<String,String> contextProperties)
- Parameters:
parent
- type
- definition
- contextProperties
-
doValidate
public int doValidate(ValidationContext context)
throws Exception
- Check whether this task should be able to run.
Implementations should check for the prescence of files, attributes,...
Validates all child tasks
Check the attributes Constants.ATTRIBUTE_IFNAME
and Constants.ATTRIBUTE_IFVALUE.
- Overrides:
doValidate
in class AbstractCompoundTask
- Returns:
- O for success. Anything else is a failure.
- Throws:
Exception
getLogger
protected org.apache.log4j.Logger getLogger()
-
- Specified by:
getLogger
in class AbstractTask
- Returns:
- Class logger
processCompound
protected int processCompound(ExecutionContext context,
Elements tasks)
throws Exception
- Checks the attributes Constants.ATTRIBUTE_IFNAME
and Constants.ATTRIBUTE_IFVALUE to determine whether to run the child task.
- Specified by:
processCompound
in class AbstractCompoundTask
- Parameters:
context
- tasks
- A list of Task definition Elements
- Returns:
- The result of running all tasks
- Throws:
Exception