org.yawlfoundation.yawl.worklet.support
Class WorkletGatewayClient

java.lang.Object
  extended by org.yawlfoundation.yawl.engine.interfce.Interface_Client
      extended by org.yawlfoundation.yawl.worklet.support.WorkletGatewayClient

public class WorkletGatewayClient
extends Interface_Client

An API to be used by clients that want to interact with the worklet service.

Author:
Michael Adams 11/07/2011

Field Summary
protected  String _wsURI
           
 
Constructor Summary
WorkletGatewayClient()
          Constructor - uses default uri on localhost
WorkletGatewayClient(String uri)
          Constructor
 
Method Summary
 String addListener(String listenerURI, String handle)
          Adds a listener for worklet events (selection, exception raising)
 String addNode(String processName, String taskID, RuleType rType, RdrNode node, String handle)
          Adds a node to a ruleSet.
 String addNode(WorkItemRecord wir, RuleType rType, RdrNode node, String handle)
          Adds a node to a ruleSet.
 String addNode(YSpecificationID specID, String taskID, RuleType rType, RdrNode node, String handle)
          Adds a node to a ruleSet.
 String checkConnection(String handle)
          Check that a session handle is active
 String connect(String userID, String password)
          Connects an external entity to the worklet service
 void disconnect(String handle)
          Disconnects an external entity from the worklet service
 String evaluate(String processName, String taskID, org.jdom.Element data, RuleType rType, String handle)
          Evaluates a data set against the rule tree for a process and task, and returns the conclusion, if any.
 String evaluate(WorkItemRecord wir, org.jdom.Element data, RuleType rType, String handle)
          Evaluates a data set against the rule tree for a specification and task, and returns the conclusion, if any.
 String evaluate(YSpecificationID specID, String taskID, org.jdom.Element data, RuleType rType, String handle)
          Evaluates a data set against the rule tree for a specification and task, and returns the conclusion, if any.
 String getNode(String processName, String taskID, RuleType rType, int nodeID, String handle)
          Gets a copy of a particular node from a rule set
 String getNode(WorkItemRecord wir, RuleType rType, int nodeID, String handle)
          Gets a copy of a particular node from a rule set
 String getNode(YSpecificationID specID, String taskID, RuleType rType, int nodeID, String handle)
          Gets a copy of a particular node from a rule set
 String getRdrSet(String processName, String handle)
          Gets a copy of a particular rule set
 String getRdrSet(YSpecificationID specID, String handle)
          Gets a copy of a particular rule set
 String getRdrTree(String processName, String taskID, RuleType rType, String handle)
          Gets a copy of a particular rule tree
 String getRdrTree(WorkItemRecord wir, RuleType rType, String handle)
          Gets a copy of a particular rule tree
 String getRdrTree(YSpecificationID specID, String taskID, RuleType rType, String handle)
          Gets a copy of a particular rule tree
 String process(WorkItemRecord wir, org.jdom.Element data, RuleType rType, String handle)
          Evaluates a data set against the rule tree for a specification and task, and if a rule node is satisfied raises an exception and executes the exception handler for the node, if one is defined.
 String refresh(YSpecificationID specID, String handle)
          Refreshes the internal rules cache from storage for a specification
 String removeListener(String listenerURI, String handle)
          Removes a listener for worklet events
 void setURI(String uri)
          Sets the uri of the Worklet Service Gateway
 
Methods inherited from class org.yawlfoundation.yawl.engine.interfce.Interface_Client
executeGet, executePost, prepareParamMap, setReadTimeout, stripOuterElement, successful
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_wsURI

protected String _wsURI
Constructor Detail

WorkletGatewayClient

public WorkletGatewayClient(String uri)
Constructor

Parameters:
uri - the uri of the Worklet Service Gateway

WorkletGatewayClient

public WorkletGatewayClient()
Constructor - uses default uri on localhost

Method Detail

setURI

public void setURI(String uri)
Sets the uri of the Worklet Service Gateway

Parameters:
uri - the uri to set

connect

public String connect(String userID,
                      String password)
               throws IOException
Connects an external entity to the worklet service

Parameters:
userID - the userid
password - the corresponding password
Returns:
a sessionHandle if successful, or a failure message if not
Throws:
IOException - if the service can't be reached

checkConnection

public String checkConnection(String handle)
                       throws IOException
Check that a session handle is active

Parameters:
handle - the session handle to check
Returns:
"true" if the id is valid, "false" if otherwise
Throws:
IOException - if the service can't be reached

disconnect

public void disconnect(String handle)
                throws IOException
Disconnects an external entity from the worklet service

Parameters:
handle - the sessionHandle to disconnect
Throws:
IOException - if the service can't be reached

addListener

public String addListener(String listenerURI,
                          String handle)
                   throws IOException
Adds a listener for worklet events (selection, exception raising)

Parameters:
listenerURI - the URI of the listener to add
handle - a current sessionhandle to the worklet service
Returns:
a message denoting success or describing an error
Throws:
IOException - if the service can't be reached

