Java Code Examples for org.activiti.engine.history.HistoricVariableInstance#getValue()
The following examples show how to use
org.activiti.engine.history.HistoricVariableInstance#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiTaskFormService.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public List<ProcessInstanceVariableRepresentation> getProcessInstanceVariables(String taskId) { HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId); List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().processInstanceId(task.getProcessInstanceId()).list(); // Get all process-variables to extract values from Map<String, ProcessInstanceVariableRepresentation> processInstanceVariables = new HashMap<String, ProcessInstanceVariableRepresentation>(); for (HistoricVariableInstance historicVariableInstance : historicVariables) { ProcessInstanceVariableRepresentation processInstanceVariableRepresentation = new ProcessInstanceVariableRepresentation( historicVariableInstance.getVariableName(), historicVariableInstance.getVariableTypeName(), historicVariableInstance.getValue()); processInstanceVariables.put(historicVariableInstance.getId(), processInstanceVariableRepresentation); } List<ProcessInstanceVariableRepresentation> processInstanceVariableRepresenations = new ArrayList<ProcessInstanceVariableRepresentation>(processInstanceVariables.values()); return processInstanceVariableRepresenations; }
Example 2
Source File: HistoricJPAVariableTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testGetJPAEntityAsHistoricVariable() { setupJPAEntities(); // ----------------------------------------------------------------------------- // Simple test, Start process with JPA entities as variables // ----------------------------------------------------------------------------- Map<String, Object> variables = new HashMap<String, Object>(); variables.put("simpleEntityFieldAccess", simpleEntityFieldAccess); // Start the process with the JPA-entities as variables. They will be stored in the DB. this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId(); for (Task task : taskService.createTaskQuery().includeTaskLocalVariables().list()) { taskService.complete(task.getId()); } // Get JPAEntity Variable by HistoricVariableInstanceQuery HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery() .processInstanceId(processInstanceId).variableName("simpleEntityFieldAccess").singleResult(); Object value = historicVariableInstance.getValue(); assertTrue(value instanceof FieldAccessJPAEntity); assertEquals(((FieldAccessJPAEntity)value).getValue(), simpleEntityFieldAccess.getValue()); }
Example 3
Source File: HistoricJPAVariableTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testGetJPAEntityAsHistoricVariable() { setupJPAEntities(); // ----------------------------------------------------------------------------- // Simple test, Start process with JPA entities as variables // ----------------------------------------------------------------------------- Map<String, Object> variables = new HashMap<String, Object>(); variables.put("simpleEntityFieldAccess", simpleEntityFieldAccess); // Start the process with the JPA-entities as variables. They will be stored // in the DB. this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId(); for (Task task : taskService.createTaskQuery().includeTaskLocalVariables().list()) { taskService.complete(task.getId()); } // Get JPAEntity Variable by HistoricVariableInstanceQuery HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).variableName("simpleEntityFieldAccess") .singleResult(); Object value = historicVariableInstance.getValue(); assertTrue(value instanceof FieldAccessJPAEntity); assertEquals(((FieldAccessJPAEntity) value).getValue(), simpleEntityFieldAccess.getValue()); }
Example 4
Source File: CustomFlowExecutionListenerTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/examples/bpmn/executionlistener/CustomFlowExecutionListenerTest.bpmn20.xml" }) public void testScriptExecutionListener() { Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("customFlowBean", new CustomFlowBean()); runtimeService.startProcessInstanceByKey("scriptExecutionListenerProcess", variableMap); HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("flow1_activiti_conditions").singleResult(); assertNotNull(variable); assertEquals("flow1_activiti_conditions", variable.getVariableName()); @SuppressWarnings("unchecked") List<String> conditions = (List<String>) variable.getValue(); assertEquals(2, conditions.size()); assertEquals("hello", conditions.get(0)); assertEquals("world", conditions.get(1)); }
Example 5
Source File: AsyncTaskTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testAsyncEndEvent() { // start process ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncEndEvent"); // now there should be one job in the database: assertEquals(1, managementService.createJobQuery().count()); Object value = runtimeService.getVariable(processInstance.getId(), "variableSetInExecutionListener"); assertNull(value); waitForJobExecutorToProcessAllJobs(2000L, 200L); // the job is done assertEquals(0, managementService.createJobQuery().count()); assertProcessEnded(processInstance.getId()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).list(); assertEquals(3, variables.size()); Object historyValue = null; for (HistoricVariableInstance variable : variables) { if ("variableSetInExecutionListener".equals(variable.getVariableName())) { historyValue = variable.getValue(); } } assertEquals("firstValue", historyValue); } }
Example 6
Source File: CustomFlowExecutionListenerTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti5/examples/bpmn/executionlistener/CustomFlowExecutionListenerTest.bpmn20.xml" }) public void testScriptExecutionListener() { Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("customFlowBean", new CustomFlowBean()); runtimeService.startProcessInstanceByKey("scriptExecutionListenerProcess", variableMap); HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("flow1_activiti_conditions").singleResult(); assertNotNull(variable); assertEquals("flow1_activiti_conditions", variable.getVariableName()); @SuppressWarnings("unchecked") List<String> conditions = (List<String>) variable.getValue(); assertEquals(2, conditions.size()); assertEquals("hello", conditions.get(0)); assertEquals("world", conditions.get(1)); }
Example 7
Source File: AsyncTaskTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testAsyncEndEvent() { // start process ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncEndEvent"); // now there should be one job in the database: assertEquals(1, managementService.createJobQuery().count()); Object value = runtimeService.getVariable(processInstance.getId(), "variableSetInExecutionListener"); assertNull(value); waitForJobExecutorToProcessAllJobs(2000L, 200L); // the job is done assertEquals(0, managementService.createJobQuery().count()); assertProcessEnded(processInstance.getId()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).list(); assertEquals(3, variables.size()); Object historyValue = null; for (HistoricVariableInstance variable : variables) { if ("variableSetInExecutionListener".equals(variable.getVariableName())) { historyValue = variable.getValue(); } } assertEquals("firstValue", historyValue); } }
Example 8
Source File: WorkflowRestImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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()); }
Example 9
Source File: ProcessInstanceHistoryLogQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public ProcessInstanceHistoryLog execute(CommandContext commandContext) { // Fetch historic process instance HistoricProcessInstanceEntity historicProcessInstance = commandContext.getHistoricProcessInstanceEntityManager().findById(processInstanceId); if (historicProcessInstance == null) { return null; } // Create a log using this historic process instance ProcessInstanceHistoryLogImpl processInstanceHistoryLog = new ProcessInstanceHistoryLogImpl(historicProcessInstance); // Add events, based on query settings // Tasks if (includeTasks) { List<? extends HistoricData> tasks = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstancesByQueryCriteria( new HistoricTaskInstanceQueryImpl(commandExecutor).processInstanceId(processInstanceId)); processInstanceHistoryLog.addHistoricData(tasks); } // Activities if (includeActivities) { List<HistoricActivityInstance> activities = commandContext.getHistoricActivityInstanceEntityManager().findHistoricActivityInstancesByQueryCriteria( new HistoricActivityInstanceQueryImpl(commandExecutor).processInstanceId(processInstanceId), null); processInstanceHistoryLog.addHistoricData(activities); } // Variables if (includeVariables) { List<HistoricVariableInstance> variables = commandContext.getHistoricVariableInstanceEntityManager().findHistoricVariableInstancesByQueryCriteria( new HistoricVariableInstanceQueryImpl(commandExecutor).processInstanceId(processInstanceId), null); // Make sure all variables values are fetched (similar to the HistoricVariableInstance query) for (HistoricVariableInstance historicVariableInstance : variables) { historicVariableInstance.getValue(); // make sure JPA entities are cached for later retrieval HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) historicVariableInstance; if (JPAEntityVariableType.TYPE_NAME.equals(variableEntity.getVariableType().getTypeName()) || JPAEntityListVariableType.TYPE_NAME.equals(variableEntity.getVariableType().getTypeName())) { ((CacheableVariable) variableEntity.getVariableType()).setForceCacheable(true); } } processInstanceHistoryLog.addHistoricData(variables); } // Comment if (includeComments) { List<? extends HistoricData> comments = commandContext.getCommentEntityManager().findCommentsByProcessInstanceId(processInstanceId); processInstanceHistoryLog.addHistoricData(comments); } // Details: variables if (includeVariableUpdates) { List<? extends HistoricData> variableUpdates = commandContext.getHistoricDetailEntityManager().findHistoricDetailsByQueryCriteria( new HistoricDetailQueryImpl(commandExecutor).variableUpdates(), null); // Make sure all variables values are fetched (similar to the HistoricVariableInstance query) for (HistoricData historicData : variableUpdates) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) historicData; variableUpdate.getValue(); } processInstanceHistoryLog.addHistoricData(variableUpdates); } // Details: form properties if (includeFormProperties) { List<? extends HistoricData> formProperties = commandContext.getHistoricDetailEntityManager().findHistoricDetailsByQueryCriteria( new HistoricDetailQueryImpl(commandExecutor).formProperties(), null); processInstanceHistoryLog.addHistoricData(formProperties); } // All events collected. Sort them by date. processInstanceHistoryLog.orderHistoricData(); return processInstanceHistoryLog; }
Example 10
Source File: WorkflowRestImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * Get an item from the process package variable */ public Item getItemFromProcess(String itemId, String processId) { NodeRef nodeRef = getNodeRef(itemId); 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); } Item item = null; if (packageScriptNode != null) { List<ChildAssociationRef> documentList = nodeService.getChildAssocs(packageScriptNode.getNodeRef()); for (ChildAssociationRef childAssociationRef : documentList) { if (childAssociationRef.getChildRef().equals(nodeRef)) { item = createItemForNodeRef(childAssociationRef.getChildRef()); break; } } } if (item == null) { throw new EntityNotFoundException(itemId); } return item; }
Example 11
Source File: ProcessInstanceHistoryLogQueryImpl.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public ProcessInstanceHistoryLog execute(CommandContext commandContext) { // Fetch historic process instance HistoricProcessInstanceEntity historicProcessInstance = commandContext .getHistoricProcessInstanceEntityManager().findHistoricProcessInstance(processInstanceId); if (historicProcessInstance == null) { return null; } // Create a log using this historic process instance ProcessInstanceHistoryLogImpl processInstanceHistoryLog = new ProcessInstanceHistoryLogImpl(historicProcessInstance); // Add events, based on query settings // Tasks if (includeTasks) { List<? extends HistoricData> tasks = commandContext.getHistoricTaskInstanceEntityManager() .findHistoricTaskInstancesByQueryCriteria( new HistoricTaskInstanceQueryImpl(commandExecutor).processInstanceId(processInstanceId)); processInstanceHistoryLog.addHistoricData(tasks); } // Activities if (includeActivities) { List<HistoricActivityInstance> activities = commandContext.getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( new HistoricActivityInstanceQueryImpl(commandExecutor).processInstanceId(processInstanceId), null); processInstanceHistoryLog.addHistoricData(activities); } // Variables if (includeVariables) { List<HistoricVariableInstance> variables = commandContext.getHistoricVariableInstanceEntityManager() .findHistoricVariableInstancesByQueryCriteria( new HistoricVariableInstanceQueryImpl(commandExecutor).processInstanceId(processInstanceId), null); // Make sure all variables values are fetched (similar to the HistoricVariableInstance query) for (HistoricVariableInstance historicVariableInstance : variables) { historicVariableInstance.getValue(); // make sure JPA entities are cached for later retrieval HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) historicVariableInstance; if (JPAEntityVariableType.TYPE_NAME.equals(variableEntity.getVariableType().getTypeName()) || JPAEntityListVariableType.TYPE_NAME.equals(variableEntity.getVariableType().getTypeName())) { ((CacheableVariable) variableEntity.getVariableType()).setForceCacheable(true); } } processInstanceHistoryLog.addHistoricData(variables); } // Comment if (includeComments) { List<? extends HistoricData> comments = commandContext.getCommentEntityManager().findCommentsByProcessInstanceId(processInstanceId); processInstanceHistoryLog.addHistoricData(comments); } // Details: variables if (includeVariableUpdates) { List<? extends HistoricData> variableUpdates = commandContext.getHistoricDetailEntityManager() .findHistoricDetailsByQueryCriteria(new HistoricDetailQueryImpl(commandExecutor).variableUpdates(), null); // Make sure all variables values are fetched (similar to the HistoricVariableInstance query) for (HistoricData historicData : variableUpdates) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) historicData; variableUpdate.getValue(); } processInstanceHistoryLog.addHistoricData(variableUpdates); } // Details: form properties if (includeFormProperties) { List<? extends HistoricData> formProperties = commandContext.getHistoricDetailEntityManager() .findHistoricDetailsByQueryCriteria(new HistoricDetailQueryImpl(commandExecutor).formProperties(), null); processInstanceHistoryLog.addHistoricData(formProperties); } // All events collected. Sort them by date. processInstanceHistoryLog.orderHistoricData(); return processInstanceHistoryLog; }