Search in sources :

Example 11 with VariableInstance

use of org.activiti.engine.impl.persistence.entity.VariableInstance in project Activiti by Activiti.

the class GetExecutionVariableInstanceCmd method execute.

public VariableInstance execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("executionId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(executionId);
    if (execution == null) {
        throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
    }
    VariableInstance variableEntity = null;
    if (isLocal) {
        variableEntity = execution.getVariableInstanceLocal(variableName, false);
    } else {
        variableEntity = execution.getVariableInstance(variableName, false);
    }
    if (locale != null) {
        String localizedName = null;
        String localizedDescription = null;
        ObjectNode languageNode = Context.getLocalizationElementProperties(locale, variableName, execution.getProcessDefinitionId(), withLocalizationFallback);
        if (languageNode != null) {
            JsonNode nameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
            if (nameNode != null) {
                localizedName = nameNode.asText();
            }
            JsonNode descriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
            if (descriptionNode != null) {
                localizedDescription = descriptionNode.asText();
            }
        }
        if (variableEntity != null) {
            variableEntity.setLocalizedName(localizedName);
            variableEntity.setLocalizedDescription(localizedDescription);
        }
    }
    return variableEntity;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) JsonNode(com.fasterxml.jackson.databind.JsonNode) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) VariableInstance(org.activiti.engine.impl.persistence.entity.VariableInstance)

Example 12 with VariableInstance

use of org.activiti.engine.impl.persistence.entity.VariableInstance in project Activiti by Activiti.

the class GetExecutionsVariablesCmd method execute.

@Override
public List<VariableInstance> execute(CommandContext commandContext) {
    // Verify existance of executions
    if (executionIds == null) {
        throw new ActivitiIllegalArgumentException("executionIds is null");
    }
    if (executionIds.isEmpty()) {
        throw new ActivitiIllegalArgumentException("Set of executionIds is empty");
    }
    List<VariableInstance> instances = new ArrayList<VariableInstance>();
    List<VariableInstanceEntity> entities = commandContext.getVariableInstanceEntityManager().findVariableInstancesByExecutionIds(executionIds);
    for (VariableInstanceEntity entity : entities) {
        entity.getValue();
        instances.add(entity);
    }
    return instances;
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ArrayList(java.util.ArrayList) VariableInstanceEntity(org.activiti.engine.impl.persistence.entity.VariableInstanceEntity) VariableInstance(org.activiti.engine.impl.persistence.entity.VariableInstance)

Aggregations

VariableInstance (org.activiti.engine.impl.persistence.entity.VariableInstance)12 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)6 Deployment (org.activiti.engine.test.Deployment)6 HashSet (java.util.HashSet)5 Task (org.activiti.engine.task.Task)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)2 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 VariableInstanceEntity (org.activiti.engine.impl.persistence.entity.VariableInstanceEntity)2 Execution (org.activiti.engine.runtime.Execution)2 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)1