Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
issue #327
  • Loading branch information
rsoika committed Oct 31, 2017
1 parent a4ec28c commit 318c235
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ public WorkflowKernel(final WorkflowContext actx) {
ruleEngine = new RuleEngine();
}

/**
* This method returns new SplitWorkitems evaluated during the last processing
* life-cycle.
*
* @return
*/
public List<ItemCollection> getSplitWorkitems() {
return splitWorkitems;
}

/**
* This method generates an immutable universally unique identifier (UUID). A
* UUID represents a 128-bit value.
Expand Down Expand Up @@ -286,7 +276,7 @@ public ItemCollection process(final ItemCollection workitem) throws PluginExcept
// load event...
ItemCollection event = loadEvent(documentResult);
documentResult = processEvent(documentResult, event);
documentResult = updateActivityList(documentResult);
documentResult = updateEventList(documentResult);
}

// set $lastEventDate
Expand Down Expand Up @@ -342,12 +332,22 @@ public ItemCollection findNextTask(ItemCollection documentContext, ItemCollectio
return itemColNextTask;
}

/**
* This method returns new SplitWorkitems evaluated during the last processing
* life-cycle.
*
* @return
*/
public List<ItemCollection> getSplitWorkitems() {
return splitWorkitems;
}

/**
* This method controls the Evnet-Chain. If the attribute $activityidlist has
* more valid ActivityIDs the next activiytID will be loaded into $activity.
*
**/
private ItemCollection updateActivityList(final ItemCollection documentContext) {
private ItemCollection updateEventList(final ItemCollection documentContext) {
ItemCollection documentResult = documentContext;

// is $activityid already provided?
Expand Down
80 changes: 48 additions & 32 deletions src/site/markdown/engine/workflowservice.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# The WorkflowService
The WorkflowService is the Java EE implementation of the [WorkflowManager interface](../core/workflowmanager.html) of the core API. This service component allows to process, update and lookup workItems in the Imixs-Workflow engine.
The WorkflowService is the Java EE implementation of the [WorkflowManager interface](../core/workflowmanager.html) from the core API. This service component allows to process, update and lookup workItems in the Imixs-Workflow engine.

Before a workitem can be processed by the WorkflowService a process model need to be defined and deployed into the workflow engine. See the section [Imixs-BPMN Modeler](../modelling/index.html) for details about how to create a model and upload it into the workflow server. The following example shows how a workitem can be processed using the WorkflowService component. A workitem must provide at least the following properties:
## How to Process a Workitem
Before a workitem can be processed by the WorkflowService, a process model need to be defined and deployed together with the workflow engine. See the section [Imixs-BPMN Modeler](../modelling/index.html) for details about how to create a model and upload it into the workflow server. The following example shows how a workitem can be processed using the WorkflowService component. A workitem must provide at least the following properties:

* $ModelVersion
* $ProcessID
Expand All @@ -19,35 +20,41 @@ These properties are defining the workflow activity which should be processed by
workitem.replaceItemValue("txtTitel", "My first workflow example");
// set workflow status based on a supported model
workitem.replaceItemValue("$modelVersion", "1.0.0");
workitem.replaceItemValue("$processID", 10);
workitem.replaceItemValue("$ActivityID", 10);
workitem.replaceItemValue(WorkflowKernel.MODELVERSION, "1.0.0");
workitem.replaceItemValue(WorkflowKernel.PROCESSID, 10);
workitem.replaceItemValue(WorkflowKernel.ACTIVITYID, 10);
// process the workitem
workitem=workflowService.processWorkItem(workitem);

After a new workitem is process the first time, it is under the control of the WorkflowManager. To get the current list of all workitems created by the current user, the method() getWorkListByCreator can be called:


After a new workitem is process the first time, it is under the control of the _WorkflowService_.

## Worklist Methods

To get the current list of all workitems, the _WorkflowService_ provides a set of methods. These methods provide different ways to read a worklist by categories. The _WorkflowService_ returns only workitems in a result set if the user has read access. If a workitem is not accessible for the user, this workitem will not be included in the result-set. All result-sets can be ordered by modified or creation date.


### getWorkListByCreator

The method getWorkListByCreator can be called to read the list of all workitems created by a specific user:

@EJB
org.imixs.workflow.jee.ejb.WorkflowService workflowService;
//...
Collection<ItemCollection> worklist=workflowService.getWorkListByCreator(null,0,-1);
//...


To read the list of all workitems created by a specific user, the parameter username need to be specified:

Collection<ItemCollection> worklist=workflowService.getWorkListByCreator('manfred',0,-1);
// get the first 10 workitem for the current user
Collection<ItemCollection> worklist=workflowService.getWorkListByCreator(null,10,0);
// get list for a named user
Collection<ItemCollection> worklist=workflowService.getWorkListByCreator('manfred',10,0);

The WorkflowManager provides a paging mechanism to browse through long result-sets. The following example
shows how to get 5 workitems starting at the tenth record
shows how to get 5 workitems from the tenth page

Collection<ItemCollection> worklist=workflowService.getWorkListByCreator(null,10,5);
Collection<ItemCollection> worklist=workflowService.getWorkListByCreator(null,5,10);


##Worklist methods
The following methods provide different ways to read a worklist by categories. The workflowService returns only workitems in a worklist if the user has read access. If a workitem is not access able for the user this workitem will not be included in the result-set. All result-sets can be ordered by modified or creation date.

###getWorkList
Returns a collection of workitems for the current user. A Workitem belongs to a user or role if the user has at least read write access to this workitem.
### getWorkList
The method returns a collection of workitems for the current user. A Workitem belongs to a user or role if the user has at least read write access to this workitem.

Collection<ItemCollection> list=workflowService.getWorkList();
//...
Expand All @@ -60,9 +67,9 @@ by this method. The type of a workitem is defined by the workitem property 'type
type,WorkflowService.SORT_ORDER_CREATED_DESC);
//...

###getWorkListByAuthor
### getWorkListByAuthor

Returns a collection of workitems belonging to a specified user. This filter can be set to
The method returns a collection of workitems belonging to a specified user. This filter can be set to
a username or a user role defined by the application. A Workitem belgons to a user or role if the user has write access to this workitem. So the method returns workitems which can be
processed by the user.

Expand All @@ -73,8 +80,8 @@ Returns a collection of workitems belonging to a specified user. This filter can
//...


###getWorkListByGroup
Returns a collection of workitems belonging to a specified workflow group. The workflow group is defined by the workflow model and includes all process entities defined by
### getWorkListByGroup
The method returns a collection of workitems belonging to a specified workflow group. The workflow group is defined by the workflow model and includes all process entities defined by
a business process

String type="workitem";
Expand All @@ -84,18 +91,18 @@ Returns a collection of workitems belonging to a specified workflow group. The
//...


###getWorkListByProcessID
### getWorkListByProcessID

Returns a collection of workitems belonging to a specified $processID defined by the workflow model.
The method returns a collection of workitems belonging to a specified $processID defined by the workflow model.

String type="workitem";
Collection<ItemCollection> list=workflowService.getWorkListByProcessID(2100,0,-1,
type,WorkflowService.SORT_ORDER_CREATED_DESC);
//...


###getWorkListByOwner
Returns a collection of workitems containing a namOwner property belonging to a specified username. The namOwner property is typical controlled by the OwnerPlugin using the Imixs Workflow Modeler
### getWorkListByOwner
The method returns a collection of workitems containing a namOwner property belonging to a specified username. The namOwner property is typical controlled by the OwnerPlugin using the Imixs Workflow Modeler

String type="workitem";
String user="Manfred"
Expand All @@ -104,22 +111,22 @@ Returns a collection of workitems containing a namOwner property belonging to a
//...

###getWorkListByWriteAccess
Returns a collection of workitems where the current user has at least writeAccess. This means the either the username or one of the user roles is contained in the $writeaccess property of each workitem returned by the method.
The method returns a collection of workitems where the current user has at least writeAccess. This means the either the username or one of the user roles is contained in the $writeaccess property of each workitem returned by the method.

String type="workitem";
Collection<ItemCollection> list=workflowService.getWorkListByWriteAccess(0,-1,
type,WorkflowService.SORT_ORDER_CREATED_DESC);
//...

###getWorkListByRef
Returns a collection of workitems belonging to a specified workitem identified by the attribute $UniqueIDRef.
The method returns a collection of workitems belonging to a specified workitem identified by the attribute $UniqueIDRef.

String type="workitem";
Collection<ItemCollection> list=workflowService.getWorkListByRef(refID,0,-1,
type,WorkflowService.SORT_ORDER_CREATED_DESC);
//...

##Model Version Management
## Model Version Management
Each time a running process instance is updated, the WorkflowService compares the internal model version with the model versions provided by the model repository. In case the current model version is no longer available the WorkflowService automatically upgrades an active process instance to the latest version in the repository. Therefore the engine verifies the task ID (numprocessid) and the process name (txtworkflowgroup) with the corresponding models. This mechanism allows to upgrade process instances at run time to a newer version.

It is also possible to handle different versions of a model at the same time. In this case each process instance is processed by the model version from which it was started.
Expand Down Expand Up @@ -147,4 +154,13 @@ This event can be consumed by another Session Bean or managed bean implementing
System.out.println("Received ProcessingEvent Type = " + processingEvent.getType());
}
}


## Evaluate the Next Task Element

The _WorkflowService_ provides the method 'evalNextTask' to evaluate the next BPMN task element based on a Event element. This method can be called by Plugins to get the outcome of the current processing step. If the event did not point to a new task, the current task will be returned.
The method supports 'conditional-events' as well as 'split-events'. A conditional-event contains the attribute 'keyExclusiveConditions' defining conditional targets (tasks) or adds conditional follow up events
A split-event contains the attribute 'keySplitConditions' defining the target for the current master version (condition evaluates to 'true'). See also the section [How to Model...](../modelling/howto.html)


// get next process entity
nextTask = workflowService.evalNextTask(adocumentContext, adocumentActivity);

0 comments on commit 318c235

Please sign in to comment.