org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity Java Examples

The following examples show how to use org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckWithdrawTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public HumanTaskDTO createHumanTask(DelegateTask delegateTask,
        HistoricTaskInstanceEntity historicTaskInstanceEntity)
        throws Exception {
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = new HumanTaskBuilder().setDelegateTask(
            delegateTask).build();

    if ("发起流程".equals(historicTaskInstanceEntity.getDeleteReason())) {
        humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    }

    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext()
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(
                    delegateTask.getProcessInstanceId());
    humanTaskDto
            .setProcessStarter(historicProcessInstance.getStartUserId());
    humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);

    return humanTaskDto;
}
 
Example #2
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void recordTaskDefinitionKeyChange(TaskEntity task, String taskDefinitionKey) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, task.getId());
        if (historicTaskInstance != null) {
            historicTaskInstance.setTaskDefinitionKey(taskDefinitionKey);

            if (taskDefinitionKey != null) {
                Expression taskFormExpression = task.getTaskDefinition().getFormKeyExpression();
                if (taskFormExpression != null) {
                    Object formValue = taskFormExpression.getValue(task.getExecution());
                    if (formValue != null) {
                        historicTaskInstance.setFormKey(formValue.toString());
                    }
                }
            }
        }
    }
}
 
Example #3
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 查找回退的目的节点.
 */
public ActivityImpl findTargetActivity(CommandContext commandContext,
        TaskEntity taskEntity) {
    if (activityId == null) {
        String historyTaskId = this.findNearestUserTask(commandContext);
        HistoricTaskInstanceEntity historicTaskInstanceEntity = commandContext
                .getHistoricTaskInstanceEntityManager()
                .findHistoricTaskInstanceById(historyTaskId);
        this.activityId = historicTaskInstanceEntity.getTaskDefinitionKey();
    }

    String processDefinitionId = taskEntity.getProcessDefinitionId();
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(commandContext);

    return processDefinitionEntity.findActivity(activityId);
}
 
Example #4
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 找到想要回退对应的任务历史.
 */
public HistoricTaskInstanceEntity findTargetHistoricTask(
        CommandContext commandContext, TaskEntity taskEntity,
        ActivityImpl activityImpl) {
    HistoricTaskInstanceQueryImpl historicTaskInstanceQueryImpl = new HistoricTaskInstanceQueryImpl();
    historicTaskInstanceQueryImpl.taskDefinitionKey(activityImpl.getId());
    historicTaskInstanceQueryImpl.processInstanceId(taskEntity
            .getProcessInstanceId());
    historicTaskInstanceQueryImpl.setFirstResult(0);
    historicTaskInstanceQueryImpl.setMaxResults(1);
    historicTaskInstanceQueryImpl.orderByTaskCreateTime().desc();

    HistoricTaskInstanceEntity historicTaskInstanceEntity = (HistoricTaskInstanceEntity) commandContext
            .getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstancesByQueryCriteria(
                    historicTaskInstanceQueryImpl).get(0);

    return historicTaskInstanceEntity;
}
 
Example #5
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 创建humanTask.
 */
public HumanTaskDTO createHumanTask(DelegateTask delegateTask,
        HistoricTaskInstanceEntity historicTaskInstanceEntity)
        throws Exception {
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = new HumanTaskBuilder().setDelegateTask(
            delegateTask).build();

    if ("发起流程".equals(historicTaskInstanceEntity.getDeleteReason())) {
        humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    }

    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext()
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(
                    delegateTask.getProcessInstanceId());
    humanTaskDto
            .setProcessStarter(historicProcessInstance.getStartUserId());
    humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);

    return humanTaskDto;
}
 
Example #6
Source File: CheckWithdrawTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 撤销流程.
 */
public Boolean execute(CommandContext commandContext) {
    // 获得历史任务
    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);

    // 获得历史节点
    HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceEntity(historyTaskId);

    Graph graph = new ActivitiHistoryGraphBuilder(
            historicTaskInstanceEntity.getProcessInstanceId()).build();

    Node node = graph.findById(historicActivityInstanceEntity.getId());

    return checkCouldWithdraw(node);
}
 
