當前位置: 首頁>>代碼示例>>Java>>正文


Java ProcessInstance.getProcessVariables方法代碼示例

本文整理匯總了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;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:7,代碼來源:ActivitiResourceMapper.java

示例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);

}
 
開發者ID:hs-web,項目名稱:hsweb-framework,代碼行數:73,代碼來源:BpmTaskServiceImp.java


注:本文中的org.activiti.engine.runtime.ProcessInstance.getProcessVariables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。