本文整理汇总了Java中org.activiti.engine.runtime.ProcessInstance.getProcessVariables方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessInstance.getProcessVariables方法的具体用法?Java ProcessInstance.getProcessVariables怎么用?Java ProcessInstance.getProcessVariables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.runtime.ProcessInstance
的用法示例。
在下文中一共展示了ProcessInstance.getProcessVariables方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapToResource
import org.activiti.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
public <T extends ProcessInstanceResource> T mapToResource(Class<T> resourceClass, ProcessInstance processInstance) {
T resource = io.crnk.core.engine.internal.utils.ClassUtils.newInstance(resourceClass);
Map<String, Object> processVariables = processInstance.getProcessVariables();
copyInternal(resource, null, processVariables, true, Optional.of(processInstance));
return resource;
}
示例2: reject
import org.activiti.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Override
public void reject(String taskId) {
// 先判定是否存在历史环节
String oldTaskId = selectVariableLocalByTaskId(taskId, "oldTaskId").toString();
HistoricTaskInstance taskInstance = historyService.createHistoricTaskInstanceQuery().taskId(oldTaskId).singleResult();
if (taskInstance == null) {
throw new NotFoundException("历史任务环节不存在,taskId:" + oldTaskId);
}
Task task = selectTaskByTaskId(taskId);
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
if (processInstance == null) {
throw new NotFoundException("流程已经结束");
}
Map<String, Object> variables = processInstance.getProcessVariables();
ProcessDefinitionEntity definition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId());
if (definition == null) {
throw new NotFoundException("流程定义未找到");
}
ActivityExecution execution = (ActivityExecution) runtimeService.createExecutionQuery()
.executionId(task.getExecutionId()).singleResult();
// 是否并行节点
if (execution.isConcurrent()) {
throw new NotFoundException("并行节点不允许驳回,taskId:" + task.getId());
}
// 是否存在定时任务
long num = managementService.createJobQuery().executionId(task.getExecutionId()).count();
if (num > 0) {
throw new NotFoundException("当前环节不允许驳回");
}
// 驳回
// 取得上一步活动
ActivityImpl currActivity = definition.findActivity(task.getTaskDefinitionKey());
List<PvmTransition> nextTransitionList = currActivity.getIncomingTransitions();
// 清除当前活动的出口
List<PvmTransition> oriPvmTransitionList = new ArrayList<>();
List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
oriPvmTransitionList.addAll(pvmTransitionList);
pvmTransitionList.clear();
// 建立新出口
List<TransitionImpl> newTransitions = new ArrayList<>();
for (PvmTransition nextTransition : nextTransitionList) {
PvmActivity nextActivity = nextTransition.getSource();
ActivityImpl nextActivityImpl = definition.findActivity(nextActivity.getId());
TransitionImpl newTransition = currActivity.createOutgoingTransition();
newTransition.setDestination(nextActivityImpl);
newTransitions.add(newTransition);
}
// 完成任务
List<Task> tasks = taskService.createTaskQuery()
.processInstanceId(processInstance.getId())
.taskDefinitionKey(task.getTaskDefinitionKey()).list();
for (Task t : tasks) {
taskService.complete(t.getId(), variables);
historyService.deleteHistoricTaskInstance(t.getId());
}
// 恢复方向
for (TransitionImpl transitionImpl : newTransitions) {
currActivity.getOutgoingTransitions().remove(transitionImpl);
}
pvmTransitionList.addAll(oriPvmTransitionList);
}