Search in sources :

Example 36 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class PvmTestCase method defaultManualActivation.

public Object defaultManualActivation() {
    Expression expression = new FixedValue(true);
    CaseControlRuleImpl caseControlRule = new CaseControlRuleImpl(expression);
    return caseControlRule;
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression) CaseControlRuleImpl(org.camunda.bpm.engine.impl.cmmn.behavior.CaseControlRuleImpl) FixedValue(org.camunda.bpm.engine.impl.el.FixedValue)

Example 37 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class ScriptUtil method getScriptFromResource.

/**
 * Creates a new {@link ExecutableScript} from a resource. It excepts static and dynamic resources.
 * Dynamic means that the resource is an expression which will be evaluated during execution.
 *
 * @param language the language of the script
 * @param resource the resource path of the script code or an expression which evaluates to the resource path
 * @param expressionManager the expression manager to use to generate the expressions of dynamic scripts
 * @param scriptFactory the script factory used to create the script
 * @return the newly created script
 * @throws NotValidException if language or resource are null or empty
 */
public static ExecutableScript getScriptFromResource(String language, String resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) {
    ensureNotEmpty(NotValidException.class, "Script language", language);
    ensureNotEmpty(NotValidException.class, "Script resource", resource);
    if (isDynamicScriptExpression(language, resource)) {
        Expression resourceExpression = expressionManager.createExpression(resource);
        return getScriptFromResourceExpression(language, resourceExpression, scriptFactory);
    } else {
        return getScriptFromResource(language, resource, scriptFactory);
    }
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression)

Example 38 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method testSentryWithIfPartWithMultipleCondition.

@Test
public void testSentryWithIfPartWithMultipleCondition() {
    // given
    IfPart ifPart = createElement(sentry, "abc", IfPart.class);
    ConditionExpression firstConditionExpression = createElement(ifPart, "con_1", ConditionExpression.class);
    Body firstBody = createElement(firstConditionExpression, null, Body.class);
    String firstExpression = "${firstExpression}";
    firstBody.setTextContent(firstExpression);
    ConditionExpression secondConditionExpression = createElement(ifPart, "con_2", ConditionExpression.class);
    Body secondBody = createElement(secondConditionExpression, null, Body.class);
    String secondExpression = "${secondExpression}";
    secondBody.setTextContent(secondExpression);
    // when
    CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
    // then
    assertNotNull(sentryDeclaration);
    CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
    assertNotNull(ifPartDeclaration);
    Expression condition = ifPartDeclaration.getCondition();
    assertNotNull(condition);
    assertEquals(firstExpression, condition.getExpressionText());
    // the second condition will be ignored!
    assertTrue(sentryDeclaration.getOnParts().isEmpty());
}
Also used : CmmnIfPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration) CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) IfPart(org.camunda.bpm.model.cmmn.instance.IfPart) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) Body(org.camunda.bpm.model.cmmn.instance.Body) Test(org.junit.Test)

Example 39 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionPlanItemNameExpression.

@Test
public void testTaskDefinitionPlanItemNameExpression() {
    // given
    String name = "A HumanTask";
    humanTask.setName(name);
    String planItemName = "My LocalName";
    planItem.setName(planItemName);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Expression nameExpression = taskDefinition.getNameExpression();
    assertNotNull(nameExpression);
    assertEquals("My LocalName", nameExpression.getExpressionText());
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 40 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionDueDateExpression.

@Test
public void testTaskDefinitionDueDateExpression() {
    // given
    String aDueDate = "aDueDate";
    humanTask.setCamundaDueDate(aDueDate);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Expression dueDateExpression = taskDefinition.getDueDateExpression();
    assertNotNull(dueDateExpression);
    assertEquals(aDueDate, dueDateExpression.getExpressionText());
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Aggregations

Expression (org.camunda.bpm.engine.delegate.Expression)62 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)18 Test (org.junit.Test)15 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)14 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)14 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)12 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)12 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)8 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 CmmnIfPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration)4 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)4 CamundaField (org.camunda.bpm.model.cmmn.instance.camunda.CamundaField)4 FieldDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration)3 CaseControlRuleImpl (org.camunda.bpm.engine.impl.cmmn.behavior.CaseControlRuleImpl)3 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)3 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)3 CamundaExpression (org.camunda.bpm.model.cmmn.instance.camunda.CamundaExpression)3 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)3 Collection (java.util.Collection)2