use of org.activiti.engine.runtime.DataObject in project Activiti by Activiti.
the class GetDataObjectCmd method execute.
public DataObject execute(CommandContext commandContext) {
if (executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
if (dataObjectName == null) {
throw new ActivitiIllegalArgumentException("dataObjectName is null");
}
ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
DataObject dataObject = null;
VariableInstance variableEntity = null;
if (isLocal) {
variableEntity = execution.getVariableInstanceLocal(dataObjectName, false);
} else {
variableEntity = execution.getVariableInstance(dataObjectName, false);
}
String localizedName = null;
String localizedDescription = null;
if (variableEntity != null) {
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(variableEntity.getExecutionId());
while (!executionEntity.isScope()) {
executionEntity = executionEntity.getParent();
}
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(executionEntity.getProcessDefinitionId());
ValuedDataObject foundDataObject = null;
if (executionEntity.getParentId() == null) {
for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) {
if (dataObjectDefinition.getName().equals(variableEntity.getName())) {
foundDataObject = dataObjectDefinition;
break;
}
}
} else {
SubProcess subProcess = (SubProcess) bpmnModel.getFlowElement(execution.getActivityId());
for (ValuedDataObject dataObjectDefinition : subProcess.getDataObjects()) {
if (dataObjectDefinition.getName().equals(variableEntity.getName())) {
foundDataObject = dataObjectDefinition;
break;
}
}
}
if (locale != null && foundDataObject != null) {
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, foundDataObject.getId(), execution.getProcessDefinitionId(), withLocalizationFallback);
if (variableEntity != null && 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 (foundDataObject != null) {
dataObject = new DataObjectImpl(variableEntity.getName(), variableEntity.getValue(), foundDataObject.getDocumentation(), foundDataObject.getType(), localizedName, localizedDescription, foundDataObject.getId());
}
}
return dataObject;
}
use of org.activiti.engine.runtime.DataObject in project Activiti by Activiti.
the class GetTaskDataObjectsCmd method execute.
public Map<String, DataObject> execute(CommandContext commandContext) {
if (taskId == null) {
throw new ActivitiIllegalArgumentException("taskId is null");
}
TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);
if (task == null) {
throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
}
Map<String, DataObject> dataObjects = null;
Map<String, VariableInstance> variables = null;
if (variableNames == null) {
variables = task.getVariableInstances();
} else {
variables = task.getVariableInstances(variableNames, false);
}
if (variables != null) {
dataObjects = new HashMap<>(variables.size());
for (Entry<String, VariableInstance> entry : variables.entrySet()) {
VariableInstance variableEntity = entry.getValue();
String localizedName = null;
String localizedDescription = null;
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(variableEntity.getExecutionId());
while (!executionEntity.isScope()) {
executionEntity = executionEntity.getParent();
}
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(executionEntity.getProcessDefinitionId());
ValuedDataObject foundDataObject = null;
if (executionEntity.getParentId() == null) {
for (ValuedDataObject dataObject : bpmnModel.getMainProcess().getDataObjects()) {
if (dataObject.getName().equals(variableEntity.getName())) {
foundDataObject = dataObject;
break;
}
}
} else {
SubProcess subProcess = (SubProcess) bpmnModel.getFlowElement(executionEntity.getActivityId());
for (ValuedDataObject dataObject : subProcess.getDataObjects()) {
if (dataObject.getName().equals(variableEntity.getName())) {
foundDataObject = dataObject;
break;
}
}
}
if (locale != null && foundDataObject != null) {
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, foundDataObject.getId(), task.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 (foundDataObject != null) {
dataObjects.put(variableEntity.getName(), new DataObjectImpl(variableEntity.getName(), variableEntity.getValue(), foundDataObject.getDocumentation(), foundDataObject.getType(), localizedName, localizedDescription, foundDataObject.getId()));
}
}
}
return dataObjects;
}
use of org.activiti.engine.runtime.DataObject in project Activiti by Activiti.
the class CustomVariableType method testLocalizeDataObjects.
@Deployment
public void testLocalizeDataObjects() {
// Start process instance with different types of variables
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("stringVar", "coca-cola");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("localizeVariables", variables);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processInstance.getProcessDefinitionId());
dynamicBpmnService.changeLocalizationName("en-US", "stringVarId", "stringVar 'en-US' Name", infoNode);
dynamicBpmnService.changeLocalizationDescription("en-US", "stringVarId", "stringVar 'en-US' Description", infoNode);
dynamicBpmnService.changeLocalizationName("en-AU", "stringVarId", "stringVar 'en-AU' Name", infoNode);
dynamicBpmnService.changeLocalizationDescription("en-AU", "stringVarId", "stringVar 'en-AU' Description", infoNode);
dynamicBpmnService.changeLocalizationName("en", "stringVarId", "stringVar 'en' Name", infoNode);
dynamicBpmnService.changeLocalizationDescription("en", "stringVarId", "stringVar 'en' Description", infoNode);
dynamicBpmnService.changeLocalizationName("en-US", "intVarId", "intVar 'en-US' Name", infoNode);
dynamicBpmnService.changeLocalizationDescription("en-US", "intVarId", "intVar 'en-US' Description", infoNode);
dynamicBpmnService.changeLocalizationName("en-AU", "intVarId", "intVar 'en-AU' Name", infoNode);
dynamicBpmnService.changeLocalizationDescription("en-AU", "intVarId", "intVar 'en-AU' Description", infoNode);
dynamicBpmnService.changeLocalizationName("en", "intVarId", "intVar 'en' Name", infoNode);
dynamicBpmnService.changeLocalizationDescription("en", "intVarId", "intVar 'en' Description", infoNode);
dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
Map<String, DataObject> dataObjects = runtimeService.getDataObjects(processInstance.getId(), "es", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'es' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'es' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObjects
dataObjects = runtimeService.getDataObjects(processInstance.getId(), "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjects(processInstance.getId(), "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjects(processInstance.getId(), "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjects(processInstance.getId(), "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
List<String> variableNames = new ArrayList<String>();
variableNames.add("stringVar");
// getDataObjects via names
dataObjects = runtimeService.getDataObjects(processInstance.getId(), variableNames, "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjects(processInstance.getId(), variableNames, "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjects(processInstance.getId(), variableNames, "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjects(processInstance.getId(), variableNames, "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObjectsLocal
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), "ja-JA", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObjectsLocal via names
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), variableNames, "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), variableNames, "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), variableNames, "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = runtimeService.getDataObjectsLocal(processInstance.getId(), variableNames, "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObject
DataObject dataObject = runtimeService.getDataObject(processInstance.getId(), "stringVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObject = runtimeService.getDataObject(processInstance.getId(), "stringVar", "en-US", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObject = runtimeService.getDataObject(processInstance.getId(), "stringVar", "en-AU", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObject = runtimeService.getDataObject(processInstance.getId(), "stringVar", "en-GB", true);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObject = runtimeService.getDataObject(processInstance.getId(), "stringVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObjectLocal
dataObject = runtimeService.getDataObjectLocal(processInstance.getId(), "stringVar", "en-US", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObject = runtimeService.getDataObjectLocal(processInstance.getId(), "stringVar", "en-AU", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObject = runtimeService.getDataObjectLocal(processInstance.getId(), "stringVar", "en-GB", true);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
dataObject = runtimeService.getDataObjectLocal(processInstance.getId(), "stringVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
Execution subprocess = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("subprocess1").singleResult();
dataObjects = runtimeService.getDataObjects(subprocess.getId(), "es", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'es' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'es' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObjects
dataObjects = runtimeService.getDataObjects(subprocess.getId(), "en-US", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-US' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), "en-AU", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-AU' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), "en-GB", true);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), "en-GB", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
// getDataObjects via names (from subprocess)
variableNames.add("intVar");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), variableNames, "en-US", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-US' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), variableNames, "en-AU", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-AU' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), variableNames, "en-GB", true);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjects(subprocess.getId(), variableNames, "en-GB", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
// getDataObjectsLocal
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-US' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-US' Description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-AU' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-AU' Description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en' Description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), "ja-JA", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
// getDataObjectsLocal via names
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), variableNames, "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-US' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-US' Description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), variableNames, "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en-AU' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en-AU' Description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), variableNames, "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar 'en' Name");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'en' Description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = runtimeService.getDataObjectsLocal(subprocess.getId(), variableNames, "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("intVar").getName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getValue()).isEqualTo(null);
assertThat(dataObjects.get("intVar").getLocalizedName()).isEqualTo("intVar");
assertThat(dataObjects.get("intVar").getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
// getDataObject (in subprocess)
dataObject = runtimeService.getDataObject(subprocess.getId(), "intVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObject(subprocess.getId(), "intVar", "en-US", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar 'en-US' Name");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'en-US' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObject(subprocess.getId(), "intVar", "en-AU", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar 'en-AU' Name");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'en-AU' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObject(subprocess.getId(), "intVar", "en-GB", true);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar 'en' Name");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'en' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObject(subprocess.getId(), "intVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
// getDataObjectLocal (in subprocess)
dataObject = runtimeService.getDataObjectLocal(subprocess.getId(), "intVar", "en-US", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar 'en-US' Name");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'en-US' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObjectLocal(subprocess.getId(), "intVar", "en-AU", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar 'en-AU' Name");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'en-AU' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObjectLocal(subprocess.getId(), "intVar", "en-GB", true);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar 'en' Name");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'en' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
dataObject = runtimeService.getDataObjectLocal(subprocess.getId(), "intVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObject.getType()).isEqualTo("int");
// Verify TaskService behavior
dataObjects = taskService.getDataObjects(task.getId());
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
// getDataObjects
dataObjects = taskService.getDataObjects(task.getId());
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = taskService.getDataObjects(task.getId(), "en-US", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = taskService.getDataObjects(task.getId(), "en-AU", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = taskService.getDataObjects(task.getId(), "en-GB", true);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
dataObjects = taskService.getDataObjects(task.getId(), "en-GB", false);
assertThat(dataObjects).hasSize(2);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
assertThat(dataObject.getName()).isEqualTo("intVar");
assertThat(dataObject.getValue()).isEqualTo(null);
assertThat(dataObject.getLocalizedName()).isEqualTo("intVar");
assertThat(dataObject.getDescription()).isEqualTo("intVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("intVar").getDataObjectDefinitionKey()).isEqualTo("intVarId");
assertThat(dataObjects.get("intVar").getType()).isEqualTo("int");
variableNames = new ArrayList<String>();
variableNames.add("stringVar");
// getDataObjects via names
dataObjects = taskService.getDataObjects(task.getId(), variableNames, "en-US", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = taskService.getDataObjects(task.getId(), variableNames, "en-AU", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = taskService.getDataObjects(task.getId(), variableNames, "en-GB", true);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
dataObjects = taskService.getDataObjects(task.getId(), variableNames, "en-GB", false);
assertThat(dataObjects).hasSize(1);
assertThat(dataObjects.get("stringVar").getName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getValue()).isEqualTo("coca-cola");
assertThat(dataObjects.get("stringVar").getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObjects.get("stringVar").getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObjects.get("stringVar").getType()).isEqualTo("string");
// getDataObject
dataObject = taskService.getDataObject(task.getId(), "stringVar");
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObject.getType()).isEqualTo("string");
dataObject = taskService.getDataObject(task.getId(), "stringVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObject.getType()).isEqualTo("string");
dataObject = taskService.getDataObject(task.getId(), "stringVar", "en-US", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en-US' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en-US' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObject.getType()).isEqualTo("string");
dataObject = taskService.getDataObject(task.getId(), "stringVar", "en-AU", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en-AU' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en-AU' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObject.getType()).isEqualTo("string");
dataObject = taskService.getDataObject(task.getId(), "stringVar", "en-GB", true);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar 'en' Name");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'en' Description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObject.getType()).isEqualTo("string");
dataObject = taskService.getDataObject(task.getId(), "stringVar", "en-GB", false);
assertThat(dataObject).isNotNull();
assertThat(dataObject.getName()).isEqualTo("stringVar");
assertThat(dataObject.getValue()).isEqualTo("coca-cola");
assertThat(dataObject.getLocalizedName()).isEqualTo("stringVar");
assertThat(dataObject.getDescription()).isEqualTo("stringVar 'default' description");
assertThat(dataObject.getDataObjectDefinitionKey()).isEqualTo("stringVarId");
assertThat(dataObject.getType()).isEqualTo("string");
}
use of org.activiti.engine.runtime.DataObject in project Activiti by Activiti.
the class GetDataObjectsCmd method execute.
public Map<String, DataObject> execute(CommandContext commandContext) {
// Verify existance of execution
if (executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
Map<String, VariableInstance> variables = null;
if (dataObjectNames == null || dataObjectNames.isEmpty()) {
// Fetch all
if (isLocal) {
variables = execution.getVariableInstancesLocal();
} else {
variables = execution.getVariableInstances();
}
} else {
// Fetch specific collection of variables
if (isLocal) {
variables = execution.getVariableInstancesLocal(dataObjectNames, false);
} else {
variables = execution.getVariableInstances(dataObjectNames, false);
}
}
Map<String, DataObject> dataObjects = null;
if (variables != null) {
dataObjects = new HashMap<>(variables.size());
for (Entry<String, VariableInstance> entry : variables.entrySet()) {
String name = entry.getKey();
VariableInstance variableEntity = (VariableInstance) entry.getValue();
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(variableEntity.getExecutionId());
while (!executionEntity.isScope()) {
executionEntity = executionEntity.getParent();
}
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());
ValuedDataObject foundDataObject = null;
if (executionEntity.getParentId() == null) {
for (ValuedDataObject dataObject : bpmnModel.getMainProcess().getDataObjects()) {
if (dataObject.getName().equals(variableEntity.getName())) {
foundDataObject = dataObject;
break;
}
}
} else {
SubProcess subProcess = (SubProcess) bpmnModel.getFlowElement(execution.getActivityId());
for (ValuedDataObject dataObject : subProcess.getDataObjects()) {
if (dataObject.getName().equals(variableEntity.getName())) {
foundDataObject = dataObject;
break;
}
}
}
String localizedName = null;
String localizedDescription = null;
if (locale != null && foundDataObject != null) {
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, foundDataObject.getId(), 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 (foundDataObject != null) {
dataObjects.put(name, new DataObjectImpl(variableEntity.getName(), variableEntity.getValue(), foundDataObject.getDocumentation(), foundDataObject.getType(), localizedName, localizedDescription, foundDataObject.getId()));
}
}
}
return dataObjects;
}
use of org.activiti.engine.runtime.DataObject in project Activiti by Activiti.
the class GetTaskDataObjectCmd method execute.
public DataObject execute(CommandContext commandContext) {
if (taskId == null) {
throw new ActivitiIllegalArgumentException("taskId is null");
}
if (variableName == null) {
throw new ActivitiIllegalArgumentException("variableName is null");
}
TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);
if (task == null) {
throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
}
DataObject dataObject = null;
VariableInstance variableEntity = task.getVariableInstance(variableName, false);
String localizedName = null;
String localizedDescription = null;
if (variableEntity != null) {
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(variableEntity.getExecutionId());
while (!executionEntity.isScope()) {
executionEntity = executionEntity.getParent();
}
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(executionEntity.getProcessDefinitionId());
ValuedDataObject foundDataObject = null;
if (executionEntity.getParentId() == null) {
for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) {
if (dataObjectDefinition.getName().equals(variableEntity.getName())) {
foundDataObject = dataObjectDefinition;
break;
}
}
} else {
SubProcess subProcess = (SubProcess) bpmnModel.getFlowElement(executionEntity.getActivityId());
for (ValuedDataObject dataObjectDefinition : subProcess.getDataObjects()) {
if (dataObjectDefinition.getName().equals(variableEntity.getName())) {
foundDataObject = dataObjectDefinition;
break;
}
}
}
if (locale != null && foundDataObject != null) {
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, foundDataObject.getId(), task.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 (foundDataObject != null) {
dataObject = new DataObjectImpl(variableEntity.getName(), variableEntity.getValue(), foundDataObject.getDocumentation(), foundDataObject.getType(), localizedName, localizedDescription, foundDataObject.getId());
}
}
return dataObject;
}
Aggregations