protected void localize(HistoricTaskInstance task) { HistoricTaskInstanceEntity taskEntity = (HistoricTaskInstanceEntity) task; taskEntity.setLocalizedName(null); taskEntity.setLocalizedDescription(null); if (locale != null) { String processDefinitionId = task.getProcessDefinitionId(); if (processDefinitionId != null) { ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && !languageNameNode.isNull()) { taskEntity.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) { taskEntity.setLocalizedDescription(languageDescriptionNode.asText()); } } } } }
assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId()); if (historicTaskInstance.getClaimTime() != null) { assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no work time", historicTaskInstance.getWorkTimeInMillis()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no id", historicTaskInstance.getId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process instance id", historicTaskInstance.getProcessInstanceId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no execution id", historicTaskInstance.getExecutionId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process definition id", historicTaskInstance.getProcessDefinitionId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no task definition key", historicTaskInstance.getTaskDefinitionKey()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no create time", historicTaskInstance.getCreateTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
/** * 流程撤回 TODO MESSAGE 流程撤回需要给相关人员发送消息提醒 * * @param instanceId 历史流程实例ID * @param userId 用户ID * @return */ @Override public Result withdrawTask(String instanceId, String userId) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId (instanceId).singleResult(); Result result = this.canWithdraw(processInstance, userId); if (!result.isSuccess()) { return new Result(false, "不可撤回", "该任务已经被签收或者办理,无法撤回,请查看流程明细"); } else { HistoricTaskInstance taskInstance = (HistoricTaskInstance) result.getData(); final TaskEntity task = (TaskEntity) taskService.createTaskQuery().processInstanceId(instanceId).singleResult(); try { this.jumpTask(task, taskInstance.getTaskDefinitionKey()); //删除历史记录,填充签收人 this.deleteCurrentTaskInstance(task.getId(), taskInstance); return new Result(true); } catch (Exception ex) { return new Result(false, "撤回异常", "任务撤回发生异常,异常原因:" + ex.getMessage()); } } }
public Result deleteCurrentTaskInstance(String taskId, HistoricTaskInstance taskInstance) { //删除正在执行的任务 //删除HistoricTaskInstance String sql_task = "delete from " + managementService.getTableName(HistoricTaskInstance.class) + " where " + "ID_='" + taskId + "' or ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_task); //删除HistoricActivityInstance String sql_activity = "delete from " + managementService.getTableName(HistoricActivityInstance.class) + " where " + "TASK_ID_='" + taskId + "' or TASK_ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_activity); //获取当前的任务,保存签收人 Task task = taskService.createTaskQuery().executionId(taskInstance.getExecutionId()).singleResult(); task.setAssignee(taskInstance.getAssignee()); task.setOwner(taskInstance.getOwner()); taskService.saveTask(task); //解决HistoricActivityInstance的Assignee为空的现象 if (!StrUtil.isEmpty(taskInstance.getAssignee())) { String sql_update = "update " + managementService.getTableName(HistoricActivityInstance.class) + " set " + "ASSIGNEE_='" + taskInstance.getAssignee() + "' where TASK_ID_='" + task.getId() + "'"; this.executeSql(sql_update); } String sql_update_execution = "update " + managementService.getTableName(Execution.class) + " set " + "ACT_ID_='" + taskInstance.getTaskDefinitionKey() + "' where ID_='" + taskInstance.getExecutionId() + "'"; this.executeSql(sql_update_execution); return new Result(true); }
protected void localize(HistoricTaskInstance task) { HistoricTaskInstanceEntity taskEntity = (HistoricTaskInstanceEntity) task; taskEntity.setLocalizedName(null); taskEntity.setLocalizedDescription(null); if (locale != null) { String processDefinitionId = task.getProcessDefinitionId(); if (processDefinitionId != null) { ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && languageNameNode.isNull() == false) { taskEntity.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && languageDescriptionNode.isNull() == false) { taskEntity.setLocalizedDescription(languageDescriptionNode.asText()); } } } } }
protected void localize(HistoricTaskInstance task) { task.setLocalizedName(null); task.setLocalizedDescription(null); if (locale != null) { String processDefinitionId = task.getProcessDefinitionId(); if (processDefinitionId != null) { ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && !languageNameNode.isNull()) { task.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) { task.setLocalizedDescription(languageDescriptionNode.asText()); } } } } }
private WorkflowNode buildHistoricTaskWorkflowNode(HistoricTaskInstance historicTaskInstance) { ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId()); PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey()); return convert(taskActivity); }
private WorkflowNode buildHistoricTaskWorkflowNode(HistoricTaskInstance historicTaskInstance) { ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId()); PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey()); return convert(taskActivity); }
assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId()); if (historicTaskInstance.getClaimTime() != null) { assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no work time", historicTaskInstance.getWorkTimeInMillis()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no id", historicTaskInstance.getId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process instance id", historicTaskInstance.getProcessInstanceId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no execution id", historicTaskInstance.getExecutionId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process definition id", historicTaskInstance.getProcessDefinitionId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no task definition key", historicTaskInstance.getTaskDefinitionKey()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no create time", historicTaskInstance.getCreateTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
@SuppressWarnings("deprecation") public LazyActivitiWorkflowTask(HistoricTaskInstance historicTask, ActivitiTypeConverter typeConverter, TenantService tenantService) { super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, historicTask.getId()), null, null, null, null, null, null, null); this.historicTask = historicTask; this.activitiTypeConverter = typeConverter; this.lazyPropertiesMap = new LazyPropertiesMap(); // Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path) WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(historicTask.getTaskDefinitionKey(), historicTask.getProcessDefinitionId()); String workflowDefinitionName = activitiTypeConverter.getWorkflowDefinitionName(historicTask.getProcessDefinitionId()); workflowDefinitionName = tenantService.getBaseName(workflowDefinitionName); WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(historicTask.getId(), taskDefinition, taskDefinition.getId(), historicTask.getName(), historicTask.getDescription(), WorkflowTaskState.COMPLETED, null, workflowDefinitionName , lazyPropertiesMap); this.definition = taskDefinition; this.name = taskDefinition.getId(); this.title = partiallyInitialized.getTitle(); this.description = partiallyInitialized.getDescription(); this.state = partiallyInitialized.getState(); }
@SuppressWarnings("deprecation") public LazyActivitiWorkflowTask(HistoricTaskInstance historicTask, ActivitiTypeConverter typeConverter, TenantService tenantService) { super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, historicTask.getId()), null, null, null, null, null, null, null); this.historicTask = historicTask; this.activitiTypeConverter = typeConverter; this.lazyPropertiesMap = new LazyPropertiesMap(); // Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path) WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(historicTask.getTaskDefinitionKey(), historicTask.getProcessDefinitionId()); String workflowDefinitionName = activitiTypeConverter.getWorkflowDefinitionName(historicTask.getProcessDefinitionId()); workflowDefinitionName = tenantService.getBaseName(workflowDefinitionName); WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(historicTask.getId(), taskDefinition, taskDefinition.getId(), historicTask.getName(), historicTask.getDescription(), WorkflowTaskState.COMPLETED, null, workflowDefinitionName , lazyPropertiesMap); this.definition = taskDefinition; this.name = taskDefinition.getId(); this.title = partiallyInitialized.getTitle(); this.description = partiallyInitialized.getDescription(); this.state = partiallyInitialized.getState(); }
private TaskInfoBean transToTaskInfoBean(HistoricTaskInstance task) { TaskInfoBean taskInfoBean = new TaskInfoBean(); taskInfoBean.setTaskDefinitionKey(task.getTaskDefinitionKey()); taskInfoBean.setFormKey(task.getFormKey()); taskInfoBean.setProcessDefinitionId(task.getProcessDefinitionId()); taskInfoBean.setProcessInstanceId(task.getProcessInstanceId()); taskInfoBean.setTaskName(task.getName()); taskInfoBean.setTaskId(task.getId()); taskInfoBean.setAssigneeId(task.getAssignee()); taskInfoBean.setTaskCreateTime(task.getCreateTime()); taskInfoBean.setTaskEndTime(task.getEndTime()); taskInfoBean.setTaskOwner(task.getOwner()); HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).includeProcessVariables().singleResult(); taskInfoBean.setItemsName(historicInstance.getProcessDefinitionName()); taskInfoBean.setVariables(historicInstance.getProcessVariables()); return taskInfoBean; }
result.setTaskDefinitionKey(taskInstance.getTaskDefinitionKey()); result.setWorkTimeInMillis(taskInstance.getWorkTimeInMillis()); result.setUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE, taskInstance.getId()));