Search in sources :

Example 31 with Expression

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

the class TaskDecoratorTest method testDecorateCandidateGroups.

public void testDecorateCandidateGroups() {
    // given
    List<String> aCandidateGroupList = new ArrayList<String>();
    aCandidateGroupList.add("management");
    aCandidateGroupList.add("accounting");
    aCandidateGroupList.add("backoffice");
    for (String candidateGroup : aCandidateGroupList) {
        Expression candidateGroupExpression = expressionManager.createExpression(candidateGroup);
        taskDefinition.addCandidateGroupIdExpression(candidateGroupExpression);
    }
    // when
    decorate(task, taskDecorator);
    // then
    Set<IdentityLink> candidates = task.getCandidates();
    assertEquals(3, candidates.size());
    for (IdentityLink identityLink : candidates) {
        String taskId = identityLink.getTaskId();
        assertEquals(task.getId(), taskId);
        assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
        String groupId = identityLink.getGroupId();
        if ("management".equals(groupId)) {
            assertEquals("management", groupId);
        } else if ("accounting".equals(groupId)) {
            assertEquals("accounting", groupId);
        } else if ("backoffice".equals(groupId)) {
            assertEquals("backoffice", groupId);
        } else {
            fail("Unexpected group: " + groupId);
        }
    }
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression) ArrayList(java.util.ArrayList) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 32 with Expression

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

the class ProcessEngineTestRule 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 33 with Expression

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

the class SpinFunctionMapperTest method executeExpression.

@SuppressWarnings("unchecked")
protected <T> T executeExpression(String expression) {
    final TestVariableScope varScope = new TestVariableScope();
    final Expression compiledExpression = processEngineConfiguration.getExpressionManager().createExpression(expression);
    return (T) processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            return compiledExpression.getValue(varScope);
        }
    });
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Expression(org.camunda.bpm.engine.delegate.Expression) Command(org.camunda.bpm.engine.impl.interceptor.Command) TestVariableScope(org.camunda.spin.plugin.script.TestVariableScope)

Example 34 with Expression

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

the class BpmnDeployer method addAuthorizationsFromIterator.

protected void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
    if (exprSet != null) {
        for (Expression expr : exprSet) {
            IdentityLinkEntity identityLink = new IdentityLinkEntity();
            identityLink.setProcessDef(processDefinition);
            if (exprType.equals(ExprType.USER)) {
                identityLink.setUserId(expr.toString());
            } else if (exprType.equals(ExprType.GROUP)) {
                identityLink.setGroupId(expr.toString());
            }
            identityLink.setType(IdentityLinkType.CANDIDATE);
            identityLink.setTenantId(processDefinition.getTenantId());
            identityLink.insert();
        }
    }
}
Also used : IdentityLinkEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity) Expression(org.camunda.bpm.engine.delegate.Expression)

Example 35 with Expression

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

the class DefaultTaskFormHandler method createTaskForm.

public TaskFormData createTaskForm(TaskEntity task) {
    TaskFormDataImpl taskFormData = new TaskFormDataImpl();
    Expression formKey = task.getTaskDefinition().getFormKey();
    if (formKey != null) {
        Object formValue = formKey.getValue(task);
        if (formValue != null) {
            taskFormData.setFormKey(formValue.toString());
        }
    }
    taskFormData.setDeploymentId(deploymentId);
    taskFormData.setTask(task);
    initializeFormProperties(taskFormData, task.getExecution());
    initializeFormFields(taskFormData, task.getExecution());
    return taskFormData;
}
Also used : TaskFormDataImpl(org.camunda.bpm.engine.impl.form.TaskFormDataImpl) Expression(org.camunda.bpm.engine.delegate.Expression)

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