org.activiti.engine.impl.persistence.entity.TaskEntity Java Examples

The following examples show how to use org.activiti.engine.impl.persistence.entity.TaskEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskDelagationAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void retrieveCandidateUserIdsAndGroupIds(TaskEntity task, Map<String, Object> userIdMap,
		Map<String, Object> groupIdMap)
{
	for (IdentityLink link : task.getCandidates())
	{
		String userId = link.getUserId();
		if (userId != null)
		{
			userIdMap.put(userId, 0);
		}

		String groupId = link.getGroupId();
		if (groupId != null)
		{
			groupIdMap.put(groupId, 0);
		}
	}
}
 
Example #2
Source File: TaskDelagationAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void handleAssignment(TaskAssignmentHandlerChain chain, Expression assigneeExpression,
		Expression ownerExpression, Set<Expression> candidateUserExpressions,
		Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
{
	//先执行其它规则
	chain.resume(assigneeExpression, ownerExpression, candidateUserExpressions,
		      candidateGroupExpressions, task, execution);

	overwriteAssignee(task);

	Map<String, Object> userIdMap = new HashMap<String, Object>();
	Map<String, Object> groupIdMap = new HashMap<String, Object>();
	retrieveCandidateUserIdsAndGroupIds(task, userIdMap, groupIdMap);
	Map<String, Object> newUserIdMap = new HashMap<String, Object>();
	Map<String, Object> removeUserIdMap = new HashMap<String, Object>();

	//遍历所有的被代理人
	List<DelegationEntity> entries = _delegationManager.listDelegationEntities();
	overwriteCandicateUserIds(userIdMap, newUserIdMap, removeUserIdMap, entries);
	overwriteCandicateGroupIds(groupIdMap, newUserIdMap, entries);

	addCandidateUsers(task, newUserIdMap.keySet());
	removeCandidateUsers(task, removeUserIdMap.keySet());
}
 
Example #3
Source File: DefaultActiviti5CompatibilityHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected org.activiti5.engine.impl.persistence.entity.TaskEntity convertToActiviti5TaskEntity(TaskEntity task) {
  org.activiti5.engine.impl.persistence.entity.TaskEntity activiti5Task = new org.activiti5.engine.impl.persistence.entity.TaskEntity();
  activiti5Task.setAssigneeWithoutCascade(task.getAssignee());
  activiti5Task.setInitialAssignee( ((TaskEntityImpl) task).getOriginalAssignee());
  activiti5Task.setCategoryWithoutCascade(task.getCategory());
  activiti5Task.setCreateTime(task.getCreateTime());
  activiti5Task.setDelegationStateString(((TaskEntityImpl)task).getDelegationStateString());
  activiti5Task.setDescriptionWithoutCascade(task.getDescription());
  activiti5Task.setDueDateWithoutCascade(task.getDueDate());
  activiti5Task.setExecutionId(task.getExecutionId());
  activiti5Task.setFormKeyWithoutCascade(task.getFormKey());
  activiti5Task.setId(task.getId());
  activiti5Task.setNameWithoutCascade(task.getName());
  activiti5Task.setOwnerWithoutCascade(task.getOwner());
  activiti5Task.setParentTaskIdWithoutCascade(task.getParentTaskId());
  activiti5Task.setPriorityWithoutCascade(task.getPriority());
  activiti5Task.setProcessDefinitionId(task.getProcessDefinitionId());
  activiti5Task.setProcessInstanceId(task.getProcessInstanceId());
  activiti5Task.setRevision(task.getRevision());
  activiti5Task.setTaskDefinitionKeyWithoutCascade(task.getTaskDefinitionKey());
  activiti5Task.setTenantId(task.getTenantId());
  return activiti5Task;
}
 
Example #4
Source File: TaskCollectionResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Create Task", tags = {"Tasks"})
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "Indicates request was successful and the tasks are returned"),
    @ApiResponse(code = 400, message = "Indicates a parameter was passed in the wrong format or that delegationState has an invalid value (other than pending and resolved). The status-message contains additional information.")
})
@RequestMapping(value = "/runtime/tasks", method = RequestMethod.POST, produces = "application/json")
public TaskResponse createTask(@RequestBody TaskRequest taskRequest, HttpServletRequest request, HttpServletResponse response) {

  Task task = taskService.newTask();

  // Populate the task properties based on the request
  populateTaskFromRequest(task, taskRequest);
  if (taskRequest.isTenantIdSet()) {
    ((TaskEntity) task).setTenantId(taskRequest.getTenantId());
  }
  taskService.saveTask(task);

  response.setStatus(HttpStatus.CREATED.value());
  return restResponseFactory.createTaskResponse(task);
}
 
