Bug 1048346 - Add lookup of WorkItem from WorkItemInfo id or List<WorkItem> from ProcessInstance id
Summary: Add lookup of WorkItem from WorkItemInfo id or List<WorkItem> from ProcessIns...
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: All
OS: All
Target Milestone: ---
: ---
Assignee: Kris Verlaenen
QA Contact: Radovan Synek
Depends On:
TreeView+ depends on / blocked
Reported: 2014-01-03 19:13 UTC by Adam Baxter
Modified: 2020-03-27 19:35 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2020-03-27 19:35:59 UTC
Type: Feature Request

Attachments (Terms of Use)

Description Adam Baxter 2014-01-03 19:13:31 UTC
Description of problem:

Request additional functionality to access a WorkItemInfo given its id.
Same for a List<WorkItemInfo> given its Process Instance id. 

The only way for this functionality right now is to query the database manually.

Version-Release number of selected component (if applicable):

Comment 2 Adam Baxter 2014-01-03 19:28:40 UTC
In particular, we are running the following queries:

Query query = entityManager.createQuery("from WorkItemInfo wii where wii.workItemId = :workItemId");
query.setParameter("workItemId", id);
WorkItemInfo info = (WorkItemInfo)query.getSingleResult();

final Long pendingStatus = new Long(WorkItem.PENDING);
Query query = entityManager.createQuery("from WorkItemInfo wii where wii.processInstanceId = :processInstanceId and wii.state = :state");
query.setParameter("processInstanceId",  processInstanceId);
query.setParameter("state", pendingStatus);
List<WorkItemInfo> infos = (List)query.getResultList();

Comment 3 Marek Baluch 2014-01-03 19:46:09 UTC
As this is a new feature I'm setting severity to low.

Comment 4 Kris Verlaenen 2014-01-04 01:59:32 UTC
Adam, could you elaborate why you would need access to the WorkItemInfo object?  This is considered an internal persistence Object and should only be accessed with caution (similar to for example ProcessInstanceInfo).

Note that you could get a WorkItem using:
((org.drools.core.process.instance.WorkItemManager) ksession.getWorkItemManager()).getWorkItem(id)

Comment 5 Adam Baxter 2014-01-06 15:23:37 UTC
Hi Kris,

Our goal is to provide the WorkItem when the only information we've been provided is the WorkItem Id. In this code we do not know the ProcessInstance Id at the start. We need that to get the ksession.

Our code looks like:

1) Get WorkItemInfo matching the provided WorkItem id.
2) Get the ProcessInstance Id from the WorkItemInfo
3) Get the KieSession given the ProcessInstance Id
4) Get the WorkItemManager from the KieSession
5) return the WorkItem from the WorkItemManager using the originally provided id

Note You need to log in before you can comment on or make changes to this bug.