Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/API/JavaAPICookbook/Querying Users entitled to perform an Activity

Querying for Users having the Grants to perform a certain Activity or Activity Instance

(Versions: 8.1.3)

To find out which users have the grants to perform a specific activity instance identified by its OID

  1. find the activity definition for the activity instance in question
  2. find the model participant for the activity
  3. find all users having the grant for this participant
  4. list user ids

package portal813;
import java.util.Iterator;
import org.eclipse.stardust.engine.api.model.Activity;
import org.eclipse.stardust.engine.api.model.ModelParticipant;
import org.eclipse.stardust.engine.api.query.ActivityInstanceFilter;
import org.eclipse.stardust.engine.api.query.ActivityInstanceQuery;
import org.eclipse.stardust.engine.api.query.ParticipantAssociationFilter;
import org.eclipse.stardust.engine.api.query.UserQuery;
import org.eclipse.stardust.engine.api.query.Users;
import org.eclipse.stardust.engine.api.runtime.QueryService;
import org.eclipse.stardust.engine.api.runtime.ServiceFactory;
import org.eclipse.stardust.engine.api.runtime.ServiceFactoryLocator;
import org.eclipse.stardust.engine.api.runtime.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestQ {
	public static void main(String[] args) {
		long aioid= 3;
		final Logger log = LoggerFactory.getLogger(TestQ.class);
		ServiceFactory sf = ServiceFactoryLocator.get("motu","motu");
		QueryService qs = sf.getQueryService();
		// get participant for activity instance
		ActivityInstanceQuery aiq = ActivityInstanceQuery.findAll();
		aiq.where(new ActivityInstanceFilter(aioid));		
		Activity activity = qs.findFirstActivityInstance(aiq).getActivity();
		ModelParticipant participant = activity.getDefaultPerformer();
		// get users for participant
		UserQuery uq = UserQuery.findActive();
		Users users = qs.getAllUsers(uq);
		//show user names
		for (Iterator<User> iterator = users.iterator(); iterator.hasNext();) {
			User user =;"User:" + user.getId());		

Back to the top