org.activiti.engine.delegate.DelegateTask Java Examples

The following examples show how to use org.activiti.engine.delegate.DelegateTask. 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: TaskEntity.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void fireEvent(String taskEventName) {
  TaskDefinition taskDefinition = getTaskDefinition();
  if (taskDefinition != null) {
    List<TaskListener> taskEventListeners = getTaskDefinition().getTaskListener(taskEventName);
    if (taskEventListeners != null) {
      for (TaskListener taskListener : taskEventListeners) {
        ExecutionEntity execution = getExecution();
        if (execution != null) {
          setEventName(taskEventName);
        }
        try {
          Context.getProcessEngineConfiguration()
            .getDelegateInterceptor()
            .handleInvocation(new TaskListenerInvocation(taskListener, (DelegateTask)this));
        }catch (Exception e) {
          throw new ActivitiException("Exception while invoking TaskListener: "+e.getMessage(), e);
        }
      }
    }
  }
}
 
Example #2
Source File: HumanTaskTaskListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
@Override
public void onDelete(DelegateTask delegateTask) throws Exception {
    HumanTaskDTO humanTaskDto = humanTaskConnector
            .findHumanTaskByTaskId(delegateTask.getId());

    if (humanTaskDto == null) {
        return;
    }

    if (!"complete".equals(humanTaskDto.getStatus())) {
        humanTaskDto.setStatus("delete");
        humanTaskDto.setCompleteTime(new Date());
        humanTaskDto.setAction("人工终止");
        humanTaskDto.setOwner(humanTaskDto.getAssignee());
        humanTaskDto.setAssignee(Authentication.getAuthenticatedUserId());
        humanTaskConnector.saveHumanTask(humanTaskDto, false);
    }
}
 
Example #3
Source File: TaskCompleteListener.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void notify(DelegateTask task)
{
    // Check all mandatory properties are set. This is checked here instead of in
    // the completeTask() to allow taskListeners to set variable values before checking
    propertyConverter.checkMandatoryProperties(task);

    // Set properties for ended task
    Map<String, Object> endTaskVariables = new HashMap<String, Object>();

    // Set task status to completed
    String statusKey = qNameConverter.mapQNameToName(WorkflowModel.PROP_STATUS);
    endTaskVariables.put(statusKey, "Completed");
    
    // Add pooled actors to task-variables to be preserved in history (if any)
    addPooledActorsAsVariable(task, endTaskVariables);
    
    // Set variables locally on the task
    task.setVariablesLocal(endTaskVariables);
}
 
Example #4
Source File: SkipTaskListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void processPosition(DelegateTask delegateTask, String value) {
    String processInstanceId = delegateTask.getProcessInstanceId();
    HistoricProcessInstanceEntity historicProcessInstanceEntity = Context
            .getCommandContext().getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    String initiator = historicProcessInstanceEntity.getStartUserId();
    OrgConnector orgConnector = (OrgConnector) ApplicationContextHelper
            .getBean(OrgConnector.class);

    // 获得发起人的职位
    int initiatorLevel = orgConnector.getJobLevelByUserId(initiator);

    // 获得审批人的职位
    int assigneeLevel = orgConnector.getJobLevelByUserId(delegateTask
            .getAssignee());

    // 比较
    if (initiatorLevel >= assigneeLevel) {
        logger.info("skip task : {}", delegateTask.getId());
        logger.info("initiatorLevel : {}, assigneeLevel : {}",
                initiatorLevel, assigneeLevel);
        new CompleteTaskWithCommentCmd(delegateTask.getId(),
                Collections.<String, Object> emptyMap(), "高级职位自动跳过")
                .execute(Context.getCommandContext());
    }
}
 
Example #5
Source File: DelegateExpressionTaskListener.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  // Note: we can't cache the result of the expression, because the
  // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
  Object delegate = expression.getValue(delegateTask.getExecution());
  ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);
  
  if (delegate instanceof TaskListener) {
    try {
      Context.getProcessEngineConfiguration()
        .getDelegateInterceptor()
        .handleInvocation(new TaskListenerInvocation((TaskListener)delegate, delegateTask));
    }catch (Exception e) {
      throw new ActivitiException("Exception while invoking TaskListener: "+e.getMessage(), e);
    }
  } else {
    throw new ActivitiIllegalArgumentException("Delegate expression " + expression 
            + " did not resolve to an implementation of " + TaskListener.class );
  }
}
 
Example #6
Source File: TaskCreateListener.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void notify(DelegateTask task)
{
    // Set all default properties, based on the type-definition
    propertyConverter.setDefaultTaskProperties(task);

    String taskFormKey = getFormKey(task);
    
    // Fetch definition and extract name again. Possible that the default is used if the provided is missing
    TypeDefinition typeDefinition = propertyConverter.getWorkflowObjectFactory().getTaskTypeDefinition(taskFormKey, false);
    taskFormKey = typeDefinition.getName().toPrefixString();
    
    // The taskDefinition key is set as a variable in order to be available
    // in the history
    task.setVariableLocal(ActivitiConstants.PROP_TASK_FORM_KEY, taskFormKey);
    
    // Add process initiator as involved person
    ActivitiScriptNode initiatorNode = (ActivitiScriptNode) task.getExecution().getVariable(WorkflowConstants.PROP_INITIATOR);
    if(initiatorNode != null) {
        task.addUserIdentityLink((String) initiatorNode.getProperties().get(ContentModel.PROP_USERNAME.toPrefixString()), IdentityLinkType.STARTER);
    }
}
 
Example #7
Source File: ResourceEnterToFinanceListener.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {

    auditUserInnerServiceSMOImpl = ApplicationContextFactory.getBean("auditUserInnerServiceSMOImpl", IAuditUserInnerServiceSMO.class);
    AuditUserDto auditUserDto = new AuditUserDto();
    ResourceOrderDto resourceOrderDto = (ResourceOrderDto)delegateTask.getVariable("resourceOrderDto");
    auditUserDto.setStoreId(resourceOrderDto.getStoreId());
    auditUserDto.setObjCode("resourceEntry");
    auditUserDto.setAuditLink("809002");
    List<AuditUserDto> auditUserDtos = auditUserInnerServiceSMOImpl.queryAuditUsers(auditUserDto);

    for (AuditUserDto tmpAuditUser : auditUserDtos) {
        AuditUser auditUser = BeanConvertUtil.covertBean(tmpAuditUser, AuditUser.class);

        delegateTask.setVariable(auditUser.getUserId(), auditUser);

    }
}
 
Example #8
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 #9
Source File: LeaveCounterSignCompleteListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    String approved = (String) delegateTask.getVariable("approved");
    if (approved.equals("true")) {
        Long agreeCounter = (Long) delegateTask.getVariable("approvedCounter");
        delegateTask.setVariable("approvedCounter", agreeCounter + 1);
    }
}
 
Example #10
Source File: TaskCompletionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  Integer counter = (Integer) delegateTask.getVariable("taskListenerCounter");
  if (counter == null) {
    counter = 0;
  }
  delegateTask.setVariable("taskListenerCounter", ++counter);
}
 
Example #11
Source File: HumanTaskBuilder.java    From lemon with Apache License 2.0 5 votes vote down vote up
public HumanTaskBuilder setDelegateTask(DelegateTask delegateTask) {
    humanTaskDto.setBusinessKey(delegateTask.getExecution()
            .getProcessBusinessKey());
    humanTaskDto.setName(delegateTask.getName());
    humanTaskDto.setDescription(delegateTask.getDescription());

    humanTaskDto.setCode(delegateTask.getTaskDefinitionKey());
    humanTaskDto.setAssignee(delegateTask.getAssignee());
    humanTaskDto.setOwner(delegateTask.getOwner());
    humanTaskDto.setDelegateStatus("none");
    humanTaskDto.setPriority(delegateTask.getPriority());
    humanTaskDto.setCreateTime(new Date());
    humanTaskDto.setDuration(delegateTask.getDueDate() + "");
    humanTaskDto.setSuspendStatus("none");
    humanTaskDto.setCategory(delegateTask.getCategory());
    humanTaskDto.setForm(delegateTask.getFormKey());
    humanTaskDto.setTaskId(delegateTask.getId());
    humanTaskDto.setExecutionId(delegateTask.getExecutionId());
    humanTaskDto.setProcessInstanceId(delegateTask.getProcessInstanceId());
    humanTaskDto.setProcessDefinitionId(delegateTask
            .getProcessDefinitionId());
    humanTaskDto.setTenantId(delegateTask.getTenantId());
    humanTaskDto.setStatus("active");
    humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_NORMAL);

    ExecutionEntity executionEntity = (ExecutionEntity) delegateTask
            .getExecution();
    ExecutionEntity processInstance = executionEntity.getProcessInstance();
    humanTaskDto.setPresentationSubject(processInstance.getName());

    String userId = Authentication.getAuthenticatedUserId();
    humanTaskDto.setProcessStarter(userId);

    return this;
}
 
Example #12
Source File: CreateTaskListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    System.out.println(task.getValue(delegateTask));
    delegateTask.setVariable("setInTaskCreate", delegateTask.getEventName() + ", " + content.getValue(delegateTask));
    System.out.println(delegateTask.getEventName() + ",任务分配给:" + delegateTask.getAssignee());
    delegateTask.setAssignee("jenny");
}
 
Example #13
Source File: CreateTaskListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    System.out.println(task.getValue(delegateTask));
    delegateTask.setVariable("setInTaskCreate", delegateTask.getEventName() + ", " + content.getValue(delegateTask));
    System.out.println(delegateTask.getEventName() + ",任务分配给:" + delegateTask.getAssignee());
    delegateTask.setAssignee("jenny");
}
 
Example #14
Source File: ActivitiPropertyConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void checkMandatoryProperties(DelegateTask task)
{
     // Check all mandatory properties are set. This is checked here instead of in
     // the completeTask() to allow taskListeners to set variable values before checking
     List<QName> missingProps = getMissingMandatoryTaskProperties(task);
     if (missingProps != null && missingProps.size() > 0)
     {
         String missingPropString = StringUtils.join(missingProps.iterator(), ", ");
         throw new WorkflowException(messageService.getMessage(ERR_MANDATORY_TASK_PROPERTIES_MISSING, missingPropString));
     }
}
 
Example #15
Source File: AssigneeOverwriteFromVariable.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void notify(DelegateTask delegateTask) {
  // get mapping table from variable
  DelegateExecution execution = delegateTask.getExecution();
  Map<String, String> assigneeMappingTable = (Map<String, String>) execution.getVariable("assigneeMappingTable");

  // get assignee from process
  String assigneeFromProcessDefinition = delegateTask.getAssignee();

  // overwrite assignee if there is an entry in the mapping table
  if (assigneeMappingTable.containsKey(assigneeFromProcessDefinition)) {
    String assigneeFromMappingTable = assigneeMappingTable.get(assigneeFromProcessDefinition);
    delegateTask.setAssignee(assigneeFromMappingTable);
  }
}
 
Example #16
Source File: HumanTaskEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void checkCopyHumanTask(DelegateTask delegateTask,
        HumanTaskDTO humanTaskDto) throws Exception {
    List<BpmConfUser> bpmConfUsers = bpmConfUserManager
            .find("from BpmConfUser where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                    delegateTask.getProcessDefinitionId(), delegateTask
                            .getExecution().getCurrentActivityId());
    logger.debug("{}", bpmConfUsers);

    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();

    try {
        for (BpmConfUser bpmConfUser : bpmConfUsers) {
            logger.debug("status : {}, type: {}", bpmConfUser.getStatus(),
                    bpmConfUser.getType());
            logger.debug("value : {}", bpmConfUser.getValue());

            String value = expressionManager
                    .createExpression(bpmConfUser.getValue())
                    .getValue(delegateTask).toString();

            if (bpmConfUser.getStatus() == 1) {
                if (bpmConfUser.getType() == TYPE_COPY) {
                    logger.info("copy humantask : {}, {}",
                            humanTaskDto.getId(), value);
                    this.copyHumanTask(humanTaskDto, value);
                }
            }
        }
    } catch (Exception ex) {
        logger.debug(ex.getMessage(), ex);
    }
}
 
Example #17
Source File: TimeoutNotice.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void process(DelegateTask delegateTask) {
    String taskDefinitionKey = delegateTask.getTaskDefinitionKey();
    String processDefinitionId = delegateTask.getProcessDefinitionId();

    List<BpmConfNotice> bpmConfNotices = ApplicationContextHelper
            .getBean(BpmConfNoticeManager.class)
            .find("from BpmConfNotice where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                    processDefinitionId, taskDefinitionKey);

    for (BpmConfNotice bpmConfNotice : bpmConfNotices) {
        if (TYPE_TIMEOUT == bpmConfNotice.getType()) {
            processTimeout(delegateTask, bpmConfNotice);
        }
    }
}
 
Example #18
Source File: CreateTaskListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    System.out.println(task.getValue(delegateTask));
    delegateTask.setVariable("setInTaskCreate", delegateTask.getEventName() + ", " + content.getValue(delegateTask));
    System.out.println(delegateTask.getEventName() + ",任务分配给:" + delegateTask.getAssignee());
    delegateTask.setAssignee("jenny");
}
 
Example #19
Source File: ResourceEnterToDepartmentListener.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
@Override
    public void notify(DelegateTask delegateTask) {
        logger.info("查询部门审核人员");

//        auditUserInnerServiceSMOImpl = ApplicationContextFactory.getBean("auditUserInnerServiceSMOImpl", IAuditUserInnerServiceSMO.class);
//        AuditUserDto auditUserDto = new AuditUserDto();
//        PurchaseApplyDto purchaseApplyDto = (PurchaseApplyDto)delegateTask.getVariable("purchaseApplyDto");
        String nextAuditStaffId = delegateTask.getVariable("nextAuditStaffId").toString();
        /*auditUserDto.setStoreId(purchaseApplyDto.getStoreId());
        auditUserDto.setObjCode("resourceEntry");
        auditUserDto.setAuditLink("809001");
        List<AuditUserDto> auditUserDtos = auditUserInnerServiceSMOImpl.queryAuditUsers(auditUserDto);


        for (AuditUserDto tmpAuditUser : auditUserDtos) {
            AuditUser auditUser = BeanConvertUtil.covertBean(tmpAuditUser, AuditUser.class);
            logger.info("查询到用户:"+tmpAuditUser.getUserName());

            delegateTask.setVariable(auditUser.getUserId(), auditUser);

        }

        logger.info("查询审核人员人数:"+auditUserDtos.size());

        if (auditUserDtos == null || auditUserDtos.size() < 1) {
            return;
        }*/

        delegateTask.setAssignee(nextAuditStaffId);
        logger.info("设置部门审核人员:"+nextAuditStaffId);
    }
 
Example #20
Source File: SetRandomVariablesTaskListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  String varName;
  for (int i = 0; i < 5; i++) {
    varName = "variable-" + new Random().nextInt(10);
    delegateTask.getExecution().setVariable(varName, getRandomValue());
  }

  for (int i = 0; i < 5; i++) {
    varName = "task-variable-" + new Random().nextInt(10);
    delegateTask.setVariableLocal(varName, getRandomValue());
  }
}
 
Example #21
Source File: HumanTaskSyncTaskListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(DelegateTask delegateTask) throws Exception {
    HumanTaskDTO humanTaskDto = humanTaskConnector
            .findHumanTaskByTaskId(delegateTask.getId());
    delegateTask.setOwner(humanTaskDto.getOwner());
    delegateTask.setAssignee(humanTaskDto.getAssignee());
}
 
Example #22
Source File: ReportBackEndProcessor.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
    Leave leave = leaveManager.get(new Long(delegateTask.getExecution().getProcessBusinessKey()));
    Object realityStartTime = delegateTask.getVariable("realityStartTime");
    leave.setRealityStartTime((Date) realityStartTime);
    Object realityEndTime = delegateTask.getVariable("realityEndTime");
    leave.setRealityEndTime((Date) realityEndTime);
    leaveManager.save(leave);
}
 
Example #23
Source File: AfterModifyApplyContentProcessor.java    From maven-framework-project with MIT License 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
	String processInstanceId = delegateTask.getProcessInstanceId();
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
	Leave leave = leaveService.findById(processInstance.getBusinessKey());
	leave.setLeaveType((String) delegateTask.getVariable("leaveType"));
	leave.setStartTime((Date) delegateTask.getVariable("startTime"));
	leave.setEndTime((Date) delegateTask.getVariable("endTime"));
	leave.setReason((String) delegateTask.getVariable("reason"));
	leaveService.save(leave);
}
 
Example #24
Source File: SkipEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void processPosition(DelegateTask delegateTask, String value) {
    String processInstanceId = delegateTask.getProcessInstanceId();
    HistoricProcessInstanceEntity historicProcessInstanceEntity = Context
            .getCommandContext().getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    String initiator = historicProcessInstanceEntity.getStartUserId();
    OrgConnector orgConnector = (OrgConnector) ApplicationContextHelper
            .getBean(OrgConnector.class);

    // 获得发起人的职位
    int initiatorLevel = orgConnector.getJobLevelByUserId(initiator);

    // 获得审批人的职位
    int assigneeLevel = orgConnector.getJobLevelByUserId(delegateTask
            .getAssignee());

    // 比较
    if (initiatorLevel >= assigneeLevel) {
        logger.info("skip task : {}", delegateTask.getId());
        logger.info("initiatorLevel : {}, assigneeLevel : {}",
                initiatorLevel, assigneeLevel);
        // new CompleteTaskWithCommentCmd(delegateTask.getId(),
        // Collections.<String, Object> emptyMap(), "高级职位自动跳过")
        // .execute(Context.getCommandContext());
        this.doSkip(delegateTask);
    }
}
 
Example #25
Source File: UserTaskExecutionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  SimulationEvent eventToSimulate = findUserTaskCompleteEvent(delegateTask);
  if (eventToSimulate != null) {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("taskId", delegateTask.getId());
    properties.put("variables", eventToSimulate.getProperty(UserTaskCompleteTransformer.TASK_VARIABLES));
    // we were able to resolve event to simulate automatically
    SimulationEvent e = new SimulationEvent.Builder(typeToCreate).properties(properties).build();
    SimulationRunContext.getEventCalendar().addEvent(e);
  }
}
 
Example #26
Source File: UserTaskExecutionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private SimulationEvent findUserTaskCompleteEvent(DelegateTask delegateTask) {
  if (delegateTask.hasVariable(StartReplayProcessEventHandler.PROCESS_INSTANCE_ID)) {
    String toSimulateProcessInstanceId = (String) delegateTask.getVariable(StartReplayProcessEventHandler.PROCESS_INSTANCE_ID);
    String toSimulateTaskDefinitionKey = delegateTask.getTaskDefinitionKey();
    for (SimulationEvent e : events) {
      if (typeToFind.equals(e.getType()) && toSimulateProcessInstanceId.equals(e.getProperty(UserTaskCompleteTransformer.PROCESS_INSTANCE_ID))
          && toSimulateTaskDefinitionKey.equals(e.getProperty(UserTaskCompleteTransformer.TASK_DEFINITION_KEY)))
        return e;
    }
  }
  return null;
}
 
Example #27
Source File: SecureJavascriptTaskListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
  validateParameters();
  if (SecureJavascriptTaskParseHandler.LANGUAGE_JAVASCRIPT.equalsIgnoreCase(language.getValue(delegateTask).toString())) {
    Object result = SecureJavascriptUtil.evaluateScript(delegateTask, script.getExpressionText());
    if (resultVariable != null) {
      delegateTask.setVariable(resultVariable.getExpressionText(), result);
    }
  } else {
    super.notify(delegateTask);
  }
}
 
Example #28
Source File: LeaveCounterSignCompleteListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    String approved = (String) delegateTask.getVariable("approved");
    if (approved.equals("true")) {
        Long agreeCounter = (Long) delegateTask.getVariable("approvedCounter");
        delegateTask.setVariable("approvedCounter", agreeCounter + 1);
    }
}
 
Example #29
Source File: ReportBackEndProcessor.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
    Leave leave = leaveManager.get(new Long(delegateTask.getExecution().getProcessBusinessKey()));
    Object realityStartTime = delegateTask.getVariable("realityStartTime");
    leave.setRealityStartTime((Date) realityStartTime);
    Object realityEndTime = delegateTask.getVariable("realityEndTime");
    leave.setRealityEndTime((Date) realityEndTime);
    leaveManager.save(leave);
}
 
Example #30
Source File: TaskAutoRedirectListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    String originAssginee = delegateTask.getAssignee();
    String newUser = userMap.get(originAssginee);
    if (StringUtils.isNotBlank(newUser)) {
        delegateTask.setAssignee(newUser);
        EngineServices engineServices = delegateTask.getExecution().getEngineServices();
        TaskService taskService = engineServices.getTaskService();
        String message = getClass().getName() + "-> 任务[" + delegateTask.getName() + "]的办理人[" + originAssginee + "]自动转办给了用户[" + newUser + "]";
        taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "delegate", message);
    } else {
        System.out.println("任务[" + delegateTask.getName() + "]没有预设的代办人");
    }
}