本文整理汇总了Java中org.activiti.engine.history.HistoricTaskInstance.getTaskDefinitionKey方法的典型用法代码示例。如果您正苦于以下问题:Java HistoricTaskInstance.getTaskDefinitionKey方法的具体用法?Java HistoricTaskInstance.getTaskDefinitionKey怎么用?Java HistoricTaskInstance.getTaskDefinitionKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.history.HistoricTaskInstance
的用法示例。
在下文中一共展示了HistoricTaskInstance.getTaskDefinitionKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Task
import org.activiti.engine.history.HistoricTaskInstance; //导入方法依赖的package包/类
public Task(HistoricTaskInstance taskInstance)
{
this.id = taskInstance.getId();
this.processId = taskInstance.getProcessInstanceId();
this.processDefinitionId = taskInstance.getProcessDefinitionId();
this.activityDefinitionId = taskInstance.getTaskDefinitionKey();
this.name = taskInstance.getName();
this.description = taskInstance.getDescription();
this.dueAt = taskInstance.getDueDate();
this.startedAt = taskInstance.getStartTime();
this.endedAt = taskInstance.getEndTime();
this.durationInMs = taskInstance.getDurationInMillis();
this.priority = taskInstance.getPriority();
this.owner = taskInstance.getOwner();
this.assignee = taskInstance.getAssignee();
this.formResourceKey = taskInstance.getFormKey();
if (taskInstance.getEndTime() != null)
{
this.state = TaskStateTransition.COMPLETED.name().toLowerCase();
}
else if (taskInstance.getAssignee() != null)
{
this.state = TaskStateTransition.CLAIMED.name().toLowerCase();
}
else
{
this.state = TaskStateTransition.UNCLAIMED.name().toLowerCase();
}
}
示例2: deleteCurrentTaskInstance
import org.activiti.engine.history.HistoricTaskInstance; //导入方法依赖的package包/类
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);
}
示例3: viewHistoryTask
import org.activiti.engine.history.HistoricTaskInstance; //导入方法依赖的package包/类
/**
* 查看已结束任务
*/
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
String viewName = "chapter6/task-form-archived";
ModelAndView mav = new ModelAndView(viewName);
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
if (task.getParentTaskId() != null) {
HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
mav.addObject("parentTask", parentTask);
}
mav.addObject("task", task);
// 读取子任务
List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
mav.addObject("subTasks", subTasks);
// 读取附件
List<Attachment> attachments = null;
if (task.getTaskDefinitionKey() != null) {
attachments = taskService.getTaskAttachments(taskId);
} else {
attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
}
mav.addObject("attachments", attachments);
return mav;
}
示例4: avgTaskTimeDurationForCompletedProcesses
import org.activiti.engine.history.HistoricTaskInstance; //导入方法依赖的package包/类
/**
* Average task duration for completed processes
*
* @param pId processDefintionId of the process selected to view the average time duration for each task
* @return list of completed tasks with the average time duration for the selected process
*/
@GET
@Path("/task-instances/duration/avarage/{pid}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseHolder avgTaskTimeDurationForCompletedProcesses(@PathParam("pid") String pId) {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
HistoryService historyService = BPMNOSGIService.getHistoryService();
long processCount = repositoryService.createProcessDefinitionQuery().
processDefinitionTenantId(getTenantIdStr()).processDefinitionId(pId).count();
if (processCount == 0) {
throw new ActivitiObjectNotFoundException("Count not find a matching process with PID '" +
pId + "'.");
}
ResponseHolder response = new ResponseHolder();
List<Object> taskListForProcess = new ArrayList<>();
HashMap<String, Long> map = new HashMap<>();
//Get the number of completed/finished process instance for each process definition
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService
.createHistoricProcessInstanceQuery().processInstanceTenantId(getTenantIdStr())
.processDefinitionId(pId).finished();
//Get the count of the complete process instances
long noOfHistoricInstances = historicProcessInstanceQuery.count();
//If the deployed process does not have any completed process instances --> Ignore
if (noOfHistoricInstances == 0) {
response.setData(taskListForProcess);
}
//If the deployed process has completed process instances --> then
else {
TaskInstanceAverageInfo tInstance;
//Get the list of completed tasks/activities in the completed process instance by passing the
//process definition id of the process
List<HistoricTaskInstance> taskList = BPMNOSGIService.getHistoryService().
createHistoricTaskInstanceQuery().taskTenantId(getTenantIdStr()).processDefinitionId(pId)
.processFinished().list();
//Iterate through each completed task/activity and get the task name and duration
for (HistoricTaskInstance taskInstance : taskList) {
//Get the task name
String taskKey = taskInstance.getTaskDefinitionKey();
//Get the time duration taken for the task to be completed
long taskDuration = taskInstance.getDurationInMillis();
if (map.containsKey(taskKey)) {
long tt = map.get(taskKey);
map.put(taskKey, taskDuration + tt);
} else {
map.put(taskKey, taskDuration);
}
//Iterating Task List finished
}
Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next().toString();
double value = map.get(key) / noOfHistoricInstances;
tInstance = new TaskInstanceAverageInfo();
tInstance.setTaskDefinitionKey(key);
tInstance.setAverageTimeForCompletion(value);
taskListForProcess.add(tInstance);
}
response.setData(taskListForProcess);
}
return response;
}