>From your description, it sounds like you just need to wait to assign an actor 
>to your swimlane until you know which department it will be.  

1) If you know which department should handle the complaint when the complaint 
is first received (the citizen specified which one), then your assignment 
handler could simply set the appropriate department.

2) However, if you won't know which department should handle the complaint 
until a worker analyzes the complaint, then try creating  a "department" 
swimlane with no default actor assignment, and allow the worker to effect a 
jBPM API call that sets the "department" swimlane's ownership once the 
department has been determined.

Ok, that all sounds great, except...By default, Swimlanes are not initialized 
and available for reassignment until a Task that is associated with the 
swimlane is instantiated.  So, to have some one assign the swimlane prior to 
the to process being passed on to a department (and a "department" task being 
instantiated), you may need to initialize your swimlanes manually when your 
process is first initialized.  This is a method I use to instantiate all my 
processes; take from it what you need:public Long instantiate(String 
processDefinitionName, String userId) {
  |         Long instanceId = null;
  |         
  |         JbpmSessionFactory jbpmSessionFactory = 
JbpmSessionFactory.getInstance();
  |         JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
  |         GraphSession graphSession = jbpmSession.getGraphSession();
  |         TaskMgmtSession taskMgmtSession = jbpmSession.getTaskMgmtSession();
  | 
  |         ProcessDefinition pd = 
graphSession.findLatestProcessDefinition(processDefinitionName);
  |         jbpmSession.beginTransaction();
  |         ProcessInstance pi = new ProcessInstance(pd);
  | 
  |         //This ensures that all swimlanes are initialized and available for 
reporting and reassignment immediately.
  |         //If we don't initialize them up front, they won't be created until 
a task calls for them.
  |         Map swimlanes = pd.getTaskMgmtDefinition().getSwimlanes();
  |         Iterator itr = swimlanes.keySet().iterator();
  |         while(itr.hasNext()) {
  |             Swimlane swimlane = (Swimlane)swimlanes.get(itr.next());
  |             SwimlaneInstance swi = 
pi.getTaskMgmtInstance().getInitializedSwimlaneInstance(new 
ExecutionContext(pi.getRootToken()), swimlane);            
  |             //We have to do this cause it doesn't automatically happen when 
we
  |             // call swimlaneInstance.setPooledActors()
  |             Set pooledActors = swi.getPooledActors();
  |             if(pooledActors != null) {
  |                 Iterator paItr = pooledActors.iterator();
  |                 while(paItr.hasNext()) {
  |                     ( (PooledActor)paItr.next() ).setSwimlaneInstance(swi);
  |                 }
  |             }
  |         }
  | 
  |         //If this process definition defines a startTask in the StartState, 
we'll have to
  |         // explicitly create it--it won't be created otherwise...
  |         if (pd.getTaskMgmtDefinition().getStartTask() != null) {
  |             
  |             //When we create the startTaskInstance, the start task will be 
assigned
  |             // to the currently authenticated user (as understood by Jbpm), 
and that
  |             // data WILL overwrite any default swimlane assignments, as 
well as update
  |             // the actual swimlaneInstance itself.  The swimlaneInstance's 
pooledActors will be NULL.
  |             // To preserve any original assignments to the 
swimlaneInstance, we'll have
  |             // to record that data now and re-set it in the 
swimlaneInstance after the
  |             // startTaskInstance has been created.
  |             org.jbpm.taskmgmt.def.Task task = 
pd.getTaskMgmtDefinition().getStartTask();
  |             String swimlaneName = task.getSwimlane().getName();
  |             SwimlaneInstance swi = 
pi.getTaskMgmtInstance().getSwimlaneInstance(swimlaneName);
  |             String originalActorId = swi.getActorId();
  |             Set originalPooledActors = swi.getPooledActors();
  |          
  |             TaskInstance startTask = 
pi.getTaskMgmtInstance().createStartTaskInstance();
  |      
  |             //Unless our application's authentication scheme has been tied 
into Jbpm's, we
  |             // should manually assign the startTask to a user as well as 
manually set the swimlane actors
  |             // referenced by this task, otherwise both will be null.
  |             startTask.setActorId(userId);
  |             
  |             if(startTask.getSwimlaneInstance() != null) {
  |                 log.debug("Swimlane assigned actor: " + 
startTask.getSwimlaneInstance().getActorId());
  |                 startTask.getSwimlaneInstance().setActorId(userId);
  |                 
  |                 //Currently, no pooledActors are being set
  |                 
  |                 //swi.setPooledActors(originalPooledActors);
  |                 
//startTask.getSwimlaneInstance().setPooledActors(originalPooledActors);
  |                 if (startTask.getSwimlaneInstance().getPooledActors() != 
null) {
  |                     log.debug("Swimlane assigned pooled actor: " + ( 
(PooledActor)(startTask.getSwimlaneInstance().getPooledActors().iterator().next())
 ).getActorId() );
  |                 }
  |                 //jbpmSession.getSession().save(swi);
  |             }
  |             
  |         }else {
  |             //If our new process doesn't have a startTask defined, we may 
want to get the new process rolling...
  |             // Although, some executions may want to set process variables, 
etc. before
  |             // continuing, in which case they should do such and signal for 
themselves.
  |             //pi.signal();
  |         }
  |         
  |         graphSession.saveProcessInstance(pi);
  |         jbpmSession.commitTransaction();
  |         
  |         instanceId = Long.valueOf(pi.getId());
  |         jbpmSession.close();
  |         return instanceId;
  |     }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3913433#3913433

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3913433


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to