use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class DynamicServiceTaskTest method testChangeExpression.
@Deployment
public void testChangeExpression() {
// first test without changing the class name
DummyTestBean testBean = new DummyTestBean();
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("bean", testBean);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertThat(historicVariableInstance).isNotNull();
assertThat((Boolean) historicVariableInstance.getValue()).isTrue();
}
assertProcessEnded(processInstance.getId());
// now test with changing the class name
testBean = new DummyTestBean();
varMap = new HashMap<String, Object>();
varMap.put("bean2", testBean);
processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
String processDefinitionId = processInstance.getProcessDefinitionId();
ObjectNode infoNode = dynamicBpmnService.changeServiceTaskExpression("service", "${bean2.test(execution)}");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertThat(historicVariableInstance).isNotNull();
assertThat((Boolean) historicVariableInstance.getValue()).isTrue();
}
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class DynamicServiceTaskTest method testChangeDelegateExpression.
@Deployment
public void testChangeDelegateExpression() {
// first test without changing the class name
DummyTestDelegateBean testBean = new DummyTestDelegateBean();
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("bean", testBean);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertThat(historicVariableInstance).isNotNull();
assertThat((Boolean) historicVariableInstance.getValue()).isTrue();
}
assertProcessEnded(processInstance.getId());
// now test with changing the class name
testBean = new DummyTestDelegateBean();
varMap = new HashMap<String, Object>();
varMap.put("bean2", testBean);
processInstance = runtimeService.startProcessInstanceByKey("dynamicServiceTask", varMap);
String processDefinitionId = processInstance.getProcessDefinitionId();
ObjectNode infoNode = dynamicBpmnService.changeServiceTaskDelegateExpression("service", "${bean2}");
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("executed").singleResult();
assertThat(historicVariableInstance).isNotNull();
assertThat((Boolean) historicVariableInstance.getValue()).isTrue();
}
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.history.HistoricVariableInstance in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowHistoricProcessInstanceService method toDto.
private WorkflowHistoricProcessInstanceDto toDto(HistoricProcessInstance instance, boolean trimmed) {
if (instance == null) {
return null;
}
String instanceName = instance.getName();
// processInstanceName
if (instanceName == null && instance.getProcessVariables() != null && instance.getProcessVariables().containsKey(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME)) {
instanceName = (String) instance.getProcessVariables().get(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME);
}
// historic variables
if (instanceName == null || instanceName.isEmpty()) {
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.getId()).variableName(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME).singleResult();
instanceName = variableInstance != null ? (String) variableInstance.getValue() : null;
}
if (instanceName == null || instanceName.isEmpty()) {
instanceName = definitionService.get(instance.getProcessDefinitionId()).getName();
}
WorkflowHistoricProcessInstanceDto dto = new WorkflowHistoricProcessInstanceDto();
dto.setTrimmed(trimmed);
dto.setId(instance.getId());
dto.setName(instanceName);
dto.setProcessDefinitionId(instance.getProcessDefinitionId());
dto.setProcessDefinitionKey(instance.getProcessDefinitionKey());
dto.setProcessVariables(instance.getProcessVariables());
dto.setDeleteReason(instance.getDeleteReason());
dto.setDurationInMillis(instance.getDurationInMillis());
dto.setEndTime(instance.getEndTime());
dto.setStartActivityId(instance.getStartActivityId());
dto.setStartTime(instance.getStartTime());
dto.setStartUserId(instance.getStartUserId());
dto.setSuperProcessInstanceId(instance.getSuperProcessInstanceId());
return dto;
}
use of org.activiti.engine.history.HistoricVariableInstance in project alfresco-remote-api by Alfresco.
the class ProcessesImpl method getVariables.
@Override
public CollectionWithPagingInfo<Variable> getVariables(String processId, Paging paging) {
CollectionWithPagingInfo<Variable> result = null;
// Check if user is allowed to get variables
List<HistoricVariableInstance> variableInstances = validateIfUserAllowedToWorkWithProcess(processId);
Map<String, Object> variables = new HashMap<String, Object>();
for (HistoricVariableInstance variable : variableInstances) {
variables.put(variable.getVariableName(), variable.getValue());
}
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
String processDefinitionId = null;
if (processInstance != null) {
processDefinitionId = processInstance.getProcessDefinitionId();
} else {
// Completed process instance
HistoricProcessInstance historicInstance = activitiProcessEngine.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processId).singleResult();
if (historicInstance == null) {
throw new EntityNotFoundException(processId);
}
processDefinitionId = historicInstance.getProcessDefinitionId();
}
// Get start-task definition for explicit typing of variables submitted at the start
String formKey = null;
StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(processDefinitionId);
if (startFormData != null) {
formKey = startFormData.getFormKey();
}
TypeDefinition startTaskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true);
// Convert raw variables to Variable objects
List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition);
result = CollectionWithPagingInfo.asPaged(paging, resultingVariables);
return result;
}
use of org.activiti.engine.history.HistoricVariableInstance in project alfresco-remote-api by Alfresco.
the class WorkflowRestImpl method getItemsFromProcess.
/**
* Get all items from the process package variable
*/
public CollectionWithPagingInfo<Item> getItemsFromProcess(String processId, Paging paging) {
ActivitiScriptNode packageScriptNode = null;
try {
HistoricVariableInstance variableInstance = activitiProcessEngine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processId).variableName(BPM_PACKAGE).singleResult();
if (variableInstance != null) {
packageScriptNode = (ActivitiScriptNode) variableInstance.getValue();
} else {
throw new EntityNotFoundException(processId);
}
} catch (ActivitiObjectNotFoundException e) {
throw new EntityNotFoundException(processId);
}
List<Item> page = new ArrayList<Item>();
if (packageScriptNode != null) {
List<ChildAssociationRef> documentList = nodeService.getChildAssocs(packageScriptNode.getNodeRef());
for (ChildAssociationRef childAssociationRef : documentList) {
Item item = createItemForNodeRef(childAssociationRef.getChildRef());
page.add(item);
}
}
return CollectionWithPagingInfo.asPaged(paging, page, false, page.size());
}
Aggregations