Search in sources :

Example 21 with VariableMap

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

the class AbstractVariablesResource method getVariables.

@Override
public Map<String, VariableValueDto> getVariables(boolean deserializeValues) {
    VariableMap variables = getVariableEntities(deserializeValues);
    Map<String, VariableValueDto> values = new HashMap<String, VariableValueDto>();
    for (String variableName : variables.keySet()) {
        VariableValueDto valueDto = VariableValueDto.fromTypedValue(variables.getValueTyped(variableName));
        values.put(variableName, valueDto);
    }
    return values;
}
Also used : VariableValueDto(org.camunda.bpm.engine.rest.dto.VariableValueDto) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap)

Example 22 with VariableMap

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

the class ProcessDefinitionResourceImpl method getFormVariables.

public Map<String, VariableValueDto> getFormVariables(String variableNames, boolean deserializeValues) {
    final FormService formService = engine.getFormService();
    List<String> formVariables = null;
    if (variableNames != null) {
        StringListConverter stringListConverter = new StringListConverter();
        formVariables = stringListConverter.convertQueryParameterToType(variableNames);
    }
    VariableMap startFormVariables = formService.getStartFormVariables(processDefinitionId, formVariables, deserializeValues);
    return VariableValueDto.fromVariableMap(startFormVariables);
}
Also used : StringListConverter(org.camunda.bpm.engine.rest.dto.converter.StringListConverter) VariableMap(org.camunda.bpm.engine.variable.VariableMap) FormService(org.camunda.bpm.engine.FormService)

Example 23 with VariableMap

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

the class TaskResourceImpl method resolve.

@Override
public void resolve(CompleteTaskDto dto) {
    TaskService taskService = engine.getTaskService();
    try {
        VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper);
        taskService.resolveTask(taskId, variables);
    } catch (RestException e) {
        String errorMessage = String.format("Cannot resolve task %s: %s", taskId, e.getMessage());
        throw new InvalidRequestException(e.getStatus(), e, errorMessage);
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) TaskService(org.camunda.bpm.engine.TaskService) RestException(org.camunda.bpm.engine.rest.exception.RestException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 24 with VariableMap

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

the class CallableElementActivityBehavior method passOutputVariables.

@Override
public void passOutputVariables(final ActivityExecution execution, final VariableScope subInstance) {
    // only data. no control flow available on this execution.
    VariableMap variables = filterVariables(getOutputVariables(subInstance));
    VariableMap localVariables = getOutputVariablesLocal(subInstance);
    execution.setVariables(variables);
    execution.setVariablesLocal(localVariables);
    final DelegateVariableMapping varMapping = resolveDelegation(execution);
    if (varMapping != null) {
        invokeVarMappingDelegation(new DelegateInvocation(execution, null) {

            @Override
            protected void invoke() throws Exception {
                varMapping.mapOutputVariables(execution, subInstance);
            }
        });
    }
}
Also used : DelegateVariableMapping(org.camunda.bpm.engine.delegate.DelegateVariableMapping) VariableMap(org.camunda.bpm.engine.variable.VariableMap) DelegateInvocation(org.camunda.bpm.engine.impl.delegate.DelegateInvocation) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 25 with VariableMap

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

the class RestartProcessInstancesCmd method collectLastVariables.

protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) {
    HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService();
    List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance.getId()).list();
    VariableMap variables = new VariableMapImpl();
    for (HistoricVariableInstance variable : historicVariables) {
        variables.putValueTyped(variable.getName(), variable.getTypedValue());
    }
    return variables;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance)

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