Class WorkflowService
- All Implemented Interfaces:
WorkflowContext
,WorkflowManager
- Author:
- rsoika
-
Field Summary
Modifier and TypeFieldDescriptionprotected jakarta.enterprise.inject.Instance<Adapter>
static final String
static final String
static final String
static final String
protected jakarta.enterprise.event.Event<ProcessingEvent>
static final String
static final int
static final int
static final int
static final int
protected jakarta.enterprise.event.Event<TextEvent>
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadaptText
(String text, ItemCollection documentContext) The method adaptText can be called to replace predefined xml tags included in a text with custom values.adaptTextList
(String text, ItemCollection documentContext) The method adaptTextList can be called to replace a text with custom values.evalNextTask
(ItemCollection workitem) The method evaluates the next task for a process instance (workitem) based on the current model definition.evalWorkflowResult
(ItemCollection event, String tag, ItemCollection documentContext) The method evaluates the WorkflowResult for a given BPMN event and returns a ItemColleciton containing all item values of a specified tag name.evalWorkflowResult
(ItemCollection event, String xmlTag, ItemCollection documentContext, boolean resolveItemValues) The method evaluates the WorkflowResult for a given BPMN event and returns a ItemColleciton containing all item values of a specified xml tag.evalWorkflowResult
(ItemCollection event, ItemCollection documentContext) Deprecated.evalWorkflowResult
(ItemCollection event, ItemCollection documentContext, boolean resolveItemValues) Deprecated.evalWorkflowResultXML
(ItemCollection event, String xmlTag, String name, ItemCollection documentContext, boolean resolveItemValues) The method evaluates a XML tag from the WorkflowResult for a given BPMN event.Returns an instance of the DocumentService EJB.getEvents
(ItemCollection workitem) This returns a list of workflow events assigned to a given workitem.This Method returns the modelManager Instance.Returns an instance of the ReportService EJB.jakarta.ejb.SessionContext
Returns an instance of the EJB session context.Obtain the java.security.Principal that identifies the caller and returns the name of this principal.This method returns a list of user names, roles and application groups the caller belongs to.getWorkItem
(String uniqueid) This method loads a Workitem with the corresponding uniqueid.getWorkListByAuthor
(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems for which the specified user has explicit write permission.getWorkListByCreator
(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems created by a specified user ($Creator).getWorkListByGroup
(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a list of workitems filtered by the field $workflowgroup the method supports still also the deprecated field "txtworkflowgroup"getWorkListByOwner
(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems containing a '$owner' item belonging to a specified username.getWorkListByProcessID
(int aid, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems belonging to a specified $taskID defined by the workflow model.getWorkListByRef
(String aref) Returns a collection of all workitems belonging to a specified workitem identified by the attribute $UniqueIDRef.getWorkListByRef
(String aref, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems belonging to a specified workitem identified by the attribute $UniqueIDRef.getWorkListByWriteAccess
(String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems where the current user has a writeAccess.boolean
isUserInRole
(String rolename) Test if the caller has a given security role.processWorkItem
(ItemCollection workitem) This method processes a workItem by the WorkflowKernel and saves the workitem after the processing was finished successful.processWorkItem
(ItemCollection workitem, int eventID) This method processes a workItem based on a given event.processWorkItem
(ItemCollection workitem, ItemCollection event) This method processes a workItem based on a given event.This method processes a workitem in a new transaction.protected void
registerAdapters
(WorkflowKernel workflowkernel) protected void
registerPlugins
(WorkflowKernel workflowkernel, org.openbpmn.bpmn.BPMNModel model) This method register all plugin classes listed in the model profilevoid
removeWorkItem
(ItemCollection aworkitem) The method removes a Workitem form the persistence unit managed by the WorkflowManager implementation.protected void
updateMetadata
(ItemCollection workitem) This method updates the workitem metadata.
-
Field Details
-
UNIQUEIDREF
- See Also:
-
READACCESS
- See Also:
-
WRITEACCESS
- See Also:
-
PARTICIPANTS
- See Also:
-
DEFAULT_TYPE
- See Also:
-
SORT_ORDER_CREATED_DESC
public static final int SORT_ORDER_CREATED_DESC- See Also:
-
SORT_ORDER_CREATED_ASC
public static final int SORT_ORDER_CREATED_ASC- See Also:
-
SORT_ORDER_MODIFIED_DESC
public static final int SORT_ORDER_MODIFIED_DESC- See Also:
-
SORT_ORDER_MODIFIED_ASC
public static final int SORT_ORDER_MODIFIED_ASC- See Also:
-
INVALID_ITEMVALUE_FORMAT
- See Also:
-
INVALID_TAG_FORMAT
- See Also:
-
adapters
-
processingEvents
-
textEvents
-
-
Constructor Details
-
WorkflowService
public WorkflowService()
-
-
Method Details
-
getWorkItem
This method loads a Workitem with the corresponding uniqueid.- Specified by:
getWorkItem
in interfaceWorkflowManager
- Returns:
- WorkItem
-
getWorkListByOwner
public List<ItemCollection> getWorkListByOwner(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems containing a '$owner' item belonging to a specified username. The '$owner' item can be controlled by the plug-inorg.imixs.workflow.plugins.OwnerPlugin
- Parameters:
name
- = username for itme '$owner' - if null current username will be usedpageSize
- = optional page count (default 20)pageIndex
- = optional start positiontype
- = defines the type property of the workitems to be returnd. can be nullsortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
- List of workitems
-
getWorkListByAuthor
public List<ItemCollection> getWorkListByAuthor(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems for which the specified user has explicit write permission. The name is a username or role contained in the $WriteAccess attribute of the workItem. The method returns only workitems the call has sufficient read access for.- Parameters:
name
- = username or role contained in $writeAccess - if null current username will be usedpageSize
- = optional page count (default 20)pageIndex
- = optional start positiontype
- = defines the type property of the workitems to be returned. can be nullsortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
- List of workitems
-
getWorkListByCreator
public List<ItemCollection> getWorkListByCreator(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems created by a specified user ($Creator). The behaivor is simmilar to the method getWorkList.- Parameters:
name
- = username for property $Creator - if null current username will be usedpageSize
- = optional page count (default 20)pageIndex
- = optional start positiontype
- = defines the type property of the workitems to be returnd. can be nullsortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
- List of workitems
-
getWorkListByWriteAccess
public List<ItemCollection> getWorkListByWriteAccess(String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems where the current user has a writeAccess. This means that at least one of the userNames is contained in the $writeaccess property.- Parameters:
pageSize
- = optional page count (default 20)pageIndex
- = optional start positiontype
- = defines the type property of the workitems to be returnd. can be nullsortorder
- = defines sortorder (SORT_ORDER_CREATED_DESC = 0 SORT_ORDER_CREATED_ASC = 1 SORT_ORDER_MODIFIED_DESC = 2 SORT_ORDER_MODIFIED_ASC = 3)sortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
- List of workitems
-
getWorkListByGroup
public List<ItemCollection> getWorkListByGroup(String name, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a list of workitems filtered by the field $workflowgroup the method supports still also the deprecated field "txtworkflowgroup"- Parameters:
name
-type
-pageSize
- = optional page count (default 20)pageIndex
- = optional start positionsortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
-
getWorkListByProcessID
public List<ItemCollection> getWorkListByProcessID(int aid, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems belonging to a specified $taskID defined by the workflow model. The behaivor is simmilar to the method getWorkList.- Parameters:
aID
- = $taskID for the workitems to be returned.pageSize
- = optional page count (default 20)pageIndex
- = optional start positiontype
- = defines the type property of the workitems to be returnd. can be nullsortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
- List of workitems
-
getWorkListByRef
public List<ItemCollection> getWorkListByRef(String aref, String type, int pageSize, int pageIndex, String sortBy, boolean sortReverse) Returns a collection of workitems belonging to a specified workitem identified by the attribute $UniqueIDRef. The behaivor of this Mehtod is simmilar to the method getWorkList.- Parameters:
aref
- A unique reference to another workitem inside a database *pageSize
- = optional page count (default 20)pageIndex
- = optional start positiontype
- = defines the type property of the workitems to be returnd. can be nullsortBy
- -optional field to sort the resultsortReverse
- - optional sort direction- Returns:
- List of workitems
-
getWorkListByRef
Returns a collection of all workitems belonging to a specified workitem identified by the attribute $UniqueIDRef.- Returns:
- List of workitems
-
getEvents
This returns a list of workflow events assigned to a given workitem. The method evaluates the events for the current $modelversion and $taskid. The result list is filtered by the properties 'keypublicresult' and 'keyRestrictedVisibility'.If the property keyRestrictedVisibility exits the method test if the current username is listed in one of the namefields.
If the current user is in the role 'org.imixs.ACCESSLEVEL.MANAGERACCESS' the property keyRestrictedVisibility will be ignored.
If the model version does not exist the model is resolved by regular expressions using the method findModelByWorkitem
If not model can be found or the $taskID is not defined by the model a ModelException is thrown.
- Parameters:
workitem
-- Returns:
- Throws:
ModelException
- if model is not found or task is not defined by the given model
-
processWorkItem
public ItemCollection processWorkItem(ItemCollection workitem) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException This method processes a workItem by the WorkflowKernel and saves the workitem after the processing was finished successful. The workitem have to provide at least the properties '$modelversion', '$taskid' and '$eventid'Before the method starts processing the workitem, the method load the current instance of the given workitem and compares the property $taskID. If it is not equal the method throws an ProcessingErrorException.
After the workitem was processed successful, the method verifies the property $workitemList. If this property holds a list of entities these entities will be saved and the property will be removed automatically.
The method provides a observer pattern for plugins to get called during the processing phase.
- Specified by:
processWorkItem
in interfaceWorkflowManager
- Parameters:
workitem
- - the workItem to be processed- Returns:
- updated version of the processed workItem
- Throws:
AccessDeniedException
- - thrown if the user has insufficient access to update the workItemProcessingErrorException
- - thrown if the workitem could not be processed by the workflowKernelPluginException
- - thrown if processing by a plugin failsModelException
-
processWorkItem
public ItemCollection processWorkItem(ItemCollection workitem, ItemCollection event) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException This method processes a workItem based on a given event.- Parameters:
workitem
- - the workItem to be processedevent
- - event object- Returns:
- updated version of the processed workItem
- Throws:
AccessDeniedException
- - thrown if the user has insufficient access to update the workItemProcessingErrorException
- - thrown if the workitem could not be processed by the workflowKernelPluginException
- - thrown if processing by a plugin failsModelException
- See Also:
-
ItemCollection processWorkItem(ItemCollection workitem)
-
processWorkItem
public ItemCollection processWorkItem(ItemCollection workitem, int eventID) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException This method processes a workItem based on a given event.- Parameters:
workitem
- - the workItem to be processedevent
- - event object- Returns:
- updated version of the processed workItem
- Throws:
AccessDeniedException
- - thrown if the user has insufficient access to update the workItemProcessingErrorException
- - thrown if the workitem could not be processed by the workflowKernelPluginException
- - thrown if processing by a plugin failsModelException
- See Also:
-
ItemCollection processWorkItem(ItemCollection workitem)
-
processWorkItemByNewTransaction
public ItemCollection processWorkItemByNewTransaction(ItemCollection workitem) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException This method processes a workitem in a new transaction. -
removeWorkItem
Description copied from interface:WorkflowManager
The method removes a Workitem form the persistence unit managed by the WorkflowManager implementation. The method throws an AccessDeniedException if the work item cannot be removed due to its state or user permissions.- Specified by:
removeWorkItem
in interfaceWorkflowManager
- Throws:
AccessDeniedException
-
getModelManager
This Method returns the modelManager Instance. The current ModelVersion is automatically updated during the Method updateProfileEntity which is called from the processWorktiem method.- Specified by:
getModelManager
in interfaceWorkflowContext
- Returns:
- ModelManager
-
getSessionContext
public jakarta.ejb.SessionContext getSessionContext()Returns an instance of the EJB session context.- Specified by:
getSessionContext
in interfaceWorkflowContext
- Returns:
-
getDocumentService
Returns an instance of the DocumentService EJB.- Returns:
-
getReportService
Returns an instance of the ReportService EJB.- Returns:
-
getUserName
Obtain the java.security.Principal that identifies the caller and returns the name of this principal.- Returns:
- the user name
-
isUserInRole
Test if the caller has a given security role.- Parameters:
rolename
-- Returns:
- true if user is in role
-
getUserNameList
This method returns a list of user names, roles and application groups the caller belongs to.- Returns:
-
adaptText
The method adaptText can be called to replace predefined xml tags included in a text with custom values. The method fires a CDI event to inform TextAdapterServices to parse and adapt a given text fragment.- Parameters:
text
-documentContext
-- Returns:
- Throws:
PluginException
-
adaptTextList
public List<String> adaptTextList(String text, ItemCollection documentContext) throws PluginException The method adaptTextList can be called to replace a text with custom values. The method fires a CDI event to inform TextAdapterServices to parse and adapt a given text fragment. The method expects a textList result.- Parameters:
text
-documentContext
-- Returns:
- Throws:
PluginException
-
evalWorkflowResult
public ItemCollection evalWorkflowResult(ItemCollection event, String xmlTag, ItemCollection documentContext, boolean resolveItemValues) throws PluginException The method evaluates the WorkflowResult for a given BPMN event and returns a ItemColleciton containing all item values of a specified xml tag. Each tag definition must contain at least a name attribute and may contain an optional list of additional attributes.The method generates a item for each content element and attribute value. e.g.:
<item name="comment" ignore="true">text</item>
This example will result in an ItemCollection with the attributes 'comment' with value 'text' and 'comment.ignore' with the value 'true'
Also embedded itemVaues can be resolved (resolveItemValues=true):
<somedata>ABC<itemvalue>$uniqueid</itemvalue></somedata>
This example will result in a new item 'somedata' with the $uniqueid prefixed with 'ABC'
- Parameters:
event
-xmlTag
- - XML tag to be evaluateddocumentContext
-resolveItemValues
- - if true, itemValue tags will be resolved.- Returns:
- eval itemCollection or null if no tags are contained in the workflow result.
- Throws:
PluginException
- if the xml structure is invalid
-
evalWorkflowResult
public ItemCollection evalWorkflowResult(ItemCollection event, String tag, ItemCollection documentContext) throws PluginException The method evaluates the WorkflowResult for a given BPMN event and returns a ItemColleciton containing all item values of a specified tag name. Each tag definition of a WorkflowResult contains a name and a optional list of additional attributes. The method generates a item for each content element and attribute value.
e.g.- text
will result in the attributes 'comment' with value 'text' and 'comment.ignore' with the value 'true'Also embedded itemVaues can be resolved (resolveItemValues=true):
<somedata>ABC<itemvalue>$uniqueid</itemvalue></somedata>
This example will result in a new item 'somedata' with the $uniqueid prefixed with 'ABC'
- Parameters:
event
-tag
- - tag to be evaluateddocumentContext
-- Returns:
- Throws:
PluginException
- See Also:
-
evalWorkflowResultXML
public List<ItemCollection> evalWorkflowResultXML(ItemCollection event, String xmlTag, String name, ItemCollection documentContext, boolean resolveItemValues) throws PluginException The method evaluates a XML tag from the WorkflowResult for a given BPMN event. The method returns a list of ItemCollecitons matching the given XML tag and name attribtue. A custom XML configuriaton may contain one or many XML tags with the same name. Each result ItemCollection holds the tag values of each XML tag. Example:<imixs-config name="CONFIG"> <textblock>....</textblock> <template>....</template> </imixs-config>
- Parameters:
event
-xmlTag
- - xml tag to be evaluatedname
- - value of the matching name attributedocumentContext
-resolveItemValues
- - if true, itemValue tags will be resolved.- Returns:
- list of ItemCollections
- Throws:
PluginException
- if the xml structure is invalid
-
evalWorkflowResult
@Deprecated public ItemCollection evalWorkflowResult(ItemCollection event, ItemCollection documentContext, boolean resolveItemValues) throws PluginException Deprecated.- Throws:
PluginException
-
evalWorkflowResult
@Deprecated public ItemCollection evalWorkflowResult(ItemCollection event, ItemCollection documentContext) throws PluginException Deprecated.- Throws:
PluginException
-
evalNextTask
The method evaluates the next task for a process instance (workitem) based on the current model definition. A Workitem must at least provide the properties $TASKID and $EVENTID.During the evaluation life-cycle more than one events can be evaluated. This depends on the model definition which can define follow-up-events, split-events and conditional events.
The method did not persist the process instance or execute any plugin or adapter classes.
- Returns:
- Task entity
- Throws:
PluginException
ModelException
-
registerPlugins
protected void registerPlugins(WorkflowKernel workflowkernel, org.openbpmn.bpmn.BPMNModel model) throws PluginException, ModelException This method register all plugin classes listed in the model profile- Throws:
PluginException
ModelException
-
registerAdapters
-
updateMetadata
This method updates the workitem metadata. The following items will be updated:- $creator
- $editor
- $lasteditor
- $participants
The method also migrates deprected items.
- Parameters:
workitem
-
-