org.yawlfoundation.yawl.worklet
Class WorkletService

java.lang.Object
  extended by org.yawlfoundation.yawl.engine.interfce.interfaceB.InterfaceBWebsideController
      extended by org.yawlfoundation.yawl.worklet.WorkletService
Direct Known Subclasses:
ExceptionService

public class WorkletService
extends InterfaceBWebsideController

This class and its support classes represent an implementation for YAWL of the Worklet paradigm. The WorkletService class is the main class for the selection and exception handling processes. For selection, it receives an enabled workitem from the engine and attempts to substitute it with a worklet.


Field Summary
protected  DBManager _dbMgr
           
protected  String _engineURI
           
protected  List<SpecificationData> _loadedSpecs
           
protected  boolean _persisting
           
protected  Rdr _rdr
           
protected  WorkletEventServer _server
           
protected  String _sessionHandle
           
protected  String _workletURI
           
 
Fields inherited from class org.yawlfoundation.yawl.engine.interfce.interfaceB.InterfaceBWebsideController
_ibCache, _interfaceBClient, _logger, _report, engineLogonName, engineLogonPassword, XSD_ANYURI_TYPE, XSD_NAMESPACE, XSD_NCNAME_TYPE, XSD_STRINGTYPE
 
Constructor Summary
WorkletService()
          the constructor
 
Method Summary
 void addAdministrationTask(String caseID, String title, String scenario, String process, int taskType)
          add case-level admin task (called from jsp)
 void addAdministrationTask(String caseID, String itemID, String title, String scenario, String process, int taskType)
          add item-level admin task (called from jsp)
protected  boolean cancelWorkletList(WorkletRecord wr)
          Cancels each of the worklets listed in the wr as running
protected  void checkOutChildren(CheckedOutItem coi)
          Checks out all the child workitems of the parent item specified
protected  CheckedOutItem checkOutParentItem(WorkItemRecord wir)
          checks out the parent enabled workitem
protected  boolean checkOutWorkItem(WorkItemRecord wir)
          Check the workitem out of the engine
 void completeAdminTask(String adminTaskID)
          marks the specified task as completed (removes it from list of tasks)
 void completeInitialisation()
          completes the initialisation of the service load-up (mainly persistence) called from servlet WorkletGateway after contexts are loaded
protected  boolean connected()
          Checks if there is a connection to the engine, and if there isn't, attempts to connect
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          displays a web page describing the service
 AdministrationTask getAdminTask(String id)
          returns the admin task with the id specified
 List getAdminTaskTitles()
          returns complete list of titles of all outstanding adimn tasks
 List getAllAdminTasksAsList()
          returns complete list of all outstanding adimn tasks
 WorkItemRecord getEngineStoredWorkItem(WorkItemRecord wir)
           
static WorkletService getInstance()
           
 Rdr getRdrInterface()
           
 WorkletEventServer getServer()
           
protected  RdrTree getTree(YSpecificationID specID, String taskID, RuleType treeType)
          returns the rule tree (if any) for the parameters passed
protected  String getWorkletFileName(String workletName)
           
protected  YSpecificationID getWorkletSpecID(String workletFileName)
           
 void handleCancelledCaseEvent(String caseID)
          Receives notification from the engine that an active case has been cancelled.
 void handleCancelledWorkItemEvent(WorkItemRecord workItemRecord)
          Handles a message from the engine that a workitem has been cancelled (see InterfaceBWebsideController for more details) In this case, it cancels any worklet(s) running in place of the workitem.
 void handleCompleteCaseEvent(String caseID, String casedata)
          Handles a message from the engine that a (worklet) case has completed (see InterfaceBWebsideController for more details).
 void handleEnabledWorkItemEvent(WorkItemRecord workItemRecord)
          Handles a message from the engine that a workitem has been enabled (see InterfaceBWebsideController for more details) In this case, it either starts a worklet substitution process, or, if the workitem denotes the end of a worklet case, it completes the substitution process by checking the original workitem back into the engine.
 void handleEngineInitialisationCompletedEvent()
          Receives notification from the engine that it has finished startup initialisation and is now in a running state.
 void initEngineURI(String uri)
           
 boolean isAdminSession(String sessionHandle)
          returns true if the session specified is an admin session
 boolean isExceptionServiceEnabled()
           
 boolean isWorkletCase(String caseID)
          returns true if case specified was launched by the worklet service
protected  String launchWorklet(WorkletRecord wr, String wName, YSpecificationID specID, boolean setObserver)
          Starts a worklet case executing in the engine
protected  boolean launchWorkletList(WorkletRecord wr, String list)
          Launches each of the worklets listed in the wr for starting
 void loadTree(YSpecificationID specID)
          loads the rule set for a spec (if not already loaded)
 void refreshRuleSet(YSpecificationID specID)
          Reloads the rule set from file (after a rule update) for the spec passed