Example #5
Source File: GetTaskFormCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public TaskFormData execute(CommandContext commandContext) {
    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("No task found for taskId '" + taskId + "'", Task.class);
    }

    if (task.getTaskDefinition() != null) {
        TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
        if (taskFormHandler == null) {
            throw new ActivitiException("No taskFormHandler specified for task '" + taskId + "'");
        }

        return taskFormHandler.createTaskForm(task);
    } else {
        // Standalone task, no TaskFormData available
        return null;
    }
}
 
Example #6
Source File: RemoveTaskVariablesCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected Void execute(CommandContext commandContext, TaskEntity task) {

    if (task.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {
      Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
      activiti5CompatibilityHandler.removeTaskVariables(taskId, variableNames, isLocal);
      return null;
    }
    
    if (isLocal) {
      task.removeVariablesLocal(variableNames);
    } else {
      task.removeVariables(variableNames);
    }

    return null;
  }
 
Example #7
Source File: DeleteRunningTaskCmd.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Void execute(CommandContext commandContext)
{
	//删除当前的任务
	//不能删除当前正在执行的任务,所以要先清除掉关联
	if (_currentTaskEntity != null)
	{
		Logger.getLogger(DefaultTaskFlowControlService.class).debug(
			String.format("deleting task: %s [id=%s]", _currentTaskEntity.getName(), _currentTaskEntity.getId()));

		Context.getCommandContext().getTaskEntityManager()
				.deleteTask(_currentTaskEntity, TaskEntity.DELETE_REASON_DELETED, false);
	}

	return null;
}
 
Example #8
Source File: VariableScopeResolver.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public VariableScopeResolver(ProcessEngineConfigurationImpl processEngineConfiguration, VariableScope variableScope) {
  
  this.processEngineConfiguration = processEngineConfiguration;
  
  if (variableScope == null) {
    throw new ActivitiIllegalArgumentException("variableScope cannot be null");
  }
  if (variableScope instanceof ExecutionEntity) {
    variableScopeKey = "execution";
  } else if (variableScope instanceof TaskEntity) {
    variableScopeKey = "task";
  } else {
    throw new ActivitiException("unsupported variable scope type: " + variableScope.getClass().getName());
  }
  this.variableScope = variableScope;
}
 
Example #9
Source File: DeleteTaskWithCommentCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
    TaskEntity taskEntity = commandContext.getTaskEntityManager()
            .findTaskById(taskId);

    // taskEntity.fireEvent(TaskListener.EVENTNAME_COMPLETE);
    if ((Authentication.getAuthenticatedUserId() != null)
            && (taskEntity.getProcessInstanceId() != null)) {
        taskEntity.getProcessInstance().involveUser(
                Authentication.getAuthenticatedUserId(),
                IdentityLinkType.PARTICIPANT);
    }

    Context.getCommandContext().getTaskEntityManager()
            .deleteTask(taskEntity, comment, false);

    if (taskEntity.getExecutionId() != null) {
        ExecutionEntity execution = taskEntity.getExecution();
        execution.removeTask(taskEntity);

        // execution.signal(null, null);
    }

    return null;
}
 
Example #10
Source File: HasTaskVariableCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean execute(CommandContext commandContext) {
    if (taskId == null) {
        throw new ActivitiIllegalArgumentException("taskId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }

    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);

    if (task == null) {
        throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
    }
    boolean hasVariable = false;

    if (isLocal) {
        hasVariable = task.hasVariableLocal(variableName);
    } else {
        hasVariable = task.hasVariable(variableName);
    }

    return hasVariable;
}
 
Example #11
Source File: GetTaskVariableCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("taskId is null");
  }
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }

  TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);

  if (task == null) {
    throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
  }

  Object value;

  if (isLocal) {
    value = task.getVariableLocal(variableName, false);
  } else {
    value = task.getVariable(variableName, false);
  }

  return value;
}
 
