当前位置: 首页>>代码示例>>Java>>正文


Java HistoricTaskInstanceQuery.singleResult方法代码示例

本文整理汇总了Java中org.activiti.engine.history.HistoricTaskInstanceQuery.singleResult方法的典型用法代码示例。如果您正苦于以下问题:Java HistoricTaskInstanceQuery.singleResult方法的具体用法?Java HistoricTaskInstanceQuery.singleResult怎么用?Java HistoricTaskInstanceQuery.singleResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.engine.history.HistoricTaskInstanceQuery的用法示例。


在下文中一共展示了HistoricTaskInstanceQuery.singleResult方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHistoricTaskInstance

import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
/**
 * @param localId String
 * @return HistoricTaskInstance
 */
public HistoricTaskInstance getHistoricTaskInstance(String localId)
{
    HistoricTaskInstanceQuery taskQuery =  historyService.createHistoricTaskInstanceQuery()
        .taskId(localId);
    if(!deployWorkflowsInTenant) {
    	taskQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
    }
    return taskQuery.singleResult();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:ActivitiUtil.java

示例2: getPreTask

import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
@Override
public TaskEx getPreTask(String taskId) {
	HistoricTaskInstanceQuery query = historyService
			.createHistoricTaskInstanceQuery().taskId(taskId);
	HistoricTaskInstance hti = query.singleResult();
	Task hiTask = taskService.createTaskQuery().taskId(hti.getId())
			.singleResult();
	return null;
}
 
开发者ID:lz84,项目名称:bachelor,代码行数:10,代码来源:BpmHistoryTaskService.java

示例3: getValidHistoricTask

import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
/**
 * Get a valid {@link HistoricTaskInstance} based on the given task id. Checks if current logged
 * in user is assignee/owner/involved with the task. In case true was passed for "validIfClaimable", 
 * the task is also valid if the current logged in user is a candidate for claiming the task.
 *  
 * @throws EntityNotFoundException when the task was not found
 * @throws PermissionDeniedException when the current logged in user isn't allowed to access task.
 */
protected HistoricTaskInstance getValidHistoricTask(String taskId)
{
    HistoricTaskInstanceQuery query = activitiProcessEngine.getHistoryService()
        .createHistoricTaskInstanceQuery()
        .taskId(taskId);
    
    if (authorityService.isAdminAuthority(AuthenticationUtil.getRunAsUser())) 
    {
        // Admin is allowed to read all tasks in the current tenant
        if (tenantService.isEnabled()) 
        {
            query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
        }
    }
    else
    {
        // If non-admin user, involvement in the task is required (either owner, assignee or externally involved).
        query.taskInvolvedUser(AuthenticationUtil.getRunAsUser());
    }
    
    HistoricTaskInstance taskInstance = query.singleResult();
    
    if (taskInstance == null) 
    {
        // Either the task doesn't exist or the user is not involved directly. We can differentiate by
        // checking if the task exists without applying the additional filtering
        taskInstance =  activitiProcessEngine.getHistoryService()
            .createHistoricTaskInstanceQuery()
            .taskId(taskId)
            .singleResult();
        
        if (taskInstance == null) 
        {
            // Full error message will be "Task with id: 'id' was not found" 
            throw new EntityNotFoundException(taskId); 
        }
        else
        {
            boolean isTaskClaimable = false;
            if (taskInstance.getEndTime() == null) 
            {
                // Task is not yet finished, so potentially claimable. If user is part of a "candidateGroup", the task is accessible to the
                // user regardless of not being involved/owner/assignee
                isTaskClaimable = activitiProcessEngine.getTaskService()
                        .createTaskQuery()
                        .taskCandidateGroupIn(new ArrayList<String>(authorityService.getAuthoritiesForUser(AuthenticationUtil.getRunAsUser())))
                        .taskId(taskId)
                        .count() == 1;
            }
            
            if (isTaskClaimable == false)
            {
                throw new PermissionDeniedException();
            }
        }
    }
    return taskInstance;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:67,代码来源:TasksImpl.java

示例4: getVariableFromRequest

import org.activiti.engine.history.HistoricTaskInstanceQuery; //导入方法依赖的package包/类
protected RestVariable getVariableFromRequest(boolean includeBinary, String taskId, String variableName, String scope) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    RestVariable.RestVariableScope variableScope = RestVariable.getScopeFromString(scope);
    HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskId(taskId);

    if (variableScope != null) {
        if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
            taskQuery.includeProcessVariables();
        } else {
            taskQuery.includeTaskLocalVariables();
        }
    } else {
        taskQuery.includeTaskLocalVariables().includeProcessVariables();
    }

    HistoricTaskInstance taskObject = taskQuery.singleResult();

    if (taskObject == null) {
        throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' couldn't be found.", HistoricTaskInstanceEntity.class);
    }

    Object value = null;
    if (variableScope != null) {
        if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
            value = taskObject.getProcessVariables().get(variableName);
        } else {
            value = taskObject.getTaskLocalVariables().get(variableName);
        }
    } else {
        // look for local task restVariables first
        if (taskObject.getTaskLocalVariables().containsKey(variableName)) {
            value = taskObject.getTaskLocalVariables().get(variableName);
        } else {
            value = taskObject.getProcessVariables().get(variableName);
        }
    }

    if (value == null) {
        throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class);
    } else {
        return new RestResponseFactory().createRestVariable(variableName, value, null, taskId,
                RestResponseFactory.VARIABLE_HISTORY_TASK, includeBinary, uriInfo.getBaseUri().toString());
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:45,代码来源:HistoricTaskInstanceService.java


注:本文中的org.activiti.engine.history.HistoricTaskInstanceQuery.singleResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。