Skip to content

Commit

Permalink
Merge pull request xuhuisheng#56 from izerui/patch-1
Browse files Browse the repository at this point in the history
自由流修改
  • Loading branch information
xuhuisheng committed Mar 29, 2014
2 parents b8abb9b + 505b4c4 commit 826c385
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions src/main/java/com/mossle/bpm/cmd/JumpCmd.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
package com.mossle.bpm.cmd;


import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;

public class JumpCmd implements Command<Object> {
private String activityId;
private String executionId;
private String jumpOrigin;

public JumpCmd(String executionId, String activityId) {
this(executionId, activityId, "jump");
}

public JumpCmd(String executionId, String activityId, String jumpOrigin) {
this.activityId = activityId;
this.executionId = executionId;
this.jumpOrigin = jumpOrigin;
}

public Object execute(CommandContext commandContext) {
for (TaskEntity taskEntity : commandContext.getTaskEntityManager()
.findTasksByExecutionId(executionId)) {
taskEntity.setVariableLocal("跳转原因", jumpOrigin);
commandContext.getTaskEntityManager().deleteTask(taskEntity,
jumpOrigin, false);
}

ExecutionEntity executionEntity = commandContext
.getExecutionEntityManager().findExecutionById(executionId);
ProcessDefinitionImpl processDefinition = executionEntity
.getProcessDefinition();
ActivityImpl activity = processDefinition.findActivity(activityId);

executionEntity.executeActivity(activity);

return null;
}
private String activityId;
private String processInstanceId;
private String jumpOrigin;

public JumpCmd(String processInstanceId, String activityId) {
this(processInstanceId,activityId,"jump");
}
public JumpCmd(String processInstanceId, String activityId , String jumpOrigin) {
this.activityId = activityId;
this.processInstanceId = processInstanceId;
this.jumpOrigin = jumpOrigin;
}

public Object execute(CommandContext commandContext) {
//parent execution
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);

//1. 删除当前execution的所有子execution
//2. 删除当前execution下的所有task
//3. 删除当前execution下的所有job
executionEntity.destroyScope(jumpOrigin);

ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition();
ActivityImpl activity = processDefinition.findActivity(activityId);

executionEntity.executeActivity(activity);


return null;
}
}

0 comments on commit 826c385

Please sign in to comment.