Search in sources :

Example 1 with ExpressionManager

use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.

the class AbstractActivityBpmnParseHandler method createMultiInstanceLoopCharacteristics.

protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {
    MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
    // Activity Behavior
    MultiInstanceActivityBehavior miActivityBehavior = null;
    ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
    if (activity == null) {
        throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
    }
    if (loopCharacteristics.isSequential()) {
        miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
    } else {
        miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
    }
    // ActivityImpl settings
    activity.setScope(true);
    activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
    activity.setActivityBehavior(miActivityBehavior);
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    // loopcardinality
    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());
    }
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) MultiInstanceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 2 with ExpressionManager

use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.

the class TimerEventDefinitionParseHandler method createTimer.

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;
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TimerDeclarationImpl(org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl) Expression(org.activiti.engine.delegate.Expression) TimerDeclarationType(org.activiti.engine.impl.jobexecutor.TimerDeclarationType)

Example 3 with ExpressionManager

use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.

the class ProcessParseHandler method transformProcess.

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());
    // Kept for backwards compatibility. See ACT-1020
    currentProcessDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, process.getDocumentation());
    currentProcessDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
    currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId());
    createExecutionListenersOnScope(bpmnParse, process.getExecutionListeners(), currentProcessDefinition);
    createEventListeners(bpmnParse, process.getEventListeners(), 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();
    if (process.getIoSpecification() != null) {
        IOSpecification ioSpecification = createIOSpecification(bpmnParse, process.getIoSpecification());
        currentProcessDefinition.setIoSpecification(ioSpecification);
    }
    return currentProcessDefinition;
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 4 with ExpressionManager

use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.

the class DefaultFormHandler method parseConfiguration.

public void parseConfiguration(List<org.activiti.bpmn.model.FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinitionEntity 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);
    }
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) Expression(org.activiti.engine.delegate.Expression) AbstractFormType(org.activiti.engine.form.AbstractFormType)

Example 5 with ExpressionManager

use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.

the class UserTaskActivityBehavior method getActiveValueSet.

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() == false || overrideValuesNode.size() == 0) {
                activeValues = null;
            } else {
                ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
                activeValues = new HashSet<Expression>();
                for (JsonNode valueNode : overrideValuesNode) {
                    activeValues.add(expressionManager.createExpression(valueNode.asText()));
                }
            }
        }
    }
    return activeValues;
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) Expression(org.activiti.engine.delegate.Expression) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)7 Expression (org.activiti.engine.delegate.Expression)5 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 TaskDefinition (org.activiti.engine.impl.task.TaskDefinition)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashSet (java.util.HashSet)1 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)1 ActivitiException (org.activiti.engine.ActivitiException)1 AbstractFormType (org.activiti.engine.form.AbstractFormType)1 Condition (org.activiti.engine.impl.Condition)1 AbstractBpmnActivityBehavior (org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior)1 MultiInstanceActivityBehavior (org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)1 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)1 UelExpressionCondition (org.activiti.engine.impl.el.UelExpressionCondition)1 DefaultTaskFormHandler (org.activiti.engine.impl.form.DefaultTaskFormHandler)1 TaskFormHandler (org.activiti.engine.impl.form.TaskFormHandler)1 TimerDeclarationImpl (org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl)1 TimerDeclarationType (org.activiti.engine.impl.jobexecutor.TimerDeclarationType)1