public interface TaskCommand extends AdminCommand
CommandMgr cmdMgr = CommandMgr.getCommandMgr();
TaskCommand taskCmd = (TaskCommand) cmdMgr.createCommand(myTaskCmdName);
taskCmd.setParameter("param1", v1);
taskCmd.setParameter("param2", v2);
:
:
:
CommandStep step1 = taskCmd.getCommandStep("stepName1");
step1.setParameter("step1Param1", v1);
step1.setParameter("step1Param2", v2);
:
:
CommandStep step2 = taskCmd.getCommandStep("stepName2");
step2.setParameter("step2Param1", v1);
step2.setParameter("step2Param2", v2);
:
:
taskCmd.execute();
In interactive mode, users can navigate enabled command steps back and forth
interactively. Three methods are provided for user to traverse command steps
either sequentially or randomly: previousStep
, nextStep
and gotoStep
methods. TaskCommand keeps an internal cursor and
the cursor moves whenever user navigates through command steps by calling one
of the preceding methods. The cursor position always lies between the
enabled step that would be returned by a call to previous() and the enabled
step that would be returned by a call to next().
Initially, the cursor position is before the first enabled step. After one of the methods
mentioned earlier is called, the cursor is moved after the returned step. The code
snippet here shows how to use task command in the interactive mode.
CommandMgr cmdMgr = CommandMgr.getCommandMgr();
TaskCommand taskCmd = (TaskCommand) cmdMgr.createCommand(myTaskCmdName);
taskCmd.setParameter("param1", v1);
taskCmd.setParameter("param2", v2);
:
:
:
// get the first enabled step.
CommandStep step1 = taskCmd.next();
step1.setParameter("step1Param1", v1);
step1.setParameter("step1Param2", v2);
:
:
// go to the next enabled step.
if (taskCmd.hasNextStep()) {
CommandStep step2 = taskCmd.next();
step2.setParameter("step2Param1", v1);
step2.setParameter("step2Param2", v2);
:
:
}
// go to the previous enabled step.
if (taskCmd.hasPreviousStep()) {
CommandStep step3 = taskCmd.previous();
step3.setParameter("step3Param1", v1);
step3.setParameter("step3Param2", v2);
:
:
}
// directly go to an enabled step.
CommandStep step4 = taskCmd.gotoStep("aStepName");
step4.setParameter("step4Param1", v1);
step4.setParameter("step4Param2", v2);
:
:
taskCmd.execute();
Since the TaskCommand keeps an internal cursor when a user navigates through steps,
the user should only modify the step returned from the last call that moves
the cursor. The code snippet shown here is not valid.
:
:
// get the first enabled step.
CommandStep step1 = taskCmd.next();
step1.setParameter("step1Param1", v1);
step1.setParameter("step1Param2", v2);
:
:
// go to the next enabled step.
if (taskCmd.hasNextStep()) {
CommandStep step2 = taskCmd.next();
step2.setParameter("step2Param1", v1);
step2.setParameter("step2Param2", v2);
:
:
}
// line here is not valid.
step1.setParameter("step1Param1", v5);
Modifier and Type | Method and Description |
---|---|
CommandStep |
getCommandStep(java.lang.String stepName)
Gets the command step of the specified command step name.
|
TaskCommandResult |
getTaskCommandResult()
Gets the task command result.
|
CommandStep |
gotoStep(java.lang.String stepName)
Goes to the specified step.
|
boolean |
hasNextStep()
Tests if there is an enabled step after the cursor.
|
boolean |
hasPreviousStep()
Tests if there is an enabled step before the cursor.
|
java.lang.String[] |
listCommandSteps()
Lists the command step names contained in this task command including
the disabled command steps.
|
CommandStep |
nextStep()
Gets the next enabled command step.
|
CommandStep |
previousStep()
Gets the previous enabled step in the task command.
|
void |
processTaskParameters()
Process task command parameters
|
createParameterMetadata, execute, generateScript, getChoices, getCmdHandler, getCommandMetadata, getCommandResult, getConfigSession, getLocale, getName, getOrigParameterValue, getParameter, getTargetObject, getTargetObjectChoices, isAsyncCommand, isDynamicStepCommand, isPrivateParameter, listAllParameterName, listParameterName, listSetParams, save, setCmdHandler, setConfigSession, setLocale, setOrigParameterValue, setParameter, setTargetObject, validate
CommandStep nextStep() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there is no enabled step after the cursor.CommandStep previousStep() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if there is no enabled step before the cursor.boolean hasNextStep()
boolean hasPreviousStep()
CommandStep gotoStep(java.lang.String stepName) throws java.util.NoSuchElementException
stepName
- the step namejava.util.NoSuchElementException
- if the step is not found or not enabled.java.lang.String[] listCommandSteps()
CommandStep getCommandStep(java.lang.String stepName) throws CommandNotFoundException
gotoStep
method, this method does not change
the cursor position. Typically this method is called when the task command
is executed in batch mode.stepName
- the command step nameCommandNotFoundException
TaskCommandResult getTaskCommandResult()
void processTaskParameters() throws CommandException
CommandException
- if not able to process task parameters.