本文整理匯總了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);
}