Search in sources :

Example 1 with Expression

use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.

the class TimerEntity method restoreExtraData.

protected void restoreExtraData(CommandContext commandContext, String jobHandlerConfiguration) {
    String embededActivityId = jobHandlerConfiguration;
    if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) {
        embededActivityId = TimerEventHandler.getActivityIdFromConfiguration(jobHandlerConfiguration);
        String endDateExpressionString = TimerEventHandler.getEndDateFromConfiguration(jobHandlerConfiguration);
        if (endDateExpressionString != null) {
            Expression endDateExpression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(endDateExpressionString);
            String endDateString = null;
            BusinessCalendar businessCalendar = Context.getProcessEngineConfiguration().getBusinessCalendarManager().getBusinessCalendar(getBusinessCalendarName(TimerEventHandler.geCalendarNameFromConfiguration(jobHandlerConfiguration)));
            VariableScope executionEntity = null;
            if (executionId != null) {
                executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
            }
            if (executionEntity == null) {
                executionEntity = NoExecutionVariableScope.getSharedInstance();
            }
            if (endDateExpression != null) {
                Object endDateValue = endDateExpression.getValue(executionEntity);
                if (endDateValue instanceof String) {
                    endDateString = (String) endDateValue;
                } else if (endDateValue instanceof Date) {
                    endDate = (Date) endDateValue;
                } else {
                    throw new ActivitiException("Timer '" + ((ExecutionEntity) executionEntity).getActivityId() + "' was not configured with a valid duration/time, either hand in a java.util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'");
                }
                if (endDate == null) {
                    endDate = businessCalendar.resolveEndDate(endDateString);
                }
            }
        }
    }
    if (processDefinitionId != null) {
        ProcessDefinition definition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
        maxIterations = checkStartEventDefinitions(definition, embededActivityId);
        if (maxIterations <= 1) {
            maxIterations = checkBoundaryEventsDefinitions(definition, embededActivityId);
        }
    } else {
        maxIterations = 1;
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Expression(org.activiti.engine.delegate.Expression) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar) BusinessCalendar(org.activiti.engine.impl.calendar.BusinessCalendar) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) VariableScope(org.activiti.engine.delegate.VariableScope) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) Date(java.util.Date)

Example 2 with Expression

use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.

the class DefaultActivityBehaviorFactory method createServiceTaskExpressionActivityBehavior.

public ServiceTaskExpressionActivityBehavior createServiceTaskExpressionActivityBehavior(ServiceTask serviceTask) {
    Expression expression = expressionManager.createExpression(serviceTask.getImplementation());
    Expression skipExpression;
    if (StringUtils.isNotEmpty(serviceTask.getSkipExpression())) {
        skipExpression = expressionManager.createExpression(serviceTask.getSkipExpression());
    } else {
        skipExpression = null;
    }
    return new ServiceTaskExpressionActivityBehavior(serviceTask.getId(), expression, skipExpression, serviceTask.getResultVariableName());
}
Also used : Expression(org.activiti.engine.delegate.Expression) ServiceTaskExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior)

Example 3 with Expression

use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.

the class DefaultActivityBehaviorFactory method createServiceTaskDelegateExpressionActivityBehavior.

public ServiceTaskDelegateExpressionActivityBehavior createServiceTaskDelegateExpressionActivityBehavior(ServiceTask serviceTask) {
    Expression delegateExpression = expressionManager.createExpression(serviceTask.getImplementation());
    Expression skipExpression;
    if (StringUtils.isNotEmpty(serviceTask.getSkipExpression())) {
        skipExpression = expressionManager.createExpression(serviceTask.getSkipExpression());
    } else {
        skipExpression = null;
    }
    return new ServiceTaskDelegateExpressionActivityBehavior(serviceTask.getId(), delegateExpression, skipExpression, createFieldDeclarations(serviceTask.getFieldExtensions()));
}
Also used : ServiceTaskDelegateExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior) Expression(org.activiti.engine.delegate.Expression)

Example 4 with Expression

use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.

the class AbstractExternalInvocationBpmnParseHandler method createDataOutputAssociation.

public AbstractDataAssociation createDataOutputAssociation(BpmnParse bpmnParse, DataAssociation dataAssociationElement) {
    if (StringUtils.isNotEmpty(dataAssociationElement.getSourceRef())) {
        return new MessageImplicitDataOutputAssociation(dataAssociationElement.getTargetRef(), dataAssociationElement.getSourceRef());
    } else {
        Expression transformation = bpmnParse.getExpressionManager().createExpression(dataAssociationElement.getTransformation());
        AbstractDataAssociation dataOutputAssociation = new TransformationDataOutputAssociation(null, dataAssociationElement.getTargetRef(), transformation);
        return dataOutputAssociation;
    }
}
Also used : MessageImplicitDataOutputAssociation(org.activiti.engine.impl.bpmn.webservice.MessageImplicitDataOutputAssociation) TransformationDataOutputAssociation(org.activiti.engine.impl.bpmn.data.TransformationDataOutputAssociation) AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) Expression(org.activiti.engine.delegate.Expression)

Example 5 with Expression

use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.

the class AbstractExternalInvocationBpmnParseHandler method createDataInputAssociation.

public AbstractDataAssociation createDataInputAssociation(BpmnParse bpmnParse, DataAssociation dataAssociationElement) {
    if (dataAssociationElement.getAssignments().isEmpty()) {
        return new MessageImplicitDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
    } else {
        SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
        for (org.activiti.bpmn.model.Assignment assigmentElement : dataAssociationElement.getAssignments()) {
            if (StringUtils.isNotEmpty(assigmentElement.getFrom()) && StringUtils.isNotEmpty(assigmentElement.getTo())) {
                Expression from = bpmnParse.getExpressionManager().createExpression(assigmentElement.getFrom());
                Expression to = bpmnParse.getExpressionManager().createExpression(assigmentElement.getTo());
                Assignment assignment = new Assignment(from, to);
                dataAssociation.addAssignment(assignment);
            }
        }
        return dataAssociation;
    }
}
Also used : Assignment(org.activiti.engine.impl.bpmn.data.Assignment) Expression(org.activiti.engine.delegate.Expression) SimpleDataInputAssociation(org.activiti.engine.impl.bpmn.data.SimpleDataInputAssociation) MessageImplicitDataInputAssociation(org.activiti.engine.impl.bpmn.webservice.MessageImplicitDataInputAssociation)

Aggregations

Expression (org.activiti.engine.delegate.Expression)61 ActivitiException (org.activiti.engine.ActivitiException)17 DelegateExecution (org.activiti.engine.delegate.DelegateExecution)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)12 Test (org.junit.Test)12 Test (org.junit.jupiter.api.Test)12 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)11 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)8 Condition (org.activiti.engine.impl.Condition)6 Date (java.util.Date)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)5 BusinessCalendar (org.activiti.engine.impl.calendar.BusinessCalendar)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)4 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayList (java.util.ArrayList)3 VariableScope (org.activiti.engine.delegate.VariableScope)3 CycleBusinessCalendar (org.activiti.engine.impl.calendar.CycleBusinessCalendar)3 DueDateBusinessCalendar (org.activiti.engine.impl.calendar.DueDateBusinessCalendar)3