Hi!
Thanks for reply! Here is the full testing code:
<code>
ProcessEngine activitiRule = (ProcessEngine) context.getBean("processEngine");
BpmnModel model = new BpmnModel();
Process process = new Process();
model.addProcess(process);
process.setId("my-process");
process.addFlowElement(createStartEvent());
process.addFlowElement(createUserTask("task1", "First task", "fred"));
process.addFlowElement(createUserTask("task2", "Second task", "john"));
process.addFlowElement(createEndEvent());
process.addFlowElement(createSequenceFlow("start", "task1"));
process.addFlowElement(createSequenceFlow("task1", "task2"));
process.addFlowElement(createSequenceFlow("task2", "end"));
Deployment deployment = activitiRule.getRepositoryService().createDeployment()
.addBpmnModel("dynamic-model.bpmn", model).name("Dynamic process deployment")
.deploy();
ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey("my-process");
activitiRule.getRuntimeService().setVariable(processInstance.getId(), "variable1", "value1");
activitiRule.getRuntimeService().setVariable(processInstance.getId(), "variable2", "value2");
activitiRule.getRuntimeService().setVariable(processInstance.getId(), "variable3", "value3");
List<Task> tasks = activitiRule.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).list();
Assert.assertEquals(1, tasks.size());
Assert.assertEquals("First task", tasks.get(0).getName());
Assert.assertEquals("fred", tasks.get(0).getAssignee());
long count = activitiRule.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).count();
Assert.assertEquals(1, count);
activitiRule.getTaskService().setVariable(tasks.get(0).getId(), "taskVar1", 5d);
tasks = activitiRule.getTaskService().createTaskQuery().includeProcessVariables().includeTaskLocalVariables().list();
Assert.assertEquals(1, tasks.size());
Assert.assertEquals(3, tasks.get(0).getProcessVariables().size());
Assert.assertEquals(1, tasks.get(0).getTaskLocalVariables().size());
</code>
Spring context:
<code>
<bean id="processEngineConfiguration" class="org.jbaf.server.workflow.processengine.JBAFProcessEngineConfiguration" lazy-init="true">
<property name="databaseType" value="h2"/>
<property name="dataSource" ref="jbafDS" />
<property name="dataAccessService" ref="dataAccessService"/>
<property name="databaseSchemaUpdate" value="false" />
<property name="history" value="audit" />
<property name="jobExecutorActivate" value="false" />
<property name="asyncExecutorEnabled" value="true" />
<property name="asyncExecutorActivate" value="true" />
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" lazy-init="true">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
</code>
ProcessEngineConfiguration impl:
<code>
public class JBAFProcessEngineConfiguration extends ProcessEngineConfigurationImpl implements ApplicationContextAware
{
private ApplicationContext applicationContext;
private IDataAccessService dataAccessService;
public void setApplicationContext(ApplicationContext applicationContext)
{
this.applicationContext = applicationContext;
}
@Override
protected CommandInterceptor createTransactionInterceptor()
{
return null;
}
@Override
protected void initIdGenerator()
{
idGenerator = new JBAFIdGenerator(this);
}
@Override
protected void initDataManagers()
{
super.initDataManagers();
this.attachmentDataManager = new ActivitiAttachmentDataManager(this);
this.byteArrayDataManager = new ActivitiByteArrayDataManager(this);
this.commentDataManager = new ActivitiCommentDataManager(this);
this.deploymentDataManager = new ActivitiDeploymentDataManager(this);
this.eventLogEntryDataManager = new ActivitiEventLogEntryDataManager(this);
this.executionDataManager = new ActivitiExecutionDataManager(this);
this.groupDataManager = new ActivitiGroupDataManager(this);
this.historicActivityInstanceDataManager = new ActivitiHistoricActivityInstanceDataManager(this);
this.historicDetailDataManager = new ActivitiHistoricDetailDataManager(this);
this.historicIdentityLinkDataManager = new ActivitiHistoricIdentityLinkDataManager(this);
this.identityInfoDataManager = new ActivitiIdentityInfoDataManager(this);
this.jobDataManager = new ActivitiJobDataManager(this);
this.membershipDataManager = new ActivitiMembershipDataManager(this);
this.modelDataManager = new ActivitiModelDataManager(this);
this.processDefinitionDataManager = new ActivitiProcessDefinitionDataManager(this);
this.processDefinitionInfoDataManager = new ActivitiProcessDefinitionInfoDataManager(this);
this.propertyDataManager = new ActivitiPropertyDataManager(this);
this.resourceDataManager = new ActivitiResourceDataManager(this);
this.taskDataManager = new ActivitiTaskDataManager(this);
this.userDataManager = new ActivitiUserDataManager(this);
this.variableInstanceDataManager = new ActivitiVariableDataManager(this);
}
public void setDataAccessService(IDataAccessService dataAccessService)
{
this.dataAccessService = dataAccessService;
}
public IDataAccessService getDataAccessService()
{
return dataAccessService;
}
}
</code>
Let me know if you need something else.
Regards,
byr