Example #12
Source File: SkipEventListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void onEvent(ActivitiEvent event) {
    if (!(event instanceof ActivitiEntityEventImpl)) {
        return;
    }

    ActivitiEntityEventImpl activitiEntityEventImpl = (ActivitiEntityEventImpl) event;
    Object entity = activitiEntityEventImpl.getEntity();

    if (!(entity instanceof TaskEntity)) {
        return;
    }

    TaskEntity taskEntity = (TaskEntity) entity;

    try {
        switch (event.getType()) {
        case TASK_CREATED:
            logger.debug("create : {}", taskEntity.getId());
            this.onCreate(taskEntity);

            break;
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example #13
Source File: ChangeSubTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void createSubTask(TaskEntity parentTask, String assignee) {
    TaskEntity task = TaskEntity.create(new Date());
    task.setProcessDefinitionId(parentTask.getProcessDefinitionId());
    // task.setId(historicTaskInstanceEntity.getId());
    task.setAssigneeWithoutCascade(assignee);
    task.setParentTaskIdWithoutCascade(parentTask.getId());
    task.setNameWithoutCascade(parentTask.getName());
    task.setTaskDefinitionKey(parentTask.getTaskDefinitionKey());
    task.setExecutionId(parentTask.getExecutionId());
    task.setPriority(parentTask.getPriority());
    task.setProcessInstanceId(parentTask.getProcessInstanceId());
    task.setDescriptionWithoutCascade(parentTask.getDescription());
    task.setCategory("subtask");

    Context.getCommandContext().getTaskEntityManager().insert(task);
}
 
Example #14
Source File: TaskCompletedEventHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {

    FlowableEntityWithVariablesEvent eventWithVariables = (FlowableEntityWithVariablesEvent) event;
    TaskEntity task = (TaskEntity) eventWithVariables.getEntity();
    Map<String, Object> data = handleCommonTaskFields(task);

    long duration = timeStamp.getTime() - task.getCreateTime().getTime();
    putInMapIfNotNull(data, Fields.DURATION, duration);

    if (eventWithVariables.getVariables() != null && !eventWithVariables.getVariables().isEmpty()) {
        Map<String, Object> variableMap = new HashMap<>();
        for (Object variableName : eventWithVariables.getVariables().keySet()) {
            putInMapIfNotNull(variableMap, (String) variableName, eventWithVariables.getVariables().get(variableName));
        }
        if (eventWithVariables.isLocalScope()) {
            putInMapIfNotNull(data, Fields.LOCAL_VARIABLES, variableMap);
        } else {
            putInMapIfNotNull(data, Fields.VARIABLES, variableMap);
        }
    }

    return createEventLogEntry(task.getProcessDefinitionId(), task.getProcessInstanceId(), task.getExecutionId(), task.getId(), data);
}
 
Example #15
Source File: DefaultTaskFlowControlService.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 分裂某节点为多实例节点
 * 
 * @param targetTaskDefinitionKey
 * @param assignee
 * @throws IOException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
@Override
public ActivityImpl split(String targetTaskDefinitionKey, boolean isSequential, String... assignees)
		throws Exception
{
	SimpleRuntimeActivityDefinitionEntity info = new SimpleRuntimeActivityDefinitionEntity();
	info.setProcessDefinitionId(_processDefinition.getId());
	info.setProcessInstanceId(_processInstanceId);

	RuntimeActivityDefinitionEntityIntepreter radei = new RuntimeActivityDefinitionEntityIntepreter(info);

	radei.setPrototypeActivityId(targetTaskDefinitionKey);
	radei.setAssignees(CollectionUtils.arrayToList(assignees));
	radei.setSequential(isSequential);

	ActivityImpl clone = new MultiInstanceActivityCreator().createActivities(_processEngine, _processDefinition,
		info)[0];

	TaskEntity currentTaskEntity = getCurrentTask();
	executeCommand(new CreateAndTakeTransitionCmd(currentTaskEntity.getExecutionId(), clone));
	executeCommand(new DeleteRunningTaskCmd(currentTaskEntity));

	recordActivitiesCreation(info);
	return clone;
}
 
Example #16
Source File: JumpToActivityCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
    for (TaskEntity taskEntity : commandContext.getTaskEntityManager()
            .findTasksByExecutionId(executionId)) {
        taskEntity.setVariableLocal("跳转原因", jumpOrigin);
        commandContext.getTaskEntityManager().deleteTask(taskEntity,
                jumpOrigin, false);
    }

    ExecutionEntity executionEntity = commandContext
            .getExecutionEntityManager().findExecutionById(executionId);
    ProcessDefinitionImpl processDefinition = executionEntity
            .getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(activityId);

    executionEntity.executeActivity(activity);

    return null;
}
 
Example #17
Source File: GetTaskVariableInstanceCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public VariableInstance execute(CommandContext commandContext) {
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("taskId is null");
  }
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }

  TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);

  if (task == null) {
    throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
  }

  VariableInstance variableEntity;

  if (isLocal) {
    variableEntity = task.getVariableInstanceLocal(variableName, false);
  } else {
    variableEntity = task.getVariableInstance(variableName, false);
  }

  return variableEntity;
}
 
