Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/API/JavaAPICookbook/QueryingWorklists

Introduction

This article will provide examples/usage of different Query API's. It is assumed that you are familiar with the modeling the processes with Stardust.

Scenario 1:

   This API usage will provide you the User and User group related information, precisely which users belong to which user groups.
UserQuery userQuery = new UserQuery();
UserGroupQuery userGroupQuery = new UserGroupQuery();
UserGroups usergroups = queryService.getAllUserGroups(userGroupQuery);
 
for (UserGroup userGroup : usergroups) {
	System.out.println("userGroup****** " + userGroup.getId());
	UserQuery userQuery1 = userQuery.findAllForUserGroup(userGroup.getId());
	Users existingusers = queryService.getAllUsers(userQuery1);
	System.out.println("existingusers.getSize****** " + existingusers.getSize());
 
	for (User user : existingusers) {
	     System.out.println("user" + user.getId());
	}
 
}

Scenario 2:

   This API usage will provide you information of a use case where you need to find the number of AIs currently in the
worklist of a particular user.


ActivityInstanceQuery activityQuery = new ActivityInstanceQuery();
 
FilterOrTerm orFilter = activityQuery.getFilter().addOrTerm();
			orFilter.add(PerformingUserFilter.CURRENT_USER);
 
ActivityInstances activeInstances = queryService.getAllActivityInstances(activityQuery);
 
for (int y = 0; y < activeInstances.getSize(); y++) {
	ActivityInstance activity = (ActivityInstance) activeInstances.get(y);
	System.out.println(y +") Activity OID: "+ activity.getOID() +" / Performer: "+ activity.getPerformedByName());
}

Scenario 3:

   This case covers the time required for an activity instance execution.
ActivityInstanceQuery aiquery = ActivityInstanceQuery.findAlive("OrderProcessing");
Date date = new Date();
long timeInMS = date.getTime() - (3600 * 1000);
 
date = new Date(timeInMS);
 
aiquery.where(ActivityInstanceQuery.START_TIME.greaterOrEqual(date.getTime()));
aiquery.orderBy(ActivityInstanceQuery.START_TIME);
ActivityInstances activityInstances_1 = queryService.getAllActivityInstances(aiquery);
System.out.println("Activity List ordered by start time ");
 
for (ActivityInstance activityInstance : activityInstances_1) {
 
   System.out.println("Activity Name: "+ activityInstance.getOID() + "Start Time: "+  activityInstance.getStartTime());
}

Back to the top