06-18-2011 02:39 AM
06-18-2011 02:45 AM
List<Task> tList = taskService.createTaskQuery().taskAssignee("person1").list();
if (null != tList && tList.size() > 0) {
for (Task task : tList) {
System.out.println("the task id is :" + task.getId());
System.out.println(task.getProcessInstanceId());
List<ProcessInstance> pdes = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).list();
if (null != pdes && pdes.size() > 0) {
for (ProcessInstance pi : pdes) {
if (null != pi) {
ExecutionEntity ee = (ExecutionEntity) pi;
if (null != ee) {
ActivityImpl ai = ee.getActivity();
List<PvmTransition> pts = ai.getOutgoingTransitions();
if (null != pts)
System.out.println(pts.size());
else
System.out.println("PvmTransition list is null");
}
}
}
}
}
}
06-20-2011 03:38 AM
08-11-2011 06:21 AM
@Test
public void getActivityBehaviorViaProcessDefinitionEntity() {
// start a process
String processKey = "singleReceiveTaskProcess";
ProcessInstance processInstance = getActivitiRuntimeService().startProcessInstanceByKey(processKey);
List<Execution> executions = getActivitiRuntimeService().createExecutionQuery()
.processInstanceId(processInstance.getId())
.list();
assertEquals(1, executions.size());
Execution execution = executions.get(0);
ExecutionEntity executionEntity = (ExecutionEntity) execution;
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) getActivitiRepositoryService() )
.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
ActivityImpl activity = processDefinitionEntity.findActivity(executionEntity.getActivityId());
assertNotNull(activity);
}
09-05-2011 11:53 PM
/**
* <pre>
* Test rollback.
* </pre>
*
* @author 宿晓斐 2011-9-5
* @throws Exception
*/
@Test
public void testRollback() throws Exception {
Task mobjTask = taskService.createTaskQuery().taskId("102").singleResult();
if (mobjTask != null) {
System.out.println("ready rollback");
ProcessDefinitionImpl processDefinitionImpl =
(ProcessDefinitionImpl) repositoryService
.createProcessDefinitionQuery()
.processDefinitionId(
mobjTask.getProcessDefinitionId())
.singleResult();
TaskEntity taskEntity = (TaskEntity) mobjTask;
// this node should not be empty.
List<PvmTransition> pvmTransitionList =
taskEntity.getExecution().getActivity()
.getIncomingTransitions();
if (pvmTransitionList == null || pvmTransitionList.isEmpty()) {
throw new ActivitiException("no IncomingTransitions found");
}
TransitionImpl transition =
(TransitionImpl) pvmTransitionList.get(0);
ActivityImpl toActiviti = transition.getSource();
if (toActiviti == null) {
throw new ActivitiException("no toActiviti found");
}
TransitionImpl transitionImpl =
toActiviti.createOutgoingTransition();
transitionImpl.setDestination(toActiviti);
taskService.complete(mobjTask.getId());
System.out.println("roll back completed");
} else {
System.out.println("task is null");
}
}
public ExecutionEntity getExecution() {
if ( (execution==null) && (executionId!=null) ) {
this.execution = Context
.getCommandContext()
.getExecutionManager()
.findExecutionById(executionId);
}
return execution;
}
It looks like Context or getCommandContext() or getExecutionManager() is null.09-06-2011 02:19 AM
09-06-2011 03:40 AM
Hi,thanks for your help.
Please post a fully working unit test so we reproduce the error.
Best regards,
public class Demo {
/** The ctx. */
private ClassPathXmlApplicationContext ctx;
/** The process engine. */
private ProcessEngine processEngine;
/** The runtime service. */
private RuntimeService runtimeService;
/** The task service. */
private TaskService taskService;
/** The repository service. */
private RepositoryService repositoryService;
/** The history service. */
private HistoryService historyService;
private ExecutionManager executionManager;
/** The ymd. */
public SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
/**
* <pre>
* Before.
* </pre>
*
* @author 宿晓斐 2011-9-2
*/
@Before
public void before() {
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
processEngine = (ProcessEngine) ctx.getBean("processEngine");
runtimeService = (RuntimeService) ctx.getBean("runtimeService");
repositoryService =
(RepositoryService) ctx.getBean("repositoryService");
taskService = (TaskService) ctx.getBean("taskService");
historyService = (HistoryService) ctx.getBean("historyService");
executionManager = (ExecutionManager) ctx.getBean("executionManager");
}
}
<!– Activiti工作流 配置 start –>
<!– Activiti的数据源等参数配置 –>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
</bean>
<!– Activiti的流程引擎 –>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<!– Activiti的资源库服务,用于获取流程定义等内容 –>
<bean id="repositoryService" factory-bean="processEngine"
factory-method="getRepositoryService" />
<!– Activiti的运行时服务,可以用于完成任务等操作 –>
<bean id="runtimeService" factory-bean="processEngine"
factory-method="getRuntimeService" />
<!– Activiti的任务服务,用于跟任务相关的操作,比如指派处理人等 –>
<bean id="taskService" factory-bean="processEngine"
factory-method="getTaskService" />
<!– Activiti的历史服务,用于查询数据,比如查询已经完成和未完成的任务等 –>
<bean id="historyService" factory-bean="processEngine"
factory-method="getHistoryService" />
<!– Activiti的管理服务 –>
<bean id="managementService" factory-bean="processEngine"
factory-method="getManagementService" />
<bean id="executionManager" class="org.activiti.engine.impl.persistence.entity.ExecutionManager" />
<!– Activiti 配置 end –>
09-15-2011 08:20 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.