Example #18
Source File: HasTaskVariableCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public Boolean execute(CommandContext commandContext) {
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("taskId is null");
  }
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }

  TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);

  if (task == null) {
    throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
  }
  boolean hasVariable = false;

  if (isLocal) {
    hasVariable = task.hasVariableLocal(variableName);
  } else {
    hasVariable = task.hasVariable(variableName);
  }

  return hasVariable;
}
 
Example #19
Source File: TaskCompleteListener.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void addPooledActorsAsVariable(DelegateTask task,
            Map<String, Object> variables) 
{
    List<IdentityLinkEntity> links = ((TaskEntity)task).getIdentityLinks();
    if (links.size() > 0)
    {
        // Add to list of IdentityLink
        List<IdentityLink> identityLinks = new ArrayList<IdentityLink>();
        identityLinks.addAll(links);
        
        List<NodeRef> pooledActorRefs = propertyConverter.getPooledActorsReference(identityLinks);
        
        // Save references as a variable
        List<String> nodeIds = new ArrayList<String>();
        for (NodeRef ref : pooledActorRefs)
        {
            nodeIds.add(ref.toString());
        }
        variables.put(ActivitiConstants.PROP_POOLED_ACTORS_HISTORY, nodeIds);
    }
}
 
Example #20
Source File: TaskDelagationAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void overwriteAssignee(TaskEntity task)
{
	String assignee = task.getAssignee();

	//受理人是否被代理
	if (assignee != null)
	{
		String[] delegates = _delegationManager.getDelegates(assignee);
		if (delegates != null && delegates.length > 0)
		{
			task.setAssignee(delegates[0]);
		}
	}
}
 
Example #21
Source File: RollbackCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 找到目的地activityId.
 */
public String findTargetActivityId() {
    if (ACTIVITY_PREVIOUS.equals(this.activityId)) {
        String taskId = this.findNearestUserTask();
        TaskEntity taskEntity = Context.getCommandContext()
                .getTaskEntityManager().findTaskById(taskId);

        return taskEntity.getTaskDefinitionKey();
    } else {
        return this.activityId;
    }
}
 
Example #22
Source File: RollbackCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public String findNearestUserTask() {
    TaskEntity taskEntity = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(taskId);

    if (taskEntity == null) {
        logger.debug("cannot find task : {}", taskId);

        return null;
    }

    Graph graph = new ActivitiHistoryGraphBuilder(
            taskEntity.getProcessInstanceId()).build();
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "select id_ from ACT_HI_ACTINST where task_id_=?",
            String.class, taskId);
    Node node = graph.findById(historicActivityInstanceId);

    String previousHistoricActivityInstanceId = this.findIncomingNode(
            graph, node);

    if (previousHistoricActivityInstanceId == null) {
        logger.debug(
                "cannot find previous historic activity instance : {}",
                taskEntity);

        return null;
    }

    return jdbcTemplate.queryForObject(
            "select task_id_ from ACT_HI_ACTINST where id_=?",
            String.class, previousHistoricActivityInstanceId);
}
 
