if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { 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());
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()) { taskEntity.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) { taskEntity.setLocalizedDescription(languageDescriptionNode.asText()); } } } } }
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)); } } } } }
public HistoricTaskInstanceResponse createHistoricTaskInstanceResponse(HistoricTaskInstance taskInstance, RestUrlBuilder urlBuilder) { HistoricTaskInstanceResponse result = new HistoricTaskInstanceResponse(); result.setAssignee(taskInstance.getAssignee()); result.setClaimTime(taskInstance.getClaimTime()); result.setDeleteReason(taskInstance.getDeleteReason()); result.setDescription(taskInstance.getDescription()); result.setDueDate(taskInstance.getDueDate()); result.setDurationInMillis(taskInstance.getDurationInMillis()); result.setEndTime(taskInstance.getEndTime()); result.setExecutionId(taskInstance.getExecutionId()); result.setFormKey(taskInstance.getFormKey()); result.setId(taskInstance.getId()); result.setName(taskInstance.getName()); result.setOwner(taskInstance.getOwner()); result.setParentTaskId(taskInstance.getParentTaskId()); result.setPriority(taskInstance.getPriority()); result.setProcessDefinitionId(taskInstance.getProcessDefinitionId()); result.setTenantId(taskInstance.getTenantId()); result.setCategory(taskInstance.getCategory()); if (taskInstance.getProcessDefinitionId() != null) { result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, taskInstance.getProcessDefinitionId())); result.setProcessInstanceId(taskInstance.getProcessInstanceId()); if (taskInstance.getProcessInstanceId() != null) { result.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, taskInstance.getProcessInstanceId())); result.setStartTime(taskInstance.getStartTime()); result.setTaskDefinitionKey(taskInstance.getTaskDefinitionKey()); result.setWorkTimeInMillis(taskInstance.getWorkTimeInMillis()); result.setUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE, taskInstance.getId()));
protected void addTaskItem(HistoricTaskInstance task, Table taskTable) { Item item = taskTable.addItem(task.getId()); if(task.getEndTime() != null) { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_FINISHED_22)); } else { item.getItemProperty("finished").setValue(new Embedded(null, Images.TASK_22)); } item.getItemProperty("name").setValue(task.getName()); item.getItemProperty("priority").setValue(task.getPriority()); item.getItemProperty("startDate").setValue(new PrettyTimeLabel(task.getStartTime(), true)); item.getItemProperty("endDate").setValue(new PrettyTimeLabel(task.getEndTime(), true)); if(task.getDueDate() != null) { Label dueDateLabel = new PrettyTimeLabel(task.getEndTime(), i18nManager.getMessage(Messages.TASK_NOT_FINISHED_YET), true); item.getItemProperty("dueDate").setValue(dueDateLabel); } if(task.getAssignee() != null) { Component taskAssigneeComponent = getTaskAssigneeComponent(task.getAssignee()); if(taskAssigneeComponent != null) { item.getItemProperty("assignee").setValue(taskAssigneeComponent); } } }
Map<QName, AssociationDefinition> taskAssociations = taskDef.getAssociations(); Map<String, Object> allVariables = getHistoricProcessVariables(historicTask.getProcessInstanceId()); allVariables.putAll(localVariables); properties.put(WorkflowModel.PROP_TASK_ID, historicTask.getId()); properties.put(WorkflowModel.PROP_DESCRIPTION, historicTask.getDescription()); properties.put(WorkflowModel.PROP_START_DATE, historicTask.getStartTime()); properties.put(WorkflowModel.PROP_DUE_DATE, historicTask.getDueDate()); properties.put(WorkflowModel.PROP_COMPLETION_DATE, historicTask.getEndTime()); properties.put(WorkflowModel.PROP_PRIORITY, historicTask.getPriority()); properties.put(ContentModel.PROP_CREATED, historicTask.getStartTime()); properties.put(ContentModel.PROP_OWNER, historicTask.getAssignee());
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; }
public HistoricTaskWrapper(HistoricTaskInstance historicTaskInstance) { this.id = historicTaskInstance.getId(); setName(historicTaskInstance.getName()); setDescription(historicTaskInstance.getDescription()); setDueDate(historicTaskInstance.getDueDate()); setPriority(historicTaskInstance.getPriority()); setOwner(historicTaskInstance.getOwner()); setAssignee(historicTaskInstance.getAssignee()); setTenantId(historicTaskInstance.getTenantId()); setFormKey(historicTaskInstance.getFormKey()); }
@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(); }
if (historicTaskInstances != null && historicTaskInstances.size() > 0) { 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());
if (instances != null) { for (HistoricTaskInstance historicTaskInstance : instances) { List<HistoricVariableInstance> v = historyService.createHistoricVariableInstanceQuery().processInstanceId(historicTaskInstance.getProcessInstanceId()).list(); Map<String, Object> map = new HashMap<String, Object>(); if (v != null) { myTaskHistoryVo.setId(historicTaskInstance.getId()); myTaskHistoryVo.setOid("" + map.get("oid")); myTaskHistoryVo.setName(historicTaskInstance.getName()); myTaskHistoryVo.setProcessDefinitionId(historicTaskInstance.getProcessDefinitionId()); myTaskHistoryVo.setProcessInstanceId(historicTaskInstance.getProcessInstanceId()); myTaskHistoryVo.setStartTime(DateFormat.format(historicTaskInstance.getStartTime()));
@Override public void delete(String id) { if (getHistoryManager().isHistoryEnabled()) { HistoricTaskInstanceEntity historicTaskInstance = findById(id); if (historicTaskInstance != null) { List<HistoricTaskInstanceEntity> subTasks = historicTaskInstanceDataManager.findHistoricTasksByParentTaskId(historicTaskInstance.getId()); for (HistoricTaskInstance subTask: subTasks) { delete(subTask.getId()); } getHistoricDetailEntityManager().deleteHistoricDetailsByTaskId(id); getHistoricVariableInstanceEntityManager().deleteHistoricVariableInstancesByTaskId(id); getCommentEntityManager().deleteCommentsByTaskId(id); getAttachmentEntityManager().deleteAttachmentsByTaskId(id); getHistoricIdentityLinkEntityManager().deleteHistoricIdentityLinksByTaskId(id); delete(historicTaskInstance); } } }
private MutableBpmTask collectHistoryActivity(HistoricTaskInstance task, ProcessInstance pi, UserData user) { MutableBpmTask t = new MutableBpmTask(); t.setProcessInstance(pi); t.setAssignee(user.getLogin()); t.setOwner(user); t.setTaskName(task.getName()); t.setInternalTaskId(null); t.setExecutionId(task.getExecutionId()); t.setCreateDate(task.getStartTime()); t.setFinishDate(task.getEndTime()); t.setFinished(task.getEndTime() != null); return t; }
String taskId = historicTaskInstance.getId(); String title = historicTaskInstance.getName(); String description = historicTaskInstance.getDescription(); String taskName = taskDef.getId();
/** * 判断流程是否可撤回 * 历史流程节点中最后一个审批人是userId */ @Override public Result canWithdraw(HistoricProcessInstance processInstance, String userId) { List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().processUnfinished() .processInstanceId(processInstance.getId()).orderByTaskCreateTime().desc().orderByTaskId().desc() .list(); //Task activeTask=taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); if (taskInstances.isEmpty() || taskInstances.size() < 2) return new Result(false, null, "已办理,不可撤回"); else { HistoricTaskInstance taskInstance = taskInstances.get(1); HistoricTaskInstance taskCurrent = taskInstances.get(0); //流程审批人未未指定(未签收+未办理) if (StrUtil.isEmpty(taskCurrent.getAssignee())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } //流程定义时指定了办理人,也可以撤回 else if (getTaskState(taskCurrent.getId())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } } return new Result(false, null, "任务被签收或办理,不可撤回"); }
public WorkflowPath getWorkflowPath(HistoricTaskInstance historicTaskInstance) { WorkflowPath path = null; // Check to see if the instance is still running Execution execution = activitiUtil.getExecution(historicTaskInstance.getExecutionId()); if(execution != null) { // Process execution still running path = convert(execution); } else { // Process execution is historic path = buildCompletedPath(historicTaskInstance.getExecutionId(), historicTaskInstance.getProcessInstanceId()); } return path; }
Label nameLabel = new Label(historicTask.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 4,0); historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false); dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE); taskDetails.addComponent(dueDateLabel, 1, 1); Integer lowMedHighPriority = convertPriority(historicTask.getPriority()); Label priorityLabel = new Label(); switch(lowMedHighPriority) { historicTask.getStartTime(), "", true); createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME); taskDetails.addComponent(createLabel, 3, 1);
protected void initRelatedContent() { relatedContentLayout = new VerticalLayout(); relatedContentLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); addComponent(relatedContentLayout); initRelatedContentTitle(); List<Attachment> attachments = new ArrayList<Attachment>(); attachments.addAll(taskService.getTaskAttachments(historicTask.getId())); if (historicTask.getProcessInstanceId() != null) { attachments.addAll(taskService.getProcessInstanceAttachments(historicTask.getProcessInstanceId())); } if (!attachments.isEmpty()) { Table table = initRelatedContentTable(); populateRelatedContent(table, attachments); } else { initNoRelatedContentLabel(); } }
private String getOwner() { if(task != null) { return task.getAssignee(); } else { return historicTask.getAssignee(); } } }