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


Java Task.getAssignee方法代码示例

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


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

示例1: TaskVo

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
public TaskVo(Task task) {
	this.id = task.getId();
	this.name = task.getName();
	this.title = task.getDescription();
	this.priority = task.getPriority();
	this.owner = task.getOwner();
	this.assignee = task.getAssignee();
	this.processInstanceId = task.getProcessInstanceId();
	this.executionId = task.getExecutionId();
	this.processDefinitionId = task.getProcessDefinitionId();
	this.createTime = task.getCreateTime();
	this.taskDefinitionKey = task.getTaskDefinitionKey();
	this.dueDate = task.getDueDate();
	this.category = task.getCategory();
	this.parentTaskId = task.getParentTaskId();
	this.tenantId = task.getTenantId();
	this.formKey = task.getFormKey();
	this.suspended = task.isSuspended();
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:20,代码来源:TaskVo.java

示例2: setTaskOwner

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
/**
 * @param task Task
 * @param properties Map<QName, Serializable>
 */
private void setTaskOwner(Task task, Map<QName, Serializable> properties)
{
    QName ownerKey = ContentModel.PROP_OWNER;
    if (properties.containsKey(ownerKey))
    {
        Serializable owner = properties.get(ownerKey);
        if (owner != null && !(owner instanceof String))
        {
            throw getInvalidPropertyValueException(ownerKey, owner);
        }
        String assignee = (String) owner;
        String currentAssignee = task.getAssignee();
        // Only set the assignee if the value has changes to prevent
        // triggering assignementhandlers when not needed
        if (ObjectUtils.equals(currentAssignee, assignee)==false)
        {
            activitiUtil.getTaskService().setAssignee(task.getId(), assignee);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ActivitiPropertyConverter.java

示例3: setCurrentTaskInfo

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
/**
 * 获取当前节点信息
 *
 * @return
 */
private void setCurrentTaskInfo(String executionId, String activityId, Map<String, Object> vars) {
    Task currentTask = taskService.createTaskQuery().executionId(executionId)
            .taskDefinitionKey(activityId).singleResult();
    logger.debug("current task for processInstance: {}", ToStringBuilder.reflectionToString(currentTask));

    if (currentTask == null) return;

    String assignee = currentTask.getAssignee();
    if (assignee != null) {
        User assigneeUser = identityService.createUserQuery().userId(assignee).singleResult();
        String userInfo = assigneeUser.getFirstName() + " " + assigneeUser.getLastName() + "/" + assigneeUser.getId();
        vars.put("当前处理人", userInfo);
        vars.put("创建时间", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(currentTask.getCreateTime()));
    } else {
        vars.put("任务状态", "未签收");
    }

}
 
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:24,代码来源:TraceProcessController.java

示例4: endNormalTask

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
private WorkflowTask endNormalTask(String taskId, String localTaskId, String transition)
{
    // Retrieve task
    Task task = taskService.createTaskQuery().taskId(localTaskId).singleResult();
    
    if(task == null)
    {
        String msg = messageService.getMessage(ERR_END_UNEXISTING_TASK, taskId);
        throw new WorkflowException(msg);
    }
    
    // Check if the assignee is equal to the current logged-in user. If not, assign task before ending
    String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser();
    if(task.getAssignee() == null || !task.getAssignee().equals(currentUserName)) {
        taskService.setAssignee(localTaskId, currentUserName);
        // Also update pojo used to set the outcome, this will read assignee as wel
        task.setAssignee(currentUserName);
        
        // Re-fetch the task-entity since it's revision has been updated by the setAssignee() call
        task = taskService.createTaskQuery().taskId(localTaskId).singleResult();
    }
    
    setOutcome(task, transition);
    taskService.complete(localTaskId);
    // The task should have a historicTaskInstance
    HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
    return typeConverter.convert(historicTask);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:ActivitiWorkflowEngine.java

示例5: setCurrentTaskAssignee

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
/**
 * 设置当前处理人信息
 *
 * @param vars
 * @param currentTask
 */
private void setCurrentTaskAssignee(Map<String, Object> vars, Task currentTask) {
    String assignee = currentTask.getAssignee();
    if (assignee != null) {
        User assigneeUser = identityService.createUserQuery().userId(assignee).singleResult();
        String userInfo = assigneeUser.getFirstName() + " " + assigneeUser.getLastName();
        vars.put("当前处理人", userInfo);
    }
}
 
开发者ID:batizhao,项目名称:microservice,代码行数:15,代码来源:WorkflowTraceService.java

示例6: complete

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
@Override
public void complete(String taskId, String userId, String activityId, String nextClaim) {
    Task task = taskService.createTaskQuery().taskId(taskId).includeProcessVariables().active().singleResult();
    if (StringUtils.isNullOrEmpty(task)) {
        logger.warn("任务不存在!");
        throw new NotFoundException("task not found");
    }
    String assignee = task.getAssignee();
    if (StringUtils.isNullOrEmpty(assignee)) {
        logger.warn("请先签收任务!");
        throw new NotFoundException("Please sign for the task first");
    }
    if (!userId.equals(assignee)) {
        logger.warn("只能完成自己的任务");
        throw new NotFoundException("You can only do your own work");
    }
    Map<String, Object> map = new HashMap<>();
    map.put("oldTaskId", task.getId());
    //完成此任务
    if (StringUtils.isNullOrEmpty(activityId)) {
        taskService.complete(taskId, map);
    } else {
        jumpTask(taskId, activityId, nextClaim);
    }
    //根据流程ID查找执行计划,存在则进行下一步,没有则结束(定制化流程预留)
    List<Execution> execution = runtimeService.createExecutionQuery().processInstanceId(task.getProcessInstanceId()).list();
    if (execution.size() > 0) {
        List<Task> tasks = selectNowTask(task.getProcessInstanceId());
        // 自定义下一执行人
        if (tasks.size() == 1 && !StringUtils.isNullOrEmpty(nextClaim)) {
            claim(tasks.get(0).getId(), nextClaim);
        } else {
            for (Task t : tasks) {
                addCandidateUser(t.getId(), t.getTaskDefinitionKey(), userId);
            }
        }
    }
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:39,代码来源:BpmTaskServiceImp.java

示例7: setCurrentTaskAssignee

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
/**
 * 设置当前处理人信息
 * @param vars
 * @param currentTask
 */
private void setCurrentTaskAssignee(Map<String, Object> vars, Task currentTask) {
	String assignee = currentTask.getAssignee();
	if (assignee != null) {
		org.activiti.engine.identity.User assigneeUser = identityService.createUserQuery().userId(assignee).singleResult();
		String userInfo = assigneeUser.getFirstName() + " " + assigneeUser.getLastName();
		vars.put("当前处理人", userInfo);
	}
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:14,代码来源:ActTaskService.java

示例8: TaskExtract

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
TaskExtract(Task task, Map<String, Object> processVariables, List<IdentityLink> taskIdentityLinks) {
	id = task.getId();
	assignee = task.getAssignee();
	name = task.getName();
	processInstanceId = task.getProcessInstanceId();
	createTime = task.getCreateTime();
	dueDate = task.getDueDate();
	owner = task.getOwner();
	executionId = task.getExecutionId();
	variables = new HashMap<>();
	if (task.getProcessVariables() != null) {
		variables.putAll(task.getProcessVariables());
	}
	if (task.getTaskLocalVariables() != null) {
		variables.putAll(task.getTaskLocalVariables());
	}
	candidateUsers = new ArrayList<>();
	candidateGroups = new ArrayList<>();
	for (IdentityLink link : taskIdentityLinks) {
		if (IdentityLinkType.CANDIDATE.equals(link.getType())) {
			if (link.getUserId() != null) {
				candidateUsers.add(link.getUserId());
			} else if (link.getGroupId() != null) {
				candidateGroups.add(link.getGroupId());
			}
		}
	}
	addProcessVariables(processVariables);
	this.taskIdentityLinks = taskIdentityLinks;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:31,代码来源:WorkItemProvider.java

示例9: claimWorkItem

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
public void claimWorkItem(String workItemId, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException {
       OperationResult result = parentResult.createSubresult(OPERATION_CLAIM_WORK_ITEM);
       result.addParam("workItemId", workItemId);
	try {
		MidPointPrincipal principal = securityEnforcer.getPrincipal();
		result.addContext("user", toShortString(principal.getUser()));

		if (LOGGER.isTraceEnabled()) {
			LOGGER.trace("Claiming work item {} by {}", workItemId, toShortString(principal.getUser()));
		}

		TaskService taskService = activitiEngine.getTaskService();
		Task task = taskService.createTaskQuery().taskId(workItemId).singleResult();
		if (task == null) {
			throw new ObjectNotFoundException("The work item does not exist");
		}
		if (task.getAssignee() != null) {
			String desc = MiscDataUtil.stringToRef(task.getAssignee()).getOid().equals(principal.getOid()) ? "the current" : "another";
			throw new SystemException("The work item is already assigned to "+desc+" user");
		}
		if (!miscDataUtil.isAuthorizedToClaim(task.getId())) {
			throw new SecurityViolationException("You are not authorized to claim the selected work item.");
		}
		taskService.claim(workItemId, principal.getOid());
		task = taskService.createTaskQuery().taskId(workItemId).singleResult();
		if (task == null) {
			throw new ObjectNotFoundException("The work item does not exist");
		}
		setNewAssignees(task, Collections.singletonList(ObjectTypeUtil.createObjectRef(principal.getOid(), ObjectTypes.USER)), taskService);
	} catch (ObjectNotFoundException|SecurityViolationException|RuntimeException e) {
		result.recordFatalError("Couldn't claim the work item " + workItemId + ": " + e.getMessage(), e);
		throw e;
	} finally {
		result.computeStatusIfUnknown();
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:37,代码来源:WorkItemManager.java

示例10: setNewAssignees

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
private void setNewAssignees(Task task, List<ObjectReferenceType> assigneeRefList, TaskService taskService) {
   	List<String> assignees = MiscDataUtil.refsToStrings(assigneeRefList);

   	// check and optionally set task assignee
	if (task.getAssignee() != null && !assignees.contains(task.getAssignee())
			|| task.getAssignee() == null && !assignees.isEmpty()) {
		// we will nominate the first delegate (if present) as a new assignee
		taskService.setAssignee(task.getId(), !assignees.isEmpty() ? assignees.get(0) :  null);
	}

	// set task identity links
	List<IdentityLink> currentLinks = taskService.getIdentityLinksForTask(task.getId());
	for (IdentityLink currentLink : currentLinks) {
		if (!CommonProcessVariableNames.MIDPOINT_ASSIGNEE.equals(currentLink.getType())) {
			continue;
		}
		String assigneeFromLink = currentLink.getUserId() != null ? currentLink.getUserId() : currentLink.getGroupId();
		if (assignees.contains(assigneeFromLink)) {
			assignees.remove(assigneeFromLink);
		} else {
			if (currentLink.getUserId() != null) {
				taskService.deleteUserIdentityLink(task.getId(), currentLink.getUserId(), CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
			} else {
				taskService.deleteGroupIdentityLink(task.getId(), currentLink.getGroupId(), CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
			}
		}
	}
	// process remaining assignees
	for (String assignee : assignees) {
		ObjectReferenceType assigneeRef = MiscDataUtil.stringToRef(assignee);
		if (assigneeRef.getType() == null || QNameUtil.match(UserType.COMPLEX_TYPE, assigneeRef.getType())) {
			taskService.addUserIdentityLink(task.getId(), assignee, CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
		} else {
			taskService.addGroupIdentityLink(task.getId(), assignee, CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
		}
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:38,代码来源:WorkItemManager.java

示例11: validateIfUserAllowedToWorkWithProcess

import org.activiti.engine.task.Task; //导入方法依赖的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;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:82,代码来源:WorkflowRestImpl.java

示例12: releaseWorkItem

import org.activiti.engine.task.Task; //导入方法依赖的package包/类
public void releaseWorkItem(String workItemId, OperationResult parentResult) throws ObjectNotFoundException, SecurityViolationException {
      OperationResult result = parentResult.createSubresult(OPERATION_RELEASE_WORK_ITEM);
      result.addParam("workItemId", workItemId);
try {
	MidPointPrincipal principal = securityEnforcer.getPrincipal();
	result.addContext("user", toShortString(principal.getUser()));

	if (LOGGER.isTraceEnabled()) {
		LOGGER.trace("Releasing work item {} by {}", workItemId, toShortString(principal.getUser()));
	}

          TaskService taskService = activitiEngine.getTaskService();
          Task task = taskService.createTaskQuery().taskId(workItemId).singleResult();
          if (task == null) {
		throw new ObjectNotFoundException("The work item does not exist");
          }
          if (task.getAssignee() == null) {
		throw new SystemException("The work item is not assigned to a user");
          }
          if (!MiscDataUtil.stringToRef(task.getAssignee()).getOid().equals(principal.getOid())) {
              throw new SystemException("The work item is not assigned to the current user");
          }
          boolean candidateFound = false;
          for (IdentityLink link : taskService.getIdentityLinksForTask(workItemId)) {
              if (IdentityLinkType.CANDIDATE.equals(link.getType())) {
                  candidateFound = true;
                  break;
              }
          }
          if (!candidateFound) {
              throw new SystemException("It has no candidates to be offered to");
          }
          taskService.unclaim(workItemId);
	task = taskService.createTaskQuery().taskId(workItemId).singleResult();
	if (task == null) {
		throw new ObjectNotFoundException("The work item does not exist");
	}
	setNewAssignees(task, Collections.emptyList(), taskService);
      } catch (ObjectNotFoundException|SecurityViolationException|RuntimeException e) {
          result.recordFatalError("Couldn't release work item " + workItemId + ": " + e.getMessage(), e);
	throw e;
      } finally {
	result.computeStatusIfUnknown();
}
  }
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:46,代码来源:WorkItemManager.java


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