The UserQuery class provides methods to retrieve workflow users matching specific criteria.
The following example shows how to retrieve all users in a workflow with a certain role belonging to a specific organization or department.
Note that this example gets the ServiceFactory from the SessionContext
(usage in a JSF backing bean). Outside the session the runtime ServiceFactoryLocator
should be used.
import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.engine.api.model.ParticipantInfo;
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;
...
public static Users getUserListForParticipant(String participantId){
SessionContext sessionContext = SessionContext.findSessionContext();
QueryService qsService = sessionContext.getServiceFactory().getQueryService();
ParticipantInfo pInfo = qsService.getParticipant(participantId);
UserQuery query = new UserQuery();
query.getFilter().add(ParticipantAssociationFilter.forParticipant(pInfo));
Users users = qsService.getAllUsers(query);
return users;
}
For details on the API used in the code refer to the according Javadoc: