Skip to main content
Jump to: navigation, search

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

< Stardust‎ | Knowledge Base
Revision as of 00:25, 3 February 2015 by Robert.emsbach.fisglobal.com (Talk | contribs) (Created page with "== Querying for Users having the Grants to perform a certain Activity or Activity Instance == (Versions: 8.1.3)<br> To find out which users have the grants to perform a spec...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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();
		uq.where(ParticipantAssociationFilter.forParticipant(participant));
		Users users = qs.getAllUsers(uq);
 
		//show user names
		for (Iterator<User> iterator = users.iterator(); iterator.hasNext();) {
			User user = iterator.next();
			log.info("User:" + user.getId());		
		}
 
		sf.close();
	}
 
}

Back to the top