JBoss Community

Re: Link the business object to the process instance

created by Pedro Gonçalves in jBPM - View the full discussion

Thanks Mauricio.

I've used the Variables to build Business Keys.

 

This is how I've managed to solve the problem:

 

 


//......Start process......
Map<String, Object> variables = new HashMap<String, Object>();
 
variables.put("business_key", buildBusinessKeyForMyObject(myObject));
 
kSession.startProcess("my_workflow_id",variables);
//......................................
 
 
 
//.........Get Process Instances Id of My Object.......
Query query = entityManager.createQuery("FROM " + VariableInstanceLog.class.getName() + " variable " +
      " WHERE variable.variableId = :business_key_id
         AND variable.value = :business_key_value);
 
     query.setParameter("business_key_id", "business_key");
     query.setParameter("business_key_value", buildCoreDataBusinessKey(coreData));
 
     List<VariableInstanceLog> resultList = query.getResultList();
 
for (VariableInstanceLog variableInstanceLog : resultList) {
     logger.info("******* " + variableInstanceLog.getProcessInstanceId());
}
//...............................................................
 

Reply to this message by going to Community

Start a new discussion in jBPM at Community