org.openanzo.commands
Class CommandChain

java.lang.Object
  extended by org.openanzo.commands.CommandChain
All Implemented Interfaces:
Command

public class CommandChain
extends java.lang.Object
implements Command

An CommandChain is an Command that is made up of a chain of Commands that get executed in order. The output of each command is placed in the input properties of the next command to reference if needed.

Author:
Matthew Roy ( mroy@cambridgesemantics.com ), Lee Feigenbaum ( feigenbl@us.ibm.com)

Constructor Summary
CommandChain()
           
 
Method Summary
 void addCommand(Command command)
          Add a command to the end of this command chain
 void addPrecondition(IPrecondition precondition)
          Add a precondition to this command that will get evaluated on the server to decide if the command can get commited.
 java.lang.Object execute()
          Method that is executed by local transaction manager when this command is processed.
 java.lang.String getCommandType()
          Returns a string representing the command type encompassed by this command.
 IDataset getDataset()
          Get the Dataset used by this command.
 java.util.Set<IPrecondition> getPreconditions()
          Return the set of preconditions for this command.
 void linkCommand(Command targetCommand, java.lang.String propertyName, Command sourceCommand)
          Linking commands allows for linking the output of one command to the input of another command.
 void setDataset(IDataset dataset)
          Set the Dataset used by this command, for example to create new resources.
 void setInputProperty(java.lang.String name, java.lang.Object value)
          An input property is a name/value pair that can be used by the command during its execution.
 void setPreconditions(java.util.Set<IPrecondition> preconditions)
          Set this commands preconditions to the given set.
 void setTransactionQueueHandler(ITransactionQueueManager transactionQueueHandler)
          Set the transactionQueueHandler on which this command is to execute
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandChain

public CommandChain()
Method Detail

addCommand

public void addCommand(Command command)
Add a command to the end of this command chain

Parameters:
command - Command to add to end of chain.

linkCommand

public void linkCommand(Command targetCommand,
                        java.lang.String propertyName,
                        Command sourceCommand)
                 throws AnzoException
Linking commands allows for linking the output of one command to the input of another command.

Parameters:
targetCommand - Command on which input property is being set
propertyName - Name of the property under which to store the output of the source command
sourceCommand - Command whose output is used as input to the target command's input properties
Throws:
AnzoException - if the source command is not a member of this chain

execute

public java.lang.Object execute()
Description copied from interface: Command
Method that is executed by local transaction manager when this command is processed. Commands can return whatever object they choose, including null.

Specified by:
execute in interface Command
Returns:
results of running command

getDataset

public IDataset getDataset()
Description copied from interface: Command
Get the Dataset used by this command.

Specified by:
getDataset in interface Command
Returns:
the Dataset used by this command

setDataset

public void setDataset(IDataset dataset)
Description copied from interface: Command
Set the Dataset used by this command, for example to create new resources.

Specified by:
setDataset in interface Command
Parameters:
dataset - the dataset where statements are added or removed

getCommandType

public java.lang.String getCommandType()
Description copied from interface: Command
Returns a string representing the command type encompassed by this command.

Specified by:
getCommandType in interface Command
Returns:
CommandType for this Command

setInputProperty

public void setInputProperty(java.lang.String name,
                             java.lang.Object value)
Description copied from interface: Command
An input property is a name/value pair that can be used by the command during its execution.

Specified by:
setInputProperty in interface Command
Parameters:
name - Name of input property
value - Value of input property

addPrecondition

public void addPrecondition(IPrecondition precondition)
Description copied from interface: Command
Add a precondition to this command that will get evaluated on the server to decide if the command can get commited.

Specified by:
addPrecondition in interface Command
Parameters:
precondition - Precondition that is evaluated on the server

getPreconditions

public java.util.Set<IPrecondition> getPreconditions()
Description copied from interface: Command
Return the set of preconditions for this command.

Specified by:
getPreconditions in interface Command
Returns:
Set of preconditions

setPreconditions

public void setPreconditions(java.util.Set<IPrecondition> preconditions)
Description copied from interface: Command
Set this commands preconditions to the given set.

Specified by:
setPreconditions in interface Command
Parameters:
preconditions - Set of preconditions that are evaluated on the server

setTransactionQueueHandler

public void setTransactionQueueHandler(ITransactionQueueManager transactionQueueHandler)
Set the transactionQueueHandler on which this command is to execute

Parameters:
transactionQueueHandler - the transactionQueueHandler on which this command is to execute


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.