protected  void registerExceptionService(ExceptionService es)
          allows the Exception Service to register an instance of itself
 String replaceWorklet(String itemid)
          Replaces a running worklet case with another worklet case after an amendment to the ruleset for this task.
 void setExceptionServiceEnabled(boolean enable)
           
protected  void setWorkletURI()
           
 void shutdown()
           
protected  org.jdom.Element updateDataList(org.jdom.Element in, org.jdom.Element out)
          updates the input datalist with the changed data in the output datalist
protected  boolean uploadWorklet(YSpecificationID specID, String fileName, String workletName)
          Uploads a worklet specification into the engine
 
Methods inherited from class org.yawlfoundation.yawl.engine.interfce.interfaceB.InterfaceBWebsideController
checkConnection, checkInWorkItem, checkInWorkItem, checkInWorkItem, checkOut, checkOutAllInstancesOfThisTask, connect, describeRequiredParams, destroy, getAuthenticationConfig, getCachedWorkItem, getChildren, getEngineStoredWorkItem, getIBCache, getModel, getResourcingSpecs, getSpecificationData, getSpecificationData, getSpecificationPrototypesList, getTaskInformation, getTaskInformation, handleCaseResumedEvent, handleCaseSuspendedEvent, handleCaseSuspendingEvent, handleStartCaseEvent, handleTimerExpiryEvent, handleWorkItemStatusChangeEvent, logContactError, prepareReplyRootElement, setEngineLogonName, setEngineLogonPassword, setRemoteAuthenticationDetails, setUpInterfaceBClient, successful
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sessionHandle

protected String _sessionHandle

_engineURI

protected String _engineURI

_workletURI

protected String _workletURI

_loadedSpecs

protected List<SpecificationData> _loadedSpecs

_persisting

protected boolean _persisting

_dbMgr

protected DBManager _dbMgr

_server

protected WorkletEventServer _server

_rdr

protected Rdr _rdr
Constructor Detail

WorkletService

public WorkletService()
the constructor

Method Detail

getInstance

public static WorkletService getInstance()
Returns:
a reference to the current WorkletService instance

registerExceptionService

protected void registerExceptionService(ExceptionService es)
allows the Exception Service to register an instance of itself


initEngineURI

public void initEngineURI(String uri)

setWorkletURI

protected void setWorkletURI()

setExceptionServiceEnabled

public void setExceptionServiceEnabled(boolean enable)

isExceptionServiceEnabled

public boolean isExceptionServiceEnabled()

getServer

public WorkletEventServer getServer()

getRdrInterface

public Rdr getRdrInterface()

completeInitialisation

public void completeInitialisation()
completes the initialisation of the service load-up (mainly persistence) called from servlet WorkletGateway after contexts are loaded


shutdown

public void shutdown()

handleEnabledWorkItemEvent

public void handleEnabledWorkItemEvent(WorkItemRecord workItemRecord)
Handles a message from the engine that a workitem has been enabled (see InterfaceBWebsideController for more details) In this case, it either starts a worklet substitution process, or, if the workitem denotes the end of a worklet case, it completes the substitution process by checking the original workitem back into the engine.

Specified by:
handleEnabledWorkItemEvent in class InterfaceBWebsideController
Parameters:
workItemRecord - - a record describing the enabled workitem

handleCancelledWorkItemEvent

public void handleCancelledWorkItemEvent(WorkItemRecord workItemRecord)
Handles a message from the engine that a workitem has been cancelled (see InterfaceBWebsideController for more details) In this case, it cancels any worklet(s) running in place of the workitem. Only deals with child workitems currently checked out - not interested in workitems that haven't been handled by the service, or parent workitems, since handling all the children takes care of the parent

Specified by:
handleCancelledWorkItemEvent in class InterfaceBWebsideController
Parameters:
workItemRecord - - a record describing the cancelled workitem

handleCompleteCaseEvent

public void handleCompleteCaseEvent(String caseID,
                                    String casedata)
Handles a message from the engine that a (worklet) case has completed (see InterfaceBWebsideController for more details). Only those services that register as an 'observer' for the case will receive these events. All worklets launched (through launchCase()) register as an observer.

Overrides:
handleCompleteCaseEvent in class InterfaceBWebsideController
Parameters:
caseID - - the id of the completed case
casedata - - an (XML) string containing the output data for the case

handleCancelledCaseEvent

public void handleCancelledCaseEvent(String caseID)
Description copied from class: InterfaceBWebsideController
Receives notification from the engine that an active case has been cancelled. Override this method to take any necessary action.

Overrides:
handleCancelledCaseEvent in class InterfaceBWebsideController
Parameters:
caseID - the id of the case that has been cancelled

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws IOException,
                  javax.servlet.ServletException
displays a web page describing the service

