activiti 更新act_hi_taskinst表DELETE_REASON_

 

由于activiti对于act_hi_taskinst表中的DELETE_REASON_列值是有限的,DELETE_REASON_类代表任务的完成原因,比如completed或者delete,因此我们在任意节点跳转或者撤销的时候,必须标记该字段,比如撤销可以标记可以定义为Revoke、跳转可以标记为jump等等。

写一个命令类如下:

public class UpdateHiTaskReasonCommand implements Command {
	protected String taskId;
	protected String deleteReason;

	public UpdateHiTaskReasonCommand(String taskId, String deleteReason) {
		this.taskId = taskId;
		this.deleteReason = deleteReason;
	}
	@Override
	public Void execute(CommandContext commandContext) {
		HistoricTaskInstanceEntity historicTaskInstance = commandContext
				.getDbSqlSession().selectById(HistoricTaskInstanceEntity.class,taskId);
		if (historicTaskInstance != null) {
			historicTaskInstance.markEnded(deleteReason);
		}
		return null;
	}
}

关于historicTaskInstance.markEnded(deleteReason)操作之后数据库的数据就会更新,可以参考Activiti权威指南一书中的会话缓存章节

 

你可能感兴趣的:(activiti)