If you have a workflow process definition and create multiple instances of the 
process, is there a way to get a list of all the processes that you have 
started?

Let's say we have a method to start processes as follows, with a static 
jbpmConfiguration member visible somewhere and using hibernate for persistence:


  | public long startProcess(String orgNumber, String suborgNumber) throws 
RMSException{
  |             long processID = -1;
  |             log.info("Entering startEfileDestructionProcess");
  |             
  |             //Check if the jbpmConfiguration has been setup
  |             if( jbpmConfiguration == null ){
  |                     //retrieve it
  |                     log.info("JBPMConfiguration was null, creating 
instance.");
  |                     jbpmConfiguration = JbpmConfiguration.getInstance();
  |             }
  |             
  |             //Doing a try and catch for all so the RMSException can contain 
the relevant info
  |         // Lookup the pojo persistence context-builder that is configured 
above
  |         JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  |         log.info("Retrieved jbpmContext.");
  |         try {
  | 
  |                         
  |                     //GraphSession graphSession = 
jbpmContext.getGraphSession();
  |                     
  |                     //ProcessDefinition processDefinition = 
  |                     log.info("Creating process");
  |                     
  |                     // With the processDefinition that we retrieved from 
the database, we 
  |                     // can create an execution of the process definition 
just like in the 
  |                     // hello world example (which was without persistence).
  |                     ProcessInstance processInstance = 
jbpmContext.newProcessInstance("JBPMEfileProcess");
  |                     log.info("Created process");                            
                  
  |                     processID = processInstance.getId();
  |                     log.info("ProcessID is ["+processID+"]");
  |                     
  |                     //Set the key variables
  |                     
processInstance.getContextInstance().createVariable("OrgNumber",orgNumber);
  | 
  |                     log.info("Set Org Number");
  |                     
processInstance.getContextInstance().createVariable("SubOrgNumber",suborgNumber);
  |                     log.info("Set SubOrg Number");
  |                     
  |                     // Now the processInstance is saved in the database.  
So the 
  |                     // current state of the execution of the process is 
stored in the 
  |                     // database. 
  |                     //Connection myConnect = jbpmContext.getConnection();
  |                     //PreparedStatement myStatement = 
myConnect.prepareStatement("SET IDENTITY_INSERT JBPM_PROCESSINSTANCE OFF");
  |                     //myStatement.execute();
  |                     //myStatement.close();
  |                     processInstance.signal();
  |                     jbpmContext.save(processInstance);
  |                     log.info("Saved New Process");
  |             }catch(Exception e){
  |                     String message = "Error creating new RMS 
process["+e.getMessage()+"]";
  |                     e.printStackTrace();
  |                     throw new RMSException(1,message);
  |             }
  |             finally {
  |                   // Tear down the pojo persistence context.
  |                   jbpmContext.close();
  |             }               
  |             
  |             log.info("Exiting startEfileDestructionProcess, created 
processID["+processID+"]");
  |             return processID;
  |     }
  | 

Is there a way to get a list of all the processes, short of saving the process 
ids myself somewhere?

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043533
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to