Example #23
Source File: SkipEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void doSkip(DelegateTask delegateTask) {
    delegateTask.getExecution().setVariableLocal(
            "_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);

    TaskDefinition taskDefinition = ((TaskEntity) delegateTask)
            .getTaskDefinition();
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();
    Expression expression = expressionManager
            .createExpression("${_ACTIVITI_SKIP_EXPRESSION_ENABLED}");
    taskDefinition.setSkipExpression(expression);
}
 
Example #24
Source File: ResolveTaskCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected Void execute(CommandContext commandContext, TaskEntity task) {
  if (variables != null) {
    task.setVariables(variables);
  }
  if (transientVariables != null) {
    task.setTransientVariables(transientVariables);
  }
  
  task.setDelegationState(DelegationState.RESOLVED);
  commandContext.getTaskEntityManager().changeTaskAssignee(task, task.getOwner());
  
  return null;
}
 
Example #25
Source File: GetTaskVariableInstancesCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Map<String, VariableInstance> execute(CommandContext commandContext) {
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("taskId is null");
  }

  TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);

  if (task == null) {
    throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
  }

  Map<String, VariableInstance> variables = null;
  if (variableNames == null) {

    if (isLocal) {
      variables = task.getVariableInstancesLocal();
    } else {
      variables = task.getVariableInstances();
    }

  } else {
    if (isLocal) {
      variables = task.getVariableInstancesLocal(variableNames, false);
    } else {
      variables = task.getVariableInstances(variableNames, false);
    }

  }

  return variables;
}
 
Example #26
Source File: GetTaskFormCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public TaskFormData execute(CommandContext commandContext) {
  TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);
  if (task == null) {
    throw new ActivitiObjectNotFoundException("No task found for taskId '" + taskId + "'", Task.class);
  }
  
  TaskFormHandler taskFormHandler = FormHandlerUtil.getTaskFormHandlder(task);
  if (taskFormHandler == null) {
    throw new ActivitiException("No taskFormHandler specified for task '" + taskId + "'");
  }

  return taskFormHandler.createTaskForm(task);
}
 
Example #27
Source File: TaskDelagationAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void removeCandidateUsers(TaskEntity task, Set<String> delegates)
{
	for (String delegate : delegates)
	{
		task.deleteCandidateUser(delegate);
	}
}
 
Example #28
Source File: ClaimTaskCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected Void execute(CommandContext commandContext, TaskEntity task) {
  if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {
    Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
    activiti5CompatibilityHandler.claimTask(taskId, userId);
    return null;
  }
  
  if (userId != null) {
    task.setClaimTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());

    if (task.getAssignee() != null) {
      if (!task.getAssignee().equals(userId)) {
        // When the task is already claimed by another user, throw
        // exception. Otherwise, ignore
        // this, post-conditions of method already met.
        throw new ActivitiTaskAlreadyClaimedException(task.getId(), task.getAssignee());
      }
    } else {
      commandContext.getTaskEntityManager().changeTaskAssignee(task, userId);
    }
  } else {
    // Task claim time should be null
    task.setClaimTime(null);

    // Task should be assigned to no one
    commandContext.getTaskEntityManager().changeTaskAssignee(task, null);
  }

  // Add claim time to historic task instance
  commandContext.getHistoryManager().recordTaskClaim(task);

  return null;
}
 
Example #29
Source File: MyUserTaskActivityBehavior.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void handleAssignments(Expression assigneeExpression, Expression ownerExpression, Set<Expression> candidateUserExpressions,
	      Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
{
	createHandlerChain().resume(assigneeExpression, ownerExpression, candidateUserExpressions, 
	        candidateGroupExpressions, task, execution);
}
 
Example #30
Source File: ActivitiInternalProcessConnector.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 解析表达式.
 */
public Object executeExpression(String taskId, String expressionText) {
    TaskEntity taskEntity = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(taskId);
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();

    return expressionManager.createExpression(expressionText).getValue(
            taskEntity);
}