removeListener

public String removeListener(String listenerURI,
                             String handle)
                      throws IOException
Removes a listener for worklet events

Parameters:
listenerURI - the URI of the listener to remove
handle - a current sessionhandle to the worklet service
Returns:
a message denoting success or describing an error
Throws:
IOException - if the service can't be reached

refresh

public String refresh(YSpecificationID specID,
                      String handle)
               throws IOException
Refreshes the internal rules cache from storage for a specification

Parameters:
specID - the specification id to refresh the rule set for
handle - a current sessionhandle to the worklet service
Returns:
a message denoting success or describing an error
Throws:
IOException - if the service can't be reached

process

public String process(WorkItemRecord wir,
                      org.jdom.Element data,
                      RuleType rType,
                      String handle)
               throws IOException
Evaluates a data set against the rule tree for a specification and task, and if a rule node is satisfied raises an exception and executes the exception handler for the node, if one is defined. A raised exception will be announced to listeners as a byproduct of this method call.

Parameters:
wir - the workitem containing specification and task identifiers. PRE: the workitem must currently exist in the engine
data - the data set to use in the evaluation
rType - the type of rule tree to evaluate. NOTE: Only ItemAbort and ItemConstraintViolation rules can be used with this method
handle - a current sessionhandle to the worklet service
Returns:
a success or error message
Throws:
IOException - if the service can't be reached

evaluate

public String evaluate(WorkItemRecord wir,
                       org.jdom.Element data,
                       RuleType rType,
                       String handle)
                throws IOException
Evaluates a data set against the rule tree for a specification and task, and returns the conclusion, if any. Note that for a conclusion to be returned, a rule tree must exist for the specification/task/ruletype, and a rule in that tree must be satisfied.

Parameters:
wir - the workitem containing specification and task identifiers
data - the data set to use in the evaluation
rType - the type of rule tree to evaluate
handle - a current sessionhandle to the worklet service
Returns:
a conclusion XML string, or an error message
Throws:
IOException - if the service can't be reached

evaluate

public String evaluate(YSpecificationID specID,
                       String taskID,
                       org.jdom.Element data,
                       RuleType rType,
                       String handle)
                throws IOException
Evaluates a data set against the rule tree for a specification and task, and returns the conclusion, if any. Note that for a conclusion to be returned, a rule tree must exist for the specification/task/ruletype, and a rule in that tree must be satisfied.

Parameters:
specID - the specification identifier
taskID - the task identifier (may be null for case-level rule types)
data - the data set to use in the evaluation
rType - the type of rule tree to evaluate
handle - a current sessionhandle to the worklet service
Returns:
a conclusion XML string, or an error message
Throws:
IOException - if the service can't be reached

evaluate

public String evaluate(String processName,
                       String taskID,
                       org.jdom.Element data,
                       RuleType rType,
                       String handle)
                throws IOException
Evaluates a data set against the rule tree for a process and task, and returns the conclusion, if any. Note that for a conclusion to be returned, a rule tree must exist for the process/task/ruletype, and a rule in that tree must be satisfied.

Parameters:
processName - the process identifier, or unique ruleset name
taskID - the task identifier (may be null for case-level rule types)
data - the data set to use in the evaluation
rType - the type of rule tree to evaluate
handle - a current sessionhandle to the worklet service
Returns:
a conclusion XML string, or an error message
Throws:
IOException - if the service can't be reached

addNode

public String addNode(WorkItemRecord wir,
                      RuleType rType,
                      RdrNode node,
                      String handle)
               throws IOException
Adds a node to a ruleSet. If the appropriate rule tree exists, the node is added to the correct place in the tree; if the rule tree does not yet exist, it is created and the node added as its first rule node (after the root); the there is no ruleSet for the parameters, one is created, and a new tree inserted as above.

Parameters:
wir - the workitem containing specification and task identifiers
rType - the type of rule tree to add the node to
node - the node to add. It is not required that values are given for id, parent, true child or false child - these will be calculated and incorporated when the node is added. It is necessary that values are given for condition, conclusion and particularly cornerstone data, which is used to determine the correct place to insert the node within the tree. Not supplying these values will produce unpredictable results
handle - a current sessionhandle to the worklet service
Returns:
the added node, updated with parent and child ids as appropriate
Throws:
IOException - if the service can't be reached

addNode

public String addNode(YSpecificationID specID,
                      String taskID,
                      RuleType rType,
                      RdrNode node,
                      String handle)
               throws IOException
Adds a node to a ruleSet. If the appropriate rule tree exists, the node is added to the correct place in the tree; if the rule tree does not yet exist, it is created and the node added as its first rule node (after the root); the there is no ruleSet for the parameters, one is created, and a new tree inserted as above.

