-
1. Re: Task list of specified actor
ebrahimsalehi Sep 23, 2007 10:44 AM (in response to zambizi)Dear member;
TaskMgmtSession which can be fetched from jbpmContext has got various methods to find task instances.
context.getTaskMgmtSession().findTaskInstances(actor);
This method finds all active task instances from all process definitions. If you want to get task instances of a specified process definition you need to get all process instances of that process definition and then call findTaskInstancesByProcessInstance(ProcessInstance processInstance).
The other alternative is to fetch all tokens from process instances of a process definition and call findTaskInstancesByToken(long tokenId). These two methods find all task instances of all actors. To narrow the result make a contribution of findTaskInstancesByProcessInstance(ProcessInstance processInstance) and findTaskInstances(actor) or simply modify findTaskInstancesByProcessInstance including actor id in its hql.
Best Wishes
Ebrahim Salehi -
2. Re: Task list of specified actor
dleerob Sep 25, 2007 8:01 AM (in response to zambizi)Here's how I get all task instances that have not ended for all processes for the currently authenticated user. You could use this code as an example. If anyone has a better way of doing it, please post it:
User currentUser = getUser(request); Session session = jbpmContext.getSession(); //create list of possible id's (this includes groups) that //belong to the current user. List actorsList = new ArrayList(); actorsList.add(currentUser.getUsername()); IdentitySession identitySession = new IdentitySession(session); org.jbpm.identity.User jbpmUser = identitySession.getUserByName(currentUser.getUsername()); Iterator i = jbpmUser.getMemberships().iterator(); while(i.hasNext()){ Membership m = (Membership) i.next(); actorsList.add(m.getGroup().getName()); } List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances(actorsList); List jbpmTaskInstanceList = session.createQuery("from org.jbpm.taskmgmt.exe.TaskInstance " + "ti where ti.start is null and ti.end is null and actorId = '"+currentUser.getUsername()+"'").list(); //add pooledTaskInstances to taskList jbpmTaskInstanceList.addAll(pooledTaskInstances); //TODO sort jbpmTaskInstanceList by task instance id
-
3. Re: Task list of specified actor
kukeltje Sep 25, 2007 10:32 AM (in response to zambizi)for those of you who want a shorter (jbpm api and java api) and jbpm 3.2 compliant version (the example above is 3.1)
String currentUser = getUser(request).getUsername(); IdentityService is = jbpmContext.getServices().getIdentityService(); org.jbpm.identity.User jbpmUser = is.getUserByName(currentUser); //create list of possible id's (this includes groups) that //the current user is a member of. List actorsList = new ArrayList(jbpmUser.getMemberships()); // add user in case he is the sole pooled actor not via a group actorsList.add(user); List pooledTaskInstances = jbpmContext.getGroupTaskList(actorsList); List userTaskInstanceList = jbpmContext.getTaskList(currentUser); userTaskInstanceList.addAll(pooledTaskInstances);
-
4. Re: Task list of specified actor
dleerob Sep 26, 2007 2:33 AM (in response to zambizi)Thanks Ronald,
I have tried your example, however, there doesn't seem to be a method getIdentityService(); There is a getService(String name) method, so I thought that perhaps I should pass in some sort of 'Identity Service' name, so I looked in Services.java and found these service names defined:public static final String SERVICENAME_AUTHENTICATION = "authentication"; public static final String SERVICENAME_AUTHORIZATION = "authorization"; public static final String SERVICENAME_TX = "tx"; public static final String SERVICENAME_LOGGING = "logging"; public static final String SERVICENAME_MESSAGE = "message"; public static final String SERVICENAME_PERSISTENCE = "persistence"; public static final String SERVICENAME_SCHEDULER = "scheduler"; public static final String SERVICENAME_JCR = "jcr"; public static final String SERVICENAME_ADDRESSRESOLVER = "addressresolver";
There doesn't seem to be anything for an Identity Service? -
5. Re: Task list of specified actor
kukeltje Sep 26, 2007 4:47 AM (in response to zambizi)my version is for 3.2 which has the methods
-
6. Re: Task list of specified actor
dleerob Sep 26, 2007 4:56 AM (in response to zambizi)I must be missing something?
I was using 3.2.1, and just upgraded yesterday to 3.2.2. Neither of which have the methods.
I am looking at:jbpm-jpdl-suite-3.2.1\jbpm-jpdl-3.2.1\src\jpdl\org\jbpm\svc\Services.java
and:jbpm-jpdl-3.2.2\src\jpdl\org\jbpm\svc\Services.java
I downloaded the releases from the links found at: http://labs.jboss.com/jbossjbpm/downloads -
7. Re: Task list of specified actor
kukeltje Sep 26, 2007 5:45 AM (in response to zambizi)ahhhhhhhh shoooooottttt you are correct... this was something I was refactoring in my local tree stupid me... I wanted to make the identity a real service ... Made the mistake to name my checkout jbpm-3.2-head..... SORRY.....
-
8. Re: Task list of specified actor
dleerob Sep 26, 2007 6:01 AM (in response to zambizi)No problem, thanks for clearing that up.
I will keep an eye out in future releases for the Identity Service.