Overrides:
doGet in class InterfaceBWebsideController
Parameters:
request - the request
response - the response.
Throws:
IOException - if an error is detected when the servlet handles the GET request
javax.servlet.ServletException - if the request for the GET could not be handled

handleEngineInitialisationCompletedEvent

public void handleEngineInitialisationCompletedEvent()
Description copied from class: InterfaceBWebsideController
Receives notification from the engine that it has finished startup initialisation and is now in a running state. Override this method to handle final service initialisation tasks that require a running engine

Overrides:
handleEngineInitialisationCompletedEvent in class InterfaceBWebsideController

checkOutParentItem

protected CheckedOutItem checkOutParentItem(WorkItemRecord wir)
checks out the parent enabled workitem


checkOutChildren

protected void checkOutChildren(CheckedOutItem coi)
Checks out all the child workitems of the parent item specified

Parameters:
coi - - the parent's data object

checkOutWorkItem

protected boolean checkOutWorkItem(WorkItemRecord wir)
Check the workitem out of the engine

Parameters:
wir - - the workitem to check out
Returns:
true if checkout was successful

uploadWorklet

protected boolean uploadWorklet(YSpecificationID specID,
                                String fileName,
                                String workletName)
Uploads a worklet specification into the engine

Parameters:
workletName - - the name of the worklet specification to upload
Returns:
true if upload is successful or spec is already loaded

getWorkletFileName

protected String getWorkletFileName(String workletName)

getWorkletSpecID

protected YSpecificationID getWorkletSpecID(String workletFileName)

launchWorkletList

protected boolean launchWorkletList(WorkletRecord wr,
                                    String list)
Launches each of the worklets listed in the wr for starting

Parameters:
wr - - the worklet record containing the list of worklets to launch
list - - a comma separated list of worklet names
Returns:
true if *any* of the worklets are successfully launched

cancelWorkletList

protected boolean cancelWorkletList(WorkletRecord wr)
Cancels each of the worklets listed in the wr as running

Parameters:
wr - - the worklet record containing the list of worklets to cancel
Returns:
true if *any* of the worklets are successfully cancelled

launchWorklet

protected String launchWorklet(WorkletRecord wr,
                               String wName,
                               YSpecificationID specID,
                               boolean setObserver)
Starts a worklet case executing in the engine

Parameters:
wr - - the record of the CheckedOutChildItem or the HandlerRunner to start the worklet for
Returns:
- the case id of the started worklet case

replaceWorklet

public String replaceWorklet(String itemid)
Replaces a running worklet case with another worklet case after an amendment to the ruleset for this task. Called by WorkletGateway after a call from the RdrEditor that the ruleset has been updated.

Parameters:
itemid - - the id and type of the orginal checked out case/workitem
Returns:
a string of messages decribing the success or otherwise of the process

updateDataList

protected org.jdom.Element updateDataList(org.jdom.Element in,
                                          org.jdom.Element out)
updates the input datalist with the changed data in the output datalist

Parameters:
in - - the JDOM Element containing the input params
out - - the JDOM Element containing the output params
Returns:
a JDOM Element with the data updated

getTree

protected RdrTree getTree(YSpecificationID specID,
                          String taskID,
                          RuleType treeType)
returns the rule tree (if any) for the parameters passed


refreshRuleSet

public void refreshRuleSet(YSpecificationID specID)
Reloads the rule set from file (after a rule update) for the spec passed


loadTree

public void loadTree(YSpecificationID specID)
loads the rule set for a spec (if not already loaded)


getEngineStoredWorkItem

public WorkItemRecord getEngineStoredWorkItem(WorkItemRecord wir)

isWorkletCase

public boolean isWorkletCase(String caseID)
returns true if case specified was launched by the worklet service


isAdminSession

public boolean isAdminSession(String sessionHandle)
returns true if the session specified is an admin session


connected

protected boolean connected()
Checks if there is a connection to the engine, and if there isn't, attempts to connect

Returns:
true if connected to the engine

addAdministrationTask

public void addAdministrationTask(String caseID,
                                  String title,
                                  String scenario,
                                  String process,
                                  int taskType)
add case-level admin task (called from jsp)


addAdministrationTask

public void addAdministrationTask(String caseID,
                                  String itemID,
                                  String title,
                                  String scenario,
                                  String process,
                                  int taskType)
add item-level admin task (called from jsp)


getAdminTaskTitles

public List getAdminTaskTitles()
returns complete list of titles of all outstanding adimn tasks


completeAdminTask

public void completeAdminTask(String adminTaskID)
marks the specified task as completed (removes it from list of tasks)


getAllAdminTasksAsList

public List getAllAdminTasksAsList()
returns complete list of all outstanding adimn tasks


getAdminTask

public AdministrationTask getAdminTask(String id)
returns the admin task with the id specified



Copyright © 2004-2012 The YAWL Foundation.