Parameters:
specID - the specification identifier
taskID - the task identifier (may be null for case-level rule types)
rType - the type of rule tree to add the node to
node - the node to add. It is not required that values are given for id, parent, true child or false child - these will be calculated and incorporated when the node is added. It is necessary that values are given for condition, conclusion and particularly cornerstone data, which is used to determine the correct place to insert the node within the tree. Not supplying these values will produce unpredictable results
handle - a current sessionhandle to the worklet service
Returns:
the added node, updated with parent and child ids as appropriate
Throws:
IOException - if the service can't be reached

addNode

public String addNode(String processName,
                      String taskID,
                      RuleType rType,
                      RdrNode node,
                      String handle)
               throws IOException
Adds a node to a ruleSet. If the appropriate rule tree exists, the node is added to the correct place in the tree; if the rule tree does not yet exist, it is created and the node added as its first rule node (after the root); the there is no ruleSet for the parameters, one is created, and a new tree inserted as above.

Parameters:
processName - the process identifier, or unique ruleset name
taskID - the task identifier (may be null for case-level rule types)
rType - the type of rule tree to add the node to
node - the node to add. It is not required that values are given for id, parent, true child or false child - these will be calculated and incorporated when the node is added. It is necessary that values are given for condition, conclusion and particularly cornerstone data, which is used to determine the correct place to insert the node within the tree. Not supplying these values will produce unpredictable results
handle - a current sessionhandle to the worklet service
Returns:
the added node, updated with parent and child ids as appropriate
Throws:
IOException - if the service can't be reached

getNode

public String getNode(WorkItemRecord wir,
                      RuleType rType,
                      int nodeID,
                      String handle)
               throws IOException
Gets a copy of a particular node from a rule set

Parameters:
wir - the workitem containing specification and task identifiers
rType - the type of rule tree to get the node from
nodeID - the (integer) node id
handle - a current sessionhandle to the worklet service
Returns:
the node, if found within the specification/task/rule-type combination
Throws:
IOException - if the service can't be reached

getNode

public String getNode(YSpecificationID specID,
                      String taskID,
                      RuleType rType,
                      int nodeID,
                      String handle)
               throws IOException
Gets a copy of a particular node from a rule set

Parameters:
specID - the specification identifier
taskID - the task identifier (may be null for case-level rule types)
rType - the type of rule tree to get the node from
nodeID - the (integer) node id
handle - a current sessionhandle to the worklet service
Returns:
the node, if found within the specification/task/rule-type combination
Throws:
IOException - if the service can't be reached

getNode

public String getNode(String processName,
                      String taskID,
                      RuleType rType,
                      int nodeID,
                      String handle)
               throws IOException
Gets a copy of a particular node from a rule set

Parameters:
processName - the process identifier, or unique ruleset name
taskID - the task identifier (may be null for case-level rule types)
rType - the type of rule tree to get the node from
nodeID - the (integer) node id
handle - a current sessionhandle to the worklet service
Returns:
the node, if found within the process/task/rule-type combination
Throws:
IOException - if the service can't be reached

getRdrTree

public String getRdrTree(WorkItemRecord wir,
                         RuleType rType,
                         String handle)
                  throws IOException
Gets a copy of a particular rule tree

Parameters:
wir - the workitem containing specification and task identifiers
rType - the type of rule tree to get the node from
handle - a current sessionhandle to the worklet service
Returns:
the tree, if found for the specification/task/rule-type combination
Throws:
IOException - if the service can't be reached

getRdrTree

public String getRdrTree(YSpecificationID specID,
                         String taskID,
                         RuleType rType,
                         String handle)
                  throws IOException
Gets a copy of a particular rule tree

Parameters:
specID - the specification identifier
taskID - the task identifier (may be null for case-level rule types)
rType - the type of rule tree to get the node from
handle - a current sessionhandle to the worklet service
Returns:
the tree, if found for the specification/task/rule-type combination
Throws:
IOException - if the service can't be reached

getRdrTree

public String getRdrTree(String processName,
                         String taskID,
                         RuleType rType,
                         String handle)
                  throws IOException
Gets a copy of a particular rule tree

Parameters:
processName - the process identifier, or unique ruleset name
taskID - the task identifier (may be null for case-level rule types)
rType - the type of rule tree to get the node from
handle - a current sessionhandle to the worklet service
Returns:
the tree, if found for the process/task/rule-type combination
Throws:
IOException - if the service can't be reached

getRdrSet

public String getRdrSet(YSpecificationID specID,
                        String handle)
                 throws IOException
Gets a copy of a particular rule set

Parameters:
specID - the specification identifier
handle - a current sessionhandle to the worklet service
Returns:
the rule set, if found for the specification
Throws:
IOException - if the service can't be reached

getRdrSet

public String getRdrSet(String processName,
                        String handle)
                 throws IOException
Gets a copy of a particular rule set

Parameters:
processName - the process identifier, or unique ruleset name
handle - a current sessionhandle to the worklet service
Returns:
the rule set, if found for the process
Throws:
IOException - if the service can't be reached


Copyright © 2004-2012 The YAWL Foundation.