02-23-2012 07:48 AM
<definitions id="definitions" targetNamespace="http://activiti.org/bpmn20"
xmlns:activiti="http://activiti.org/bpmn" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
<process id="testProcess" name="Test process">
<startEvent id="theStart" />
<sequenceFlow id='flow1' sourceRef='theStart' targetRef='javaService' />
<serviceTask id="javaService" name="My Java Service Task"
activiti:expression="#{myServiceTask.execute(name)}"
activiti:resultVariableName="myResult" />
<sequenceFlow id='flow2' sourceRef='javaService'
targetRef='theEnd' />
<endEvent id="theEnd" />
</process>
</definitions>
@Component
public class MyServiceTask {
@Transactional
public String execute(String name) throws Exception {
List<MyTable> myTables = myTableMapper.selectByExample(null);
int maxId = -1;
for (MyTable myTable : myTables) {
maxId = maxId < myTable.getId() ? myTable.getId() : maxId;
}
MyTable newMyTable = new MyTable();
newMyTable.setId(maxId + 1);
newMyTable.setName(name);
myTableMapper.insert(newMyTable);
return "Halo " + name + " !";
}
@Autowired
private MyTableMapper myTableMapper;
}
Map<String, Object> input = new HashMap<String, Object>();
input.put("name", "Peter");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", input);
02-23-2012 08:52 AM
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", input);
String myResult = runtimeService.getVariable(processInstance.getId(), "myResult");
But do not forget to signal the process afterwards to continue and finally end:
Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(pi.getId())
.activityId("receiveTask")
.singleResult();
runtimeService.signal(execution.getId());
Now the process really ended.02-23-2012 03:59 PM
02-24-2012 09:32 AM
08-27-2012 03:03 PM
08-27-2012 10:38 PM
08-29-2012 04:49 PM
08-29-2012 11:55 PM
07-15-2016 02:55 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.