forked from xuhuisheng/lemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request xuhuisheng#56 from izerui/patch-1
自由流修改
- Loading branch information
Showing
1 changed file
with
31 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |