org.activiti.engine.impl.el.ExpressionManager Java Examples

The following examples show how to use org.activiti.engine.impl.el.ExpressionManager. 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: WebServiceActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected AbstractDataAssociation createDataInputAssociation(DataAssociation dataAssociationElement) {
  if (dataAssociationElement.getAssignments().isEmpty()) {
    return new MessageImplicitDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
  } else {
    SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
    ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
    
    for (org.activiti.bpmn.model.Assignment assignmentElement : dataAssociationElement.getAssignments()) {
      if (StringUtils.isNotEmpty(assignmentElement.getFrom()) && StringUtils.isNotEmpty(assignmentElement.getTo())) {
        Expression from = expressionManager.createExpression(assignmentElement.getFrom());
        Expression to = expressionManager.createExpression(assignmentElement.getTo());
        Assignment assignment = new Assignment(from, to);
        dataAssociation.addAssignment(assignment);
      }
    }
    return dataAssociation;
  }
}
 
Example #2
Source File: UserTaskActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected Set<Expression> getActiveValueSet(Set<Expression> originalValues, String propertyName, ObjectNode taskElementProperties) {
    Set<Expression> activeValues = originalValues;
    if (taskElementProperties != null) {
        JsonNode overrideValuesNode = taskElementProperties.get(propertyName);
        if (overrideValuesNode != null) {
            if (overrideValuesNode.isNull() || !overrideValuesNode.isArray() || overrideValuesNode.size() == 0) {
                activeValues = null;
            } else {
                ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
                activeValues = new HashSet<>();
                for (JsonNode valueNode : overrideValuesNode) {
                    activeValues.add(expressionManager.createExpression(valueNode.asText()));
                }
            }
        }
    }
    return activeValues;
}
 
Example #3
Source File: CallActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void completing(DelegateExecution execution, DelegateExecution subProcessInstance) throws Exception {
  // only data. no control flow available on this execution.

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

  // copy process variables
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  CallActivity callActivity = (CallActivity) executionEntity.getCurrentFlowElement();
  for (IOParameter ioParameter : callActivity.getOutParameters()) {
    Object value = null;
    if (StringUtils.isNotEmpty(ioParameter.getSourceExpression())) {
      Expression expression = expressionManager.createExpression(ioParameter.getSourceExpression().trim());
      value = expression.getValue(subProcessInstance);

    } else {
      value = subProcessInstance.getVariable(ioParameter.getSource());
    }
    execution.setVariable(ioParameter.getTarget(), value);
  }
}
 
Example #4
Source File: ExecuteExpressionCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Void execute(CommandContext commandContext) {
    try {
        ExpressionManager expressionManager = Context
                .getProcessEngineConfiguration().getExpressionManager();
        MockVariableScope mockVariableScope = new MockVariableScope(
                eventCode, eventName, modelInfo, userId, activityId,
                activityName);
        Object result = expressionManager.createExpression(expressionText)
                .getValue(mockVariableScope);
        logger.info("result : {}", result);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }

    return null;
}
 
Example #5
Source File: DefaultFormHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void parseConfiguration(List<org.activiti.bpmn.model.FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinition processDefinition) {
  this.deploymentId = deployment.getId();

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

  if (StringUtils.isNotEmpty(formKey)) {
    this.formKey = expressionManager.createExpression(formKey);
  }

  FormTypes formTypes = Context.getProcessEngineConfiguration().getFormTypes();

  for (org.activiti.bpmn.model.FormProperty formProperty : formProperties) {
    FormPropertyHandler formPropertyHandler = new FormPropertyHandler();
    formPropertyHandler.setId(formProperty.getId());
    formPropertyHandler.setName(formProperty.getName());

    AbstractFormType type = formTypes.parseFormPropertyType(formProperty);
    formPropertyHandler.setType(type);
    formPropertyHandler.setRequired(formProperty.isRequired());
    formPropertyHandler.setReadable(formProperty.isReadable());
    formPropertyHandler.setWritable(formProperty.isWriteable());
    formPropertyHandler.setVariableName(formProperty.getVariable());

    if (StringUtils.isNotEmpty(formProperty.getExpression())) {
      Expression expression = expressionManager.createExpression(formProperty.getExpression());
      formPropertyHandler.setVariableExpression(expression);
    }

    if (StringUtils.isNotEmpty(formProperty.getDefaultExpression())) {
      Expression defaultExpression = expressionManager.createExpression(formProperty.getDefaultExpression());
      formPropertyHandler.setDefaultExpression(defaultExpression);
    }

    formPropertyHandlers.add(formPropertyHandler);
  }
}
 
Example #6
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 #7
Source File: SkipEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void processExpression(DelegateTask delegateTask, String value) {
    UserConnector userConnector = ApplicationContextHelper
            .getBean(UserConnector.class);
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();
    String processInstanceId = delegateTask.getProcessInstanceId();
    HistoricProcessInstanceEntity historicProcessInstanceEntity = Context
            .getCommandContext().getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    String initiator = historicProcessInstanceEntity.getStartUserId();
    MapVariableScope mapVariableScope = new MapVariableScope();
    mapVariableScope.setVariable("initiator",
            userConnector.findById(initiator));

    Object objectResult = expressionManager.createExpression(value)
            .getValue(mapVariableScope);

    if ((objectResult == null) || (!(objectResult instanceof Boolean))) {
        logger.error("{} is not Boolean, just return", objectResult);

        return;
    }

    Boolean result = (Boolean) objectResult;

    logger.info("value : {}, result : {}", value, result);

    if (result) {
        logger.info("skip task : {}", delegateTask.getId());
        // new CompleteTaskWithCommentCmd(delegateTask.getId(),
        // Collections.<String, Object> emptyMap(), "跳过")
        // .execute(Context.getCommandContext());
        this.doSkip(delegateTask);
    }
}
 
Example #8
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);
}
 
Example #9
Source File: WebServiceActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected AbstractDataAssociation createDataOutputAssociation(DataAssociation dataAssociationElement) {
  if (StringUtils.isNotEmpty(dataAssociationElement.getSourceRef())) {
    return new MessageImplicitDataOutputAssociation(dataAssociationElement.getTargetRef(), dataAssociationElement.getSourceRef());
  } else {
    ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
    Expression transformation = expressionManager.createExpression(dataAssociationElement.getTransformation());
    AbstractDataAssociation dataOutputAssociation = new TransformationDataOutputAssociation(null, dataAssociationElement.getTargetRef(), transformation);
    return dataOutputAssociation;
  }
}
 
Example #10
Source File: HumanTaskTaskListener.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 #11
Source File: SequenceFlowParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) {

    ScopeImpl scope = bpmnParse.getCurrentScope();

    ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef());
    ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef());

    Expression skipExpression;
    if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) {
        ExpressionManager expressionManager = bpmnParse.getExpressionManager();
        skipExpression = expressionManager.createExpression(sequenceFlow.getSkipExpression());
    } else {
        skipExpression = null;
    }

    TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId(), skipExpression);
    bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition);
    transition.setProperty("name", sequenceFlow.getName());
    transition.setProperty("documentation", sequenceFlow.getDocumentation());
    transition.setDestination(destinationActivity);

    if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
        Condition expressionCondition = new UelExpressionCondition(sequenceFlow.getConditionExpression());
        transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression());
        transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition);
    }

    createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition);

}
 
Example #12
Source File: TaskConfTaskListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(DelegateTask delegateTask) throws Exception {
    String businessKey = delegateTask.getExecution()
            .getProcessBusinessKey();
    String taskDefinitionKey = delegateTask.getTaskDefinitionKey();

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

    try {
        String sql = "select ASSIGNEE from BPM_TASK_CONF where BUSINESS_KEY=? and TASK_DEFINITION_KEY=?";
        String assignee = jdbcTemplate.queryForObject(sql, String.class,
                businessKey, taskDefinitionKey);

        if ((assignee == null) || "".equals(assignee)) {
            return;
        }

        if ((assignee.indexOf("&&") != -1)
                || (assignee.indexOf("||") != -1)) {
            logger.info("assignee : {}", assignee);

            List<String> candidateUsers = new Expr().evaluate(assignee,
                    this);
            logger.info("candidateUsers : {}", candidateUsers);
            delegateTask.addCandidateUsers(candidateUsers);
        } else {
            String value = expressionManager.createExpression(assignee)
                    .getValue(delegateTask).toString();
            delegateTask.setAssignee(value);
        }
    } catch (Exception ex) {
        logger.debug(ex.getMessage(), ex);
    }
}
 
Example #13
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 #14
Source File: SkipTaskListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void processExpression(DelegateTask delegateTask, String value) {
    UserConnector userConnector = ApplicationContextHelper
            .getBean(UserConnector.class);
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();
    String processInstanceId = delegateTask.getProcessInstanceId();
    HistoricProcessInstanceEntity historicProcessInstanceEntity = Context
            .getCommandContext().getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    String initiator = historicProcessInstanceEntity.getStartUserId();
    MapVariableScope mapVariableScope = new MapVariableScope();
    mapVariableScope.setVariable("initiator",
            userConnector.findById(initiator));

    Object objectResult = expressionManager.createExpression(value)
            .getValue(mapVariableScope);

    if ((objectResult == null) || (!(objectResult instanceof Boolean))) {
        logger.error("{} is not Boolean, just return", objectResult);

        return;
    }

    Boolean result = (Boolean) objectResult;

    logger.info("value : {}, result : {}", value, result);

    if (result) {
        logger.info("skip task : {}", delegateTask.getId());
        new CompleteTaskWithCommentCmd(delegateTask.getId(),
                Collections.<String, Object> emptyMap(), "跳过")
                .execute(Context.getCommandContext());
    }
}
 
Example #15
Source File: DelegateHelper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an {@link Expression} for the {@link FieldExtension}.
 */
public static Expression createExpressionForField(FieldExtension fieldExtension) {
  if (StringUtils.isNotEmpty(fieldExtension.getExpression())) {
    ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
    return expressionManager.createExpression(fieldExtension.getExpression());
  } else {
    return new FixedValue(fieldExtension.getStringValue());
  }
}
 
Example #16
Source File: ProcessParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) {
    ProcessDefinitionEntity currentProcessDefinition = new ProcessDefinitionEntity();
    bpmnParse.setCurrentProcessDefinition(currentProcessDefinition);

    /*
     * Mapping object model - bpmn xml: processDefinition.id -> generated by activiti engine processDefinition.key -> bpmn id (required) processDefinition.name -> bpmn name (optional)
     */
    currentProcessDefinition.setKey(process.getId());
    currentProcessDefinition.setName(process.getName());
    currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace());
    currentProcessDefinition.setDescription(process.getDocumentation());
    currentProcessDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, process.getDocumentation()); // Kept for backwards compatibility. See ACT-1020
    currentProcessDefinition.setTaskDefinitions(new HashMap<>());
    currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId());
    createEventListeners(bpmnParse, process.getEventListeners());
    createExecutionListenersOnScope(bpmnParse, process.getExecutionListeners(), currentProcessDefinition);

    ExpressionManager expressionManager = bpmnParse.getExpressionManager();

    for (String candidateUser : process.getCandidateStarterUsers()) {
        currentProcessDefinition.addCandidateStarterUserIdExpression(expressionManager.createExpression(candidateUser));
    }

    for (String candidateGroup : process.getCandidateStarterGroups()) {
        currentProcessDefinition.addCandidateStarterGroupIdExpression(expressionManager.createExpression(candidateGroup));
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey());
    }

    bpmnParse.setCurrentScope(currentProcessDefinition);

    bpmnParse.processFlowElements(process.getFlowElements());
    processArtifacts(bpmnParse, process.getArtifacts(), currentProcessDefinition);

    // parse out any data objects from the template in order to set up the necessary process variables
    Map<String, Object> variables = processDataObjects(bpmnParse, process.getDataObjects(), currentProcessDefinition);
    if (null != currentProcessDefinition.getVariables()) {
        currentProcessDefinition.getVariables().putAll(variables);
    } else {
        currentProcessDefinition.setVariables(variables);
    }

    bpmnParse.removeCurrentScope();

    return currentProcessDefinition;
}
 
Example #17
Source File: BpmnParse.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ExpressionManager getExpressionManager() {
    return expressionManager;
}
 
Example #18
Source File: TimerEventDefinitionParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected TimerDeclarationImpl createTimer(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) {
    TimerDeclarationType type = null;
    Expression expression = null;
    Expression endDate = null;
    Expression calendarName = null;
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDate())) {
        // TimeDate
        type = TimerDeclarationType.DATE;
        expression = expressionManager.createExpression(timerEventDefinition.getTimeDate());
    } else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeCycle())) {
        // TimeCycle
        type = TimerDeclarationType.CYCLE;
        expression = expressionManager.createExpression(timerEventDefinition.getTimeCycle());
        // support for endDate
        if (StringUtils.isNotEmpty(timerEventDefinition.getEndDate())) {
            endDate = expressionManager.createExpression(timerEventDefinition.getEndDate());
        }
    } else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDuration())) {
        // TimeDuration
        type = TimerDeclarationType.DURATION;
        expression = expressionManager.createExpression(timerEventDefinition.getTimeDuration());
    }

    if (StringUtils.isNotEmpty(timerEventDefinition.getCalendarName())) {
        calendarName = expressionManager.createExpression(timerEventDefinition.getCalendarName());
    }

    // neither date, cycle or duration configured!
    if (expression == null) {
        LOGGER.warn("Timer needs configuration (either timeDate, timeCycle or timeDuration is needed) ({})", timerActivity.getId());
    }

    String jobHandlerConfiguration = timerActivity.getId();

    if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) ||
            jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) ||
            jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) {
        jobHandlerConfiguration = TimerStartEventJobHandler.createConfiguration(timerActivity.getId(), endDate, calendarName);
    }

    // Parse the timer declaration
    // TODO move the timer declaration into the bpmn activity or next to the
    // TimerSession
    TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType, endDate, calendarName);
    timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration);

    timerDeclaration.setExclusive(true);
    return timerDeclaration;
}
 
Example #19
Source File: BpmnParse.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setExpressionManager(ExpressionManager expressionManager) {
    this.expressionManager = expressionManager;
}
 
Example #20
Source File: BpmnDeployer.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ExpressionManager getExpressionManager() {
    return expressionManager;
}
 
Example #21
Source File: BpmnDeployer.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setExpressionManager(ExpressionManager expressionManager) {
    this.expressionManager = expressionManager;
}
 
Example #22
Source File: ConfUserTaskListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(DelegateTask delegateTask) 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() == 0) {
                    delegateTask.setAssignee(value);
                } else if (bpmConfUser.getType() == 1) {
                    delegateTask.addCandidateUser(value);
                } else if (bpmConfUser.getType() == 2) {
                    delegateTask.addCandidateGroup(value);
                }
            } else if (bpmConfUser.getStatus() == 2) {
                if (bpmConfUser.getType() == 0) {
                    if (delegateTask.getAssignee().equals(value)) {
                        delegateTask.setAssignee(null);
                    }
                } else if (bpmConfUser.getType() == 1) {
                    delegateTask.deleteCandidateUser(value);
                } else if (bpmConfUser.getType() == 2) {
                    delegateTask.deleteCandidateGroup(value);
                }
            }
        }
    } catch (Exception ex) {
        logger.debug(ex.getMessage(), ex);
    }
}
 
Example #23
Source File: HumanTaskUserTaskListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(DelegateTask delegateTask) throws Exception {
    String processDefinitionId = delegateTask.getProcessDefinitionId();
    String businessKey = delegateTask.getExecution()
            .getProcessBusinessKey();
    String taskDefinitionKey = delegateTask.getExecution()
            .getCurrentActivityId();
    ProcessTaskDefinition processTaskDefinition = internalProcessConnector
            .findTaskDefinition(processDefinitionId, businessKey,
                    taskDefinitionKey);
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();

    for (ParticipantDefinition participantDefinition : processTaskDefinition
            .getParticipantDefinitions()) {
        if ("user".equals(participantDefinition.getType())) {
            if ("add".equals(participantDefinition.getStatus())) {
                delegateTask.addCandidateUser(participantDefinition
                        .getValue());
            } else {
                delegateTask.deleteCandidateUser(participantDefinition
                        .getValue());
            }
        } else {
            if ("add".equals(participantDefinition.getStatus())) {
                delegateTask.addCandidateGroup(participantDefinition
                        .getValue());
            } else {
                delegateTask.deleteCandidateGroup(participantDefinition
                        .getValue());
            }
        }
    }

    String assignee = null;

    if (processTaskDefinition.getAssignee() != null) {
        assignee = expressionManager
                .createExpression(processTaskDefinition.getAssignee())
                .getValue(delegateTask).toString();
    }

    if (assignee == null) {
        delegateTask.setAssignee(null);
    } else if ((assignee.indexOf("&&") != -1)
            || (assignee.indexOf("||") != -1)) {
        logger.debug("assignee : {}", assignee);

        List<String> candidateUsers = new Expr().evaluate(assignee, this);
        logger.debug("candidateUsers : {}", candidateUsers);
        delegateTask.addCandidateUsers(candidateUsers);
    } else {
        delegateTask.setAssignee(assignee);
    }
}
 
Example #24
Source File: AutoCompleteFirstTaskEventListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
public void onCreate(DelegateTask delegateTask) throws Exception {
    String initiatorId = Authentication.getAuthenticatedUserId();

    if (initiatorId == null) {
        return;
    }

    String assignee = delegateTask.getAssignee();

    if (assignee == null) {
        return;
    }

    if (!initiatorId.equals(assignee)) {
        return;
    }

    PvmActivity targetActivity = this.findFirstActivity(delegateTask
            .getProcessDefinitionId());
    logger.debug("targetActivity : {}", targetActivity);

    if (!targetActivity.getId().equals(
            delegateTask.getExecution().getCurrentActivityId())) {
        return;
    }

    logger.debug("auto complete first task : {}", delegateTask);

    for (IdentityLink identityLink : delegateTask.getCandidates()) {
        String userId = identityLink.getUserId();
        String groupId = identityLink.getGroupId();

        if (userId != null) {
            delegateTask.deleteCandidateUser(userId);
        }

        if (groupId != null) {
            delegateTask.deleteCandidateGroup(groupId);
        }
    }

    // 对提交流程的任务进行特殊处理
    HumanTaskDTO humanTaskDto = humanTaskConnector
            .findHumanTaskByTaskId(delegateTask.getId());
    humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    humanTaskConnector.saveHumanTask(humanTaskDto);

    // ((TaskEntity) delegateTask).complete();
    // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask);
    // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask);
    // new CompleteTaskWithCommentCmd(delegateTask.getId(), null, "发起流程")
    // .execute(Context.getCommandContext());

    // 因为recordTaskId()会判断endTime,而complete以后会导致endTime!=null,
    // 所以才会出现record()放在complete后面导致taskId没记录到historyActivity里的情况
    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 #25
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ExpressionManager getExpressionManager() {
    return expressionManager;
}
 
Example #26
Source File: ProcessEngineConfigurationImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ExpressionManager getExpressionManager() {
  return expressionManager;
}
 
Example #27
Source File: ProcessEngineConfigurationImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ProcessEngineConfigurationImpl setExpressionManager(ExpressionManager expressionManager) {
  this.expressionManager = expressionManager;
  return this;
}
 
Example #28
Source File: AbstractBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ExpressionManager getExpressionManager() {
  return expressionManager;
}
 
Example #29
Source File: AbstractBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void setExpressionManager(ExpressionManager expressionManager) {
  this.expressionManager = expressionManager;
}
 
Example #30
Source File: AbstractActivityBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {

    MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();

    // Activity Behavior
    MultiInstanceActivityBehavior miActivityBehavior = null;

    if (loopCharacteristics.isSequential()) {
      miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(modelActivity, (AbstractBpmnActivityBehavior) modelActivity.getBehavior());
    } else {
      miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(modelActivity, (AbstractBpmnActivityBehavior) modelActivity.getBehavior());
    }

    modelActivity.setBehavior(miActivityBehavior);

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

    // loop cardinality
    if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
      miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
    }

    // completion condition
    if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
      miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
    }

    // activiti:collection
    if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
      if (loopCharacteristics.getInputDataItem().contains("{")) {
        miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
      } else {
        miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
      }
    }

    // activiti:elementVariable
    if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
      miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
    }

    // activiti:elementIndexVariable
    if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) {
      miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable());
    }

  }