Search in sources :

Example 11 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method submitFormVariables.

public void submitFormVariables(VariableMap properties, VariableScope variableScope) {
    boolean userOperationLogEnabled = Context.getCommandContext().isUserOperationLogEnabled();
    Context.getCommandContext().enableUserOperationLog();
    VariableMap propertiesCopy = new VariableMapImpl(properties);
    // support legacy form properties
    for (FormPropertyHandler formPropertyHandler : formPropertyHandlers) {
        // submitFormProperty will remove all the keys which it takes care of
        formPropertyHandler.submitFormProperty(variableScope, propertiesCopy);
    }
    // support form data:
    for (FormFieldHandler formFieldHandler : formFieldHandlers) {
        if (!formFieldHandler.isBusinessKey()) {
            formFieldHandler.handleSubmit(variableScope, propertiesCopy, properties);
        }
    }
    // properties are added to the process as variables
    for (String propertyId : propertiesCopy.keySet()) {
        variableScope.setVariable(propertyId, propertiesCopy.getValueTyped(propertyId));
    }
    fireFormPropertyHistoryEvents(properties, variableScope);
    Context.getCommandContext().setLogUserOperationEnabled(userOperationLogEnabled);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 12 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class CaseTaskTest method testInputSourceExpression.

/**
 * Default manual activation changed - add variables to case instantiation, remove manual activation
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputSourceExpression.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceExpression() {
    // given
    VariableMap vars = new VariableMapImpl();
    vars.putValue("aVariable", "abc");
    vars.putValue("anotherVariable", 999);
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
    assertFalse(variables.isEmpty());
    assertEquals(2, variables.size());
    for (VariableInstance variable : variables) {
        String name = variable.getName();
        if ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
            assertEquals("abc", variable.getValue());
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
            assertEquals((long) 1000, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    terminate(subCaseInstance.getId());
    close(subCaseInstance.getId());
    assertCaseEnded(subCaseInstance.getId());
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class CaseTaskTest method testCallCaseByVersionAsExpressionStartsWithDollar.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseByVersionAsExpressionStartsWithDollar.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseByVersionAsExpressionStartsWithDollar() {
    // given
    String bpmnResourceName = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn";
    String secondDeploymentId = repositoryService.createDeployment().addClasspathResource(bpmnResourceName).deploy().getId();
    String thirdDeploymentId = repositoryService.createDeployment().addClasspathResource(bpmnResourceName).deploy().getId();
    assertEquals(4, repositoryService.createCaseDefinitionQuery().count());
    VariableMap vars = new VariableMapImpl();
    vars.putValue("myVersion", 2);
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    String caseDefinitionIdInSecondDeployment = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).deploymentId(secondDeploymentId).singleResult().getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
    CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
    assertEquals(caseTaskId, superCaseExecutionId);
    assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
    assertEquals(caseDefinitionIdInSecondDeployment, subCaseInstance.getCaseDefinitionId());
    // complete ////////////////////////////////////////////////////////
    terminate(subCaseInstance.getId());
    close(subCaseInstance.getId());
    assertCaseEnded(subCaseInstance.getId());
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
    repositoryService.deleteDeployment(secondDeploymentId, true);
    repositoryService.deleteDeployment(thirdDeploymentId, true);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableMap(org.camunda.bpm.engine.variable.VariableMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class CaseTaskTest method testCallCaseAsExpressionStartsWithHash.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseAsExpressionStartsWithHash.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseAsExpressionStartsWithHash() {
    // given
    // a deployed case definition
    VariableMap vars = new VariableMapImpl();
    vars.putValue("oneTaskCase", ONE_TASK_CASE);
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
    CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
    assertEquals(caseTaskId, superCaseExecutionId);
    assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
    // complete ////////////////////////////////////////////////////////
    terminate(subCaseInstance.getId());
    close(subCaseInstance.getId());
    assertCaseEnded(subCaseInstance.getId());
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableMap(org.camunda.bpm.engine.variable.VariableMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class CaseTaskTest method testCallCaseAsExpressionStartsWithDollar.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseAsExpressionStartsWithDollar.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseAsExpressionStartsWithDollar() {
    // given
    // a deployed case definition
    VariableMap vars = new VariableMapImpl();
    vars.putValue("oneTaskCase", ONE_TASK_CASE);
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    // then
    CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
    CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
    assertEquals(caseTaskId, superCaseExecutionId);
    assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
    // complete ////////////////////////////////////////////////////////
    terminate(subCaseInstance.getId());
    close(subCaseInstance.getId());
    assertCaseEnded(subCaseInstance.getId());
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableMap(org.camunda.bpm.engine.variable.VariableMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)22 VariableMap (org.camunda.bpm.engine.variable.VariableMap)15 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)7 Deployment (org.camunda.bpm.engine.test.Deployment)7 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)4 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)3 HistoryService (org.camunda.bpm.engine.HistoryService)2 FormField (org.camunda.bpm.engine.form.FormField)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)2 Field (java.lang.reflect.Field)1 ProcessVariable (org.camunda.bpm.engine.cdi.annotation.ProcessVariable)1 ProcessVariableTyped (org.camunda.bpm.engine.cdi.annotation.ProcessVariableTyped)1 StartFormData (org.camunda.bpm.engine.form.StartFormData)1 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)1 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)1 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)1 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)1 HistoricDetailQueryImpl (org.camunda.bpm.engine.impl.HistoricDetailQueryImpl)1