Example #7
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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());
        }
      }
    }
  }
}
 
Example #8
Source File: WithdrawTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public HumanTaskDTO createHumanTask(DelegateTask delegateTask,
        HistoricTaskInstanceEntity historicTaskInstanceEntity)
        throws Exception {
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = new HumanTaskBuilder().setDelegateTask(
            delegateTask).build();

    if ("发起流程".equals(historicTaskInstanceEntity.getDeleteReason())) {
        humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    }

    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext()
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(
                    delegateTask.getProcessInstanceId());
    humanTaskDto
            .setProcessStarter(historicProcessInstance.getStartUserId());
    humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);

    return humanTaskDto;
}
 
Example #9
Source File: RollbackCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void initSource() {
    // source task
    this.jumpInfo.setSourceTaskId(this.taskId);

    TaskEntity sourceTask = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(this.taskId);
    this.jumpInfo.setSourceTask(sourceTask);

    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration()
            .getDeploymentManager()
            .findDeployedProcessDefinitionById(
                    sourceTask.getProcessDefinitionId());
    // source activity
    this.jumpInfo.setSourceActivityId(sourceTask.getTaskDefinitionKey());
    this.jumpInfo.setSourceActivity(processDefinitionEntity
            .findActivity(this.jumpInfo.getSourceActivityId()));

    HistoricTaskInstanceEntity sourceHistoryTask = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(this.jumpInfo.getSourceTaskId());
}
 
Example #10
Source File: RollbackCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public HumanTaskDTO createHumanTask(DelegateTask delegateTask,
        HistoricTaskInstanceEntity historicTaskInstanceEntity)
        throws Exception {
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = new HumanTaskBuilder().setDelegateTask(
            delegateTask).build();

    if ("发起流程".equals(historicTaskInstanceEntity.getDeleteReason())) {
        humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    }

    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext()
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(
                    delegateTask.getProcessInstanceId());
    humanTaskDto
            .setProcessStarter(historicProcessInstance.getStartUserId());
    humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);

    return humanTaskDto;
}
 
Example #11
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskNameChange(String taskId, String taskName) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setName(taskName);
        }
    }
}
 
Example #12
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskDescriptionChange(String taskId, String description) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setDescription(description);
        }
    }
}
 
Example #13
Source File: DefaultHistoryManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskNameChange(String taskId, String taskName) {
  if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
    HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskInstanceEntityManager().findById(taskId);
    if (historicTaskInstance != null) {
      historicTaskInstance.setName(taskName);
    }
  }
}
 
Example #14
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskDueDateChange(String taskId, Date dueDate) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setDueDate(dueDate);
        }
    }
}
 
Example #15
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskOwnerChange(String taskId, String owner) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setOwner(owner);
        }
    }
}
 
Example #16
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskPriorityChange(String taskId, int priority) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setPriority(priority);
        }
    }
}
 
Example #17
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskFormKeyChange(String taskId, String formKey) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setFormKey(formKey);
        }
    }
}
 
Example #18
Source File: DefaultHistoryManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskDueDateChange(String taskId, Date dueDate) {
  if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
    HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskInstanceEntityManager().findById(taskId);
    if (historicTaskInstance != null) {
      historicTaskInstance.setDueDate(dueDate);
    }
  }
}
 
Example #19
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskCategoryChange(String taskId, String category) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setCategory(category);
        }
    }
}
 
Example #20
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskParentTaskIdChange(String taskId, String parentTaskId) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setParentTaskId(parentTaskId);
        }
    }
}
 
Example #21
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskExecutionIdChange(String taskId, String executionId) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setExecutionId(executionId);
        }
    }
}
 
Example #22
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskProcessDefinitionChange(String taskId, String processDefinitionId) {
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.setProcessDefinitionId(processDefinitionId);
        }
    }
}
 
Example #23
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 判断想要回退的目标节点和当前节点是否在一个分支上.
 */
public boolean isSameBranch(
        HistoricTaskInstanceEntity historicTaskInstanceEntity) {
    TaskEntity taskEntity = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(taskId);

    return taskEntity.getExecutionId().equals(
            historicTaskInstanceEntity.getExecutionId());
}
 
Example #24
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 判断跳过节点.
 */
public boolean isSkipActivity(String historyActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate.queryForObject(
            "SELECT TASK_ID_ FROM ACT_HI_ACTINST WHERE ID_=?",
            String.class, historyActivityId);

    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);
    String deleteReason = historicTaskInstanceEntity.getDeleteReason();

    return "跳过".equals(deleteReason);
}
 
Example #25
Source File: CheckWithdrawTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public boolean isSkipActivity(String historyActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate.queryForObject(
            "select task_id_ from ACT_HI_ACTINST where id_=?",
            String.class, historyActivityId);

    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);
    String deleteReason = historicTaskInstanceEntity.getDeleteReason();

    return "跳过".equals(deleteReason);
}
 
Example #26
Source File: WithdrawTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 撤销流程.
 * 
 * @return 0-撤销成功 1-流程结束 2-下一结点已经通过,不能撤销
 */
public Integer execute(CommandContext commandContext) {
    // 获得历史任务
    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);

    // 获得历史节点
    HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceEntity(historyTaskId);

    Graph graph = new ActivitiHistoryGraphBuilder(
            historicTaskInstanceEntity.getProcessInstanceId()).build();

    Node node = graph.findById(historicActivityInstanceEntity.getId());

    if (!checkCouldWithdraw(node)) {
        logger.info("cannot withdraw {}", historyTaskId);

        return 2;
    }

    // 删除所有活动中的task
    this.deleteActiveTasks(historicTaskInstanceEntity
            .getProcessInstanceId());

    // 获得期望撤销的节点后面的所有节点历史
    List<String> historyNodeIds = new ArrayList<String>();
    this.collectNodes(node, historyNodeIds);
    this.deleteHistoryActivities(historyNodeIds);
    // 恢复期望撤销的任务和历史
    this.processHistoryTask(historicTaskInstanceEntity,
            historicActivityInstanceEntity);

    logger.info("activiti is withdraw {}",
            historicTaskInstanceEntity.getName());

    return 0;
}
 
Example #27
Source File: WithdrawTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public boolean isSkipActivity(String historyActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate.queryForObject(
            "select task_id_ from ACT_HI_ACTINST where id_=?",
            String.class, historyActivityId);

    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);
    String deleteReason = historicTaskInstanceEntity.getDeleteReason();

    return "跳过".equals(deleteReason);
}
 
Example #28
Source File: RollbackCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 校验目标节点是否可以回退.
 */
public boolean validateTargetActivity(String targetActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate
            .queryForObject(
                    "select id_ from ACT_HI_TASKINST where act_id_=? order by END_TIME_ desc",
                    String.class, targetActivityId);

    // 先找到历史任务
    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);

    // 再反向查找历史任务对应的历史节点
    HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceEntity(historyTaskId);

    logger.info("historic activity instance is : {}",
            historicActivityInstanceEntity.getId());

    Graph graph = new ActivitiHistoryGraphBuilder(
            historicTaskInstanceEntity.getProcessInstanceId()).build();

    Node node = graph.findById(historicActivityInstanceEntity.getId());

    if (!this.checkCouldRollback(node)) {
        logger.info("cannot rollback {}", taskId);

        return false;
    }

    return true;
}
 
Example #29
Source File: RollbackCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public boolean isSameBranch(
        HistoricTaskInstanceEntity historicTaskInstanceEntity) {
    TaskEntity taskEntity = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(taskId);

    return taskEntity.getExecutionId().equals(
            historicTaskInstanceEntity.getExecutionId());
}
 
Example #30
Source File: RollbackCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 判断跳过节点.
 */
public boolean isSkipActivity(String historyActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate.queryForObject(
            "select task_id_ from ACT_HI_ACTINST where id_=?",
            String.class, historyActivityId);

    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);
    String deleteReason = historicTaskInstanceEntity.getDeleteReason();

    return "跳过".equals(deleteReason);
}