Hi
i building a custom service and i need help
how can i count the number of allocated and started tasks of user and convert the result to int

Michael Adams

Thu, 04/23/2015 - 01:30

Like this:

public int getItemCount(String userid) {
String rsURI = "http://localhost:8080/resourceService/workqueuegateway";
WorkQueueGatewayClientAdapter adapter = new WorkQueueGatewayClientAdapter(rsURI);
try {
String handle = adapter.connect("admin", "YAWL");
Participant p = adapter.getParticipantFromUserID(userid, handle);
if (p != null) {
Set<WorkItemRecord> allocatedSet =
adapter.getQueuedWorkItems(p.getID(), WorkQueue.ALLOCATED, handle);
Set<WorkItemRecord> startedSet =
adapter.getQueuedWorkItems(p.getID(), WorkQueue.STARTED, handle);
if (! (allocatedSet == null || startedSet == null)) {
return allocatedSet.size() + startedSet.size();
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return -1; // to indicate error
}