protected AbstractSetProcessInstanceStateCmd getProcessInstanceChangeStateCmd(ProcessInstance processInstance) { return new ActivateProcessInstanceCmd(processInstance.getId()); } }
protected AbstractSetProcessInstanceStateCmd getProcessInstanceChangeStateCmd(ProcessInstance processInstance) { return new SuspendProcessInstanceCmd(processInstance.getId()); }
protected void assertHistoricActivitiesDeleteReason(ProcessInstance processInstance, String expectedDeleteReason, String ... activityIds) { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { for (String activityId : activityIds) { List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery() .activityId(activityId).processInstanceId(processInstance.getId()).list(); assertTrue("Could not find historic activities", historicActivityInstances.size() > 0); for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) { assertNotNull(historicActivityInstance.getEndTime()); if (expectedDeleteReason == null) { assertNull(historicActivityInstance.getDeleteReason()); } else { assertTrue(historicActivityInstance.getDeleteReason().startsWith(expectedDeleteReason)); } } } } }
processInstanceJSON.put("processInstanceId", subProcessInstance.getId()); processInstanceJSON.put("superExecutionId", superExecutionId); processInstanceJSON.put("processDefinitionId", subDef.getId());
protected void assertHistoricTasksDeleteReason(ProcessInstance processInstance, String expectedDeleteReason, String ... taskNames) { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { for (String taskName : taskNames) { List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()).taskName(taskName).list(); assertTrue(historicTaskInstances.size() > 0); for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertNotNull(historicTaskInstance.getEndTime()); if (expectedDeleteReason == null) { assertNull(historicTaskInstance.getDeleteReason()); } else { assertTrue(historicTaskInstance.getDeleteReason().startsWith(expectedDeleteReason)); } } } } }
@PostMapping("/start/id/{defId}") @ApiOperation("提交表单数据并根据流程定义ID启动流程") @Authorize(merge = false) public ResponseMessage<String> startProcess(@PathVariable String defId, @RequestBody Map<String, Object> data, Authentication authentication) { ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() .processDefinitionId(defId) .active() .singleResult(); if (null == definition) { throw new NotFoundException("流程[" + defId + "]不存在"); } //判断权限 processConfigurationService.getProcessConfiguration(definition.getId()) .assertCanStartProcess(authentication.getUser().getId(), definition); ProcessInstance instance = bpmProcessService.startProcessInstance(StartProcessRequest.builder() .creatorId(authentication.getUser().getId()) .creatorName(authentication.getUser().getName()) .formData(data) .processDefineId(defId) .build()); return ResponseMessage.ok(instance.getId()); }
@PostMapping("/start/key/{defineKey}") @ApiOperation("提交表单数据并根据流程定义key启动流程") @Authorize(merge = false) public ResponseMessage<String> startProcessByKey(@PathVariable String defineKey, @RequestBody Map<String, Object> data, Authentication authentication) { ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(defineKey) .active() .latestVersion() .singleResult(); if (null == definition) { throw new NotFoundException("流程[" + defineKey + "]不存在"); } //判断权限 processConfigurationService.getProcessConfiguration(definition.getId()) .assertCanStartProcess(authentication.getUser().getId(), definition); String id = definition.getId(); ProcessInstance instance = bpmProcessService.startProcessInstance(StartProcessRequest.builder() .creatorId(authentication.getUser().getId()) .creatorName(authentication.getUser().getName()) .formData(data) .processDefineId(id) .build()); return ResponseMessage.ok(instance.getId()); }
@RequestMapping(value = "/find/{id}", method = RequestMethod.POST) @ResponseBody public Map<String,String> getData(@PathVariable("id") String id) { Map<String,String> map=new HashMap<>(); ProcessInstance processInstance=runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(id) .singleResult(); map.put("name",processInstance.getName()); map.put("verifiers",runtimeService.getVariable(processInstance.getId(),"verifiers").toString()); map.put("approvers",runtimeService.getVariable(processInstance.getId(),"approvers").toString()); map.put("taskState",runtimeService.getVariable(processInstance.getId(),"taskState")!=null?runtimeService .getVariable(processInstance.getId(),"taskState").toString():null); return map; } }
@Override public ProcessInstance from(org.activiti.engine.runtime.ProcessInstance internalProcessInstance) { ProcessInstanceImpl processInstance = new ProcessInstanceImpl(); processInstance.setId(internalProcessInstance.getId()); processInstance.setParentId(internalProcessInstance.getParentProcessInstanceId()); processInstance.setName(internalProcessInstance.getName()); processInstance.setDescription(internalProcessInstance.getDescription()); processInstance.setProcessDefinitionId(internalProcessInstance.getProcessDefinitionId()); processInstance.setProcessDefinitionKey(internalProcessInstance.getProcessDefinitionKey()); processInstance.setProcessDefinitionVersion(internalProcessInstance.getProcessDefinitionVersion()); processInstance.setInitiator(internalProcessInstance.getStartUserId()); processInstance.setStartDate(internalProcessInstance.getStartTime()); processInstance.setProcessDefinitionKey(internalProcessInstance.getProcessDefinitionKey()); processInstance.setBusinessKey(internalProcessInstance.getBusinessKey()); processInstance.setStatus(calculateStatus(internalProcessInstance)); processInstance.setProcessDefinitionVersion(internalProcessInstance.getProcessDefinitionVersion()); return processInstance; }
@BeforeClass public void before() { List<ProcessInstance> instances = runtimeService.createProcessInstanceQuery().list(); for (ProcessInstance instance : instances) { runtimeService.deleteProcessInstance(instance.getId(), "test"); historyService.deleteHistoricProcessInstance(instance.getId()); } List<HistoricProcessInstance> historicProcessInstances=historyService.createHistoricProcessInstanceQuery() .list(); for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) { historyService.deleteHistoricProcessInstance(historicProcessInstance.getId()); } }
runtimeService.setProcessInstanceName(processInstance.getId(), "流程实例名称设置:"); System.out.println("根据key启动最新的流程,流程定义ID:" + processInstance.getProcessDefinitionId());
private static boolean contains(List<ProcessInstance> processInstances, String processId) { for (ProcessInstance process : processInstances) { if (process.getId().equals(processId)) { return true; } } return false; }
protected String getProcessDisplayName(ProcessDefinition processDefinition, ProcessInstance processInstance) { if(processDefinition.getName() != null) { return processDefinition.getName() + " (" + processInstance.getId() +")"; } else { return processDefinition.getKey() + " (" + processInstance.getId() +")"; } }
@ApiOperation(value = "Get involved people for process instance", tags = { "Process Instances" }, nickname = "listProcessInstanceIdentityLinks", notes = "Note that the groupId in Response Body will always be null, as it’s only possible to involve users with a process-instance.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the process instance was found and links are returned."), @ApiResponse(code = 404, message = "Indicates the requested process instance was not found.") }) @RequestMapping(value = "/runtime/process-instances/{processInstanceId}/identitylinks", method = RequestMethod.GET, produces = "application/json") public List<RestIdentityLink> getIdentityLinks(@ApiParam(name = "processInstanceId", value="The id of the process instance to the links for.") @PathVariable String processInstanceId, HttpServletRequest request) { ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId); return restResponseFactory.createRestIdentityLinks(runtimeService.getIdentityLinksForProcessInstance(processInstance.getId())); }
protected String getProcessDisplayName(ProcessDefinition processDefinition, ProcessInstance processInstance) { if(processDefinition.getName() != null) { return processDefinition.getName() + " (" + processInstance.getId() +")"; } else { return processDefinition.getKey() + " (" + processInstance.getId() +")"; } }
protected String getProcessDisplayName(ProcessDefinition processDefinition, ProcessInstance processInstance) { if(processDefinition.getName() != null) { return processDefinition.getName() + " (" + processInstance.getId() +")"; } else { return processDefinition.getKey() + " (" + processInstance.getId() +")"; } }
@Override public void delete(String userId) { abortProcessExecution(userId); getActivitiFacade().deleteHistoricProcessInstance(userId, processInstance.getId()); }
public WorkflowInstance convertAndSetVariables(ProcessInstance instance, Map<String, Object> collectedvariables) { if(instance == null) return null; HistoricProcessInstance historicInstance = historyService .createHistoricProcessInstanceQuery() .processInstanceId(instance.getId()) .singleResult(); return convertToInstanceAndSetVariables(historicInstance, collectedvariables); }
protected void addDeleteButton() { Button deleteProcessInstanceButton = new Button(i18nManager.getMessage(Messages.PROCESS_INSTANCE_DELETE)); deleteProcessInstanceButton.setIcon(Images.DELETE); deleteProcessInstanceButton.addListener(new DeleteProcessInstanceClickListener(processInstance.getId(), processInstancePage)); // Clear toolbar and add 'start' button processInstancePage.getToolBar().removeAllButtons(); processInstancePage.getToolBar().addButton(deleteProcessInstanceButton); }