maq99 [
https://community.jboss.org/people/maq99] created the discussion
"Re: JBPM 5.4.0-Final: Human Task variable mapping is not working"
To view the discussion, visit:
https://community.jboss.org/message/792774#792774
--------------------------------------------------------------
Hallo,
I have simmilar problem and decide to add my post to this topic instead create new one.
Something wrong is with saveing variables. I already spend some time on it and have not
found sollution. All base on seam framework (web app) + EJB3 as jbpm managment layer.
Persistence is made on Postgres.
Here is my diagram:
https://community.jboss.org/servlet/JiveServlet/showImage/2-792774-20169/...
https://community.jboss.org/servlet/JiveServlet/downloadImage/2-792774-20...
As You can see there is two human tasks.. After process is started user:user1 pick
object:wrapper (from external Wsdl) to edit, chenge its fields and confirm changes or
reject it. Eddited object is about to be placed as HT result and stored as process
variables.
First gateway check if object have been placed (not null - go to commit) or changes have
been rejected (is null - cancel & end process)
At begininig next HT (approval) fallowing log script is called, then it calls my custom
EscalatedDeadlineHandler and send email to user:approver that he has task assign. Approval
base on object:wrapper from previous HT.
Approvel page display edited object:wrapper and shows changes made by user:user1
As a result Boolean value isApproved has to be added to proces variables. Next gateway
check isApproved on true go to submit changes (send back to store edited object - external
Wsdl) - else goes to end.
process variables:
Name: wrapper; Type: Object; ClassName: Object
Name: isApproved; Type: Object; ClassName: Object
1HT (edit object) Result mapping:
Parameter: result; Variable: wrapper
1Gateway:
commit: Type: code; Dialect: mvel; wrapper!=null
cancel: Type: code; Dialect: mvel; wrapper==null
2HT (approval) Parameter mapping:
Parameter wrapper; Variable: wrapper;
2HT (approval) Result mapping:
Parameter isApproved; Variable: isApproved;
Starting process code:
@PersistenceUnit(unitName = "org.jbpm.persistence.jpa")
protected EntityManagerFactory jbpmPersistence;
@PersistenceUnit(unitName = "org.jbpm.task")
protected EntityManagerFactory jbpmTask;
(...)
Environment env = EnvironmentFactory.newEnvironment();
env.set(EnvironmentName.TRANSACTION_MANAGER,TransactionManagerServices.getTransactionManager());
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
new ObjectMarshallingStrategy[] {
new JPAPlaceholderResolverStrategy(env),
new SerializablePlaceholderResolverStrategy(
ClassObjectMarshallingStrategyAcceptor.DEFAULT) });
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(bpmn),ResourceType.BPMN2);
// Check for errors
if (kbuilder.hasErrors()) {
if (kbuilder.getErrors().size() > 0) {
for (KnowledgeBuilderError error : kbuilder.getErrors()) {
log.error(error.toString());
}
}
}
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
KnowledgeSessionConfiguration conf =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase,
conf, env);
KnowledgeRuntimeLogger knowledgeRuntimeLogger =
KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);
MyHtWorkItemHandler workItemHandler = new MyHtWorkItemHandler(
ksession);
workItemHandler.setLocal(true);
workItemHandler.setIpAddress(WUIConfiguration.getHumanTaskServiceIP());
workItemHandler.setPort(WUIConfiguration.getHumanTaskServicePort());
workItemHandler.setClient(getLocalTaskService());
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
workItemHandler);
workItemHandler.connect();
WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession
.startProcess(processId);// variables will be
added in HT.. .
protected TaskService getLocalTaskService() {
if (taskService == null) {
taskService = new org.jbpm.task.service.TaskService(jbpmTask,
SystemEventListenerFactory.getSystemEventListener());
//for PoC it can be singleton?
taskService
.setEscalatedDeadlineHandler(MyEscalatedDeadlineHandler
.getInstance());
TaskServiceSession taskServiceSession = taskService.createSession();
// TODO create dynamic users list..
taskServiceSession.addUser(new User("approver"));
taskServiceSession.addUser(new User("user1"));
}
// taskservicesMap.put(processName, taskService);
return new LocalTaskService(taskService);
}
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/792774#792774]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]