本文整理汇总了Java中org.activiti.engine.history.HistoricTaskInstanceQuery.list方法的典型用法代码示例。如果您正苦于以下问题:Java HistoricTaskInstanceQuery.list方法的具体用法?Java HistoricTaskInstanceQuery.list怎么用?Java HistoricTaskInstanceQuery.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.history.HistoricTaskInstanceQuery
的用法示例。
在下文中一共展示了HistoricTaskInstanceQuery.list方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryHistoricTasks
import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
private List<WorkflowTask> queryHistoricTasks(WorkflowTaskQuery query)
{
HistoricTaskInstanceQuery historicQuery = createHistoricTaskQuery(query);
List<HistoricTaskInstance> results;
int limit = query.getLimit();
if (limit > 0)
{
results = historicQuery.listPage(0, limit);
}
else
{
results = historicQuery.list();
}
return getValidHistoricTasks(results);
}
示例2: createHistoryContent
import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
/**
* История выполнения БП.
* Список завершенных задач с указанием времени создания, времени завершения, ответственного.
*
* @return созданный контент
*/
private Component createHistoryContent(final String processId) {
// Получение данных
final HistoryService historyService = lookup(HistoryService.class);
final HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery()
.processInstanceId(processId)
.finished()
.orderByHistoricTaskInstanceEndTime()
.desc();
final List<HistoricTaskInstance> resultList = query.list();
final Panel panel = new Panel("История выполнения БП");
if (!resultList.isEmpty()) {
final Container tableContainer = CollectionContainer.fromBeans(resultList);
final Table table = new Table("Завершенные задачи", tableContainer);
table.setHeight(10, Unit.EM);
table.setVisibleColumns("name", "startTime", "endTime", "assignee", "description");
table.setColumnHeader("name", "Имя задачи");
table.setColumnHeader("startTime", "Старт задачи");
table.setColumnHeader("endTime", "Завершение задачи");
table.setColumnHeader("assignee", "Ответственный");
table.setConverter("assignee", lookup(LoginToUserNameConverter.class));
table.setColumnHeader("description", "Описание задачи");
panel.setContent(table);
} else {
panel.setContent(new Label("Нет истории задач для бизнес процесса (Первая задача?)"));
}
return panel;
}
示例3: queryLastTask
import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
private HistoricTaskInstance queryLastTask(final String processId) {
final HistoryService historyService = lookup(HistoryService.class);
final HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery()
.processInstanceId(processId)
.finished()
.orderByHistoricTaskInstanceEndTime()
.desc();
final List<HistoricTaskInstance> resultList = query.list();
return resultList.isEmpty() ? null : resultList.get(0);
}
示例4: validateIfUserAllowedToWorkWithProcess
import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
/**
* Validates if the logged in user is allowed to get information about a specific process instance.
* If the user is not allowed an exception is thrown.
*
* @param processId identifier of the process instance
*/
protected List<HistoricVariableInstance> validateIfUserAllowedToWorkWithProcess(String processId)
{
List<HistoricVariableInstance> variableInstances = activitiProcessEngine.getHistoryService()
.createHistoricVariableInstanceQuery()
.processInstanceId(processId)
.list();
Map<String, Object> variableMap = new HashMap<String, Object>();
if (variableInstances != null && variableInstances.size() > 0)
{
for (HistoricVariableInstance variableInstance : variableInstances)
{
variableMap.put(variableInstance.getVariableName(), variableInstance.getValue());
}
}
else
{
throw new EntityNotFoundException(processId);
}
if (tenantService.isEnabled())
{
String tenantDomain = (String) variableMap.get(ActivitiConstants.VAR_TENANT_DOMAIN);
if (TenantUtil.getCurrentDomain().equals(tenantDomain) == false)
{
throw new PermissionDeniedException("Process is running in another tenant");
}
}
//MNT-17918 - required for initiator variable already updated as NodeRef type
Object initiator = variableMap.get(WorkflowConstants.PROP_INITIATOR);
String nodeId = ((initiator instanceof ActivitiScriptNode) ? ((ActivitiScriptNode) initiator).getNodeRef().getId() : ((NodeRef) initiator).getId());
if (initiator != null && AuthenticationUtil.getRunAsUser().equals(nodeId))
{
// user is allowed
return variableInstances;
}
String username = AuthenticationUtil.getRunAsUser();
if (authorityService.isAdminAuthority(username))
{
// Admin is allowed to read all processes in the current tenant
return variableInstances;
}
else
{
// MNT-12382 check for membership in the assigned group
ActivitiScriptNode group = (ActivitiScriptNode) variableMap.get("bpm_groupAssignee");
if (group != null)
{
// check that the process is unclaimed
Task task = activitiProcessEngine.getTaskService().createTaskQuery().processInstanceId(processId).singleResult();
if ((task != null) && (task.getAssignee() == null) && isUserInGroup(username, group.getNodeRef()))
{
return variableInstances;
}
}
// If non-admin user, involvement in the task is required (either owner, assignee or externally involved).
HistoricTaskInstanceQuery query = activitiProcessEngine.getHistoryService()
.createHistoricTaskInstanceQuery()
.processInstanceId(processId)
.taskInvolvedUser(AuthenticationUtil.getRunAsUser());
List<HistoricTaskInstance> taskList = query.list();
if (org.apache.commons.collections.CollectionUtils.isEmpty(taskList))
{
throw new PermissionDeniedException("user is not allowed to access information about process " + processId);
}
}
return variableInstances;
}
示例5: validateIfUserAllowedToWorkWithProcess
import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
/**
* Validates if the logged in user is allowed to get information about a specific process instance.
* If the user is not allowed an exception is thrown.
*
* @param processId identifier of the process instance
*/
protected List<HistoricVariableInstance> validateIfUserAllowedToWorkWithProcess(String processId)
{
List<HistoricVariableInstance> variableInstances = activitiProcessEngine.getHistoryService()
.createHistoricVariableInstanceQuery()
.processInstanceId(processId)
.list();
Map<String, Object> variableMap = new HashMap<String, Object>();
if (variableInstances != null && variableInstances.size() > 0)
{
for (HistoricVariableInstance variableInstance : variableInstances)
{
variableMap.put(variableInstance.getVariableName(), variableInstance.getValue());
}
}
else
{
throw new EntityNotFoundException(processId);
}
if (tenantService.isEnabled())
{
String tenantDomain = (String) variableMap.get(ActivitiConstants.VAR_TENANT_DOMAIN);
if (TenantUtil.getCurrentDomain().equals(tenantDomain) == false)
{
throw new PermissionDeniedException("Process is running in another tenant");
}
}
ActivitiScriptNode initiator = (ActivitiScriptNode) variableMap.get(WorkflowConstants.PROP_INITIATOR);
if (initiator != null && AuthenticationUtil.getRunAsUser().equals(initiator.getNodeRef().getId()))
{
// user is allowed
return variableInstances;
}
String username = AuthenticationUtil.getRunAsUser();
if (authorityService.isAdminAuthority(username))
{
// Admin is allowed to read all processes in the current tenant
return variableInstances;
}
else
{
// MNT-12382 check for membership in the assigned group
ActivitiScriptNode group = (ActivitiScriptNode) variableMap.get("bpm_groupAssignee");
if (group != null)
{
// check that the process is unclaimed
Task task = activitiProcessEngine.getTaskService().createTaskQuery().processInstanceId(processId).singleResult();
if ((task != null) && (task.getAssignee() == null) && isUserInGroup(username, group.getNodeRef()))
{
return variableInstances;
}
}
// If non-admin user, involvement in the task is required (either owner, assignee or externally involved).
HistoricTaskInstanceQuery query = activitiProcessEngine.getHistoryService()
.createHistoricTaskInstanceQuery()
.processInstanceId(processId)
.taskInvolvedUser(AuthenticationUtil.getRunAsUser());
List<HistoricTaskInstance> taskList = query.list();
if (org.apache.commons.collections.CollectionUtils.isEmpty(taskList))
{
throw new PermissionDeniedException("user is not allowed to access information about process " + processId);
}
}
return variableInstances;
}