Search in sources :

Example 11 with VariableMap

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

the class ProcessInstanceWithVariablesDto method fromProcessInstance.

public static ProcessInstanceDto fromProcessInstance(ProcessInstanceWithVariables instance) {
    ProcessInstanceWithVariablesDto result = new ProcessInstanceWithVariablesDto(instance);
    VariableMap variables = instance.getVariables();
    Map<String, VariableValueDto> values = new HashMap<String, VariableValueDto>();
    for (String variableName : variables.keySet()) {
        VariableValueDto valueDto = VariableValueDto.fromTypedValue(variables.getValueTyped(variableName), true);
        values.put(variableName, valueDto);
    }
    result.variables = values;
    return result;
}
Also used : VariableValueDto(org.camunda.bpm.engine.rest.dto.VariableValueDto) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap)

Example 12 with VariableMap

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

the class ExternalTaskResourceImpl method complete.

@Override
public void complete(CompleteExternalTaskDto dto) {
    ExternalTaskService externalTaskService = engine.getExternalTaskService();
    VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper);
    VariableMap localVariables = VariableValueDto.toMap(dto.getLocalVariables(), engine, objectMapper);
    try {
        externalTaskService.complete(externalTaskId, dto.getWorkerId(), variables, localVariables);
    } catch (NotFoundException e) {
        throw new RestException(Status.NOT_FOUND, e, "External task with id " + externalTaskId + " does not exist");
    } catch (BadUserRequestException e) {
        throw new RestException(Status.BAD_REQUEST, e, e.getMessage());
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 13 with VariableMap

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

the class MockProvider method createMockFormVariables.

public static VariableMap createMockFormVariables() {
    VariableMap mock = Variables.createVariables();
    mock.putValueTyped(EXAMPLE_VARIABLE_INSTANCE_NAME, EXAMPLE_PRIMITIVE_VARIABLE_VALUE);
    return mock;
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 14 with VariableMap

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

the class ThrowSignalEventActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    String businessKey = signalDefinition.getEventPayload().getBusinessKey(execution);
    VariableMap variableMap = signalDefinition.getEventPayload().getInputVariables(execution);
    String eventName = signalDefinition.resolveExpressionOfEventName(execution);
    // trigger all event subscriptions for the signal (start and intermediate)
    List<EventSubscriptionEntity> signalEventSubscriptions = findSignalEventSubscriptions(eventName, execution.getTenantId());
    for (EventSubscriptionEntity signalEventSubscription : signalEventSubscriptions) {
        if (isActiveEventSubscription(signalEventSubscription)) {
            signalEventSubscription.eventReceived(variableMap, businessKey, signalDefinition.isAsync());
        }
    }
    leave(execution);
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 15 with VariableMap

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

the class HistoricDecisionInstanceSerializationTest method testListJsonProperty.

@Deployment(resources = { "org/camunda/spin/plugin/DecisionSingleOutput.dmn11.xml" })
public void testListJsonProperty() {
    JsonListSerializable<String> list = new JsonListSerializable<String>();
    list.addElement("foo");
    ObjectValue objectValue = Variables.objectValue(list).serializationDataFormat(DataFormats.JSON_DATAFORMAT_NAME).create();
    VariableMap variables = Variables.createVariables().putValueTyped("input1", objectValue);
    decisionService.evaluateDecisionTableByKey("testDecision", variables);
    HistoricDecisionInstance testDecision = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey("testDecision").includeInputs().includeOutputs().singleResult();
    assertNotNull(testDecision);
    List<HistoricDecisionInputInstance> inputs = testDecision.getInputs();
    assertEquals(1, inputs.size());
    HistoricDecisionInputInstance inputInstance = inputs.get(0);
    assertEquals(list.getListProperty(), inputInstance.getValue());
    List<HistoricDecisionOutputInstance> outputs = testDecision.getOutputs();
    assertEquals(1, outputs.size());
    HistoricDecisionOutputInstance outputInstance = outputs.get(0);
    assertEquals(list.getListProperty(), outputInstance.getValue());
}
Also used : HistoricDecisionInputInstance(org.camunda.bpm.engine.history.HistoricDecisionInputInstance) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

VariableMap (org.camunda.bpm.engine.variable.VariableMap)230 Deployment (org.camunda.bpm.engine.test.Deployment)107 Test (org.junit.Test)59 Task (org.camunda.bpm.engine.task.Task)38 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)32 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)30 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)15 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)13 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 HashMap (java.util.HashMap)12 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 ProcessInstanceWithVariables (org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables)9 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)8 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)8 RestException (org.camunda.bpm.engine.rest.exception.RestException)8 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)8 Execution (org.camunda.bpm.engine.runtime.Execution)8 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)7 ThrowErrorDelegate (org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate)7