use of org.activiti.engine.history.HistoricFormProperty in project Activiti by Activiti.
the class FullHistoryTest method testHistoricDetailQueryMixed.
@Deployment
public void testHistoricDetailQueryMixed() throws Exception {
Map<String, String> formProperties = new HashMap<String, String>();
formProperties.put("formProp1", "activiti rocks!");
formProperties.put("formProp2", "12345");
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("historicDetailMixed").singleResult();
ProcessInstance processInstance = formService.submitStartFormData(procDef.getId(), formProperties);
List<HistoricDetail> details = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).orderByVariableName().asc().list();
assertEquals(4, details.size());
assertTrue(details.get(0) instanceof HistoricFormProperty);
HistoricFormProperty formProp1 = (HistoricFormProperty) details.get(0);
assertEquals("formProp1", formProp1.getPropertyId());
assertEquals("activiti rocks!", formProp1.getPropertyValue());
assertTrue(details.get(1) instanceof HistoricFormProperty);
HistoricFormProperty formProp2 = (HistoricFormProperty) details.get(1);
assertEquals("formProp2", formProp2.getPropertyId());
assertEquals("12345", formProp2.getPropertyValue());
assertTrue(details.get(2) instanceof HistoricVariableUpdate);
HistoricVariableUpdate varUpdate1 = (HistoricVariableUpdate) details.get(2);
assertEquals("variable1", varUpdate1.getVariableName());
assertEquals("activiti rocks!", varUpdate1.getValue());
// This variable should be of type LONG since this is defined in the process-definition
assertTrue(details.get(3) instanceof HistoricVariableUpdate);
HistoricVariableUpdate varUpdate2 = (HistoricVariableUpdate) details.get(3);
assertEquals("variable2", varUpdate2.getVariableName());
assertEquals(12345L, varUpdate2.getValue());
}
use of org.activiti.engine.history.HistoricFormProperty in project Activiti by Activiti.
the class AdminCompletedInstancesPanel method addVariables.
protected void addVariables(HistoricProcessInstance processInstance) {
if (variablesHeader != null) {
mainPanel.removeComponent(variablesHeader);
mainPanel.removeComponent(variablesEmptyHeader);
}
if (noVariablesLabel != null) {
mainPanel.removeComponent(noVariablesLabel);
}
variablesHeader = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_VARIABLES));
variablesHeader.addStyleName(ExplorerLayout.STYLE_H3);
variablesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
variablesHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);
addDetailComponent(variablesHeader);
variablesEmptyHeader = new Label(" ", Label.CONTENT_XHTML);
addDetailComponent(variablesEmptyHeader);
if (variablesTable != null) {
mainPanel.removeComponent(variablesTable);
}
// variable sorting is done in-memory (which is ok, since normally there aren't that many vars)
List<HistoricDetail> variables = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).orderByTime().desc().list();
if (!variables.isEmpty()) {
variablesTable = new Table();
variablesTable.setWidth(60, UNITS_PERCENTAGE);
variablesTable.setHeight(250, UNITS_PIXELS);
variablesTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
variablesTable.addContainerProperty("name", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_VARIABLE_NAME), null, Table.ALIGN_LEFT);
variablesTable.addContainerProperty("value", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_VARIABLE_VALUE), null, Table.ALIGN_LEFT);
variablesTable.addContainerProperty("type", String.class, null, i18nManager.getMessage(Messages.GROUP_TYPE), null, Table.ALIGN_LEFT);
List<String> variableNames = new ArrayList<String>();
for (HistoricDetail detail : variables) {
if (detail instanceof HistoricVariableUpdate) {
HistoricVariableUpdate variable = (HistoricVariableUpdate) detail;
if (variableNames.contains(variable.getVariableName()) == false) {
variableNames.add(variable.getVariableName());
Item variableItem = variablesTable.addItem(variable.getVariableName());
variableItem.getItemProperty("name").setValue(variable.getVariableName());
// Get string value to show
String theValue = variableRendererManager.getStringRepresentation(variable.getValue());
variableItem.getItemProperty("value").setValue(theValue);
variableItem.getItemProperty("type").setValue("variable");
}
} else {
HistoricFormProperty form = (HistoricFormProperty) detail;
if (variableNames.contains(form.getPropertyId()) == false) {
variableNames.add(form.getPropertyId());
Item variableItem = variablesTable.addItem(form.getPropertyId());
variableItem.getItemProperty("name").setValue(form.getPropertyId());
variableItem.getItemProperty("value").setValue(form.getPropertyValue());
variableItem.getItemProperty("type").setValue("form property");
}
}
}
variablesTable.setPageLength(variables.size());
addDetailComponent(variablesTable);
} else {
noVariablesLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_VARIABLES));
addDetailComponent(noVariablesLabel);
}
}
use of org.activiti.engine.history.HistoricFormProperty in project midpoint by Evolveum.
the class ActivitiInterface method queryActivitiProcessInstance.
public void queryActivitiProcessInstance(QueryProcessCommand qpc, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
String pid = qpc.getPid();
LOGGER.trace("Querying process instance id {}", pid);
HistoryService hs = activitiEngine.getHistoryService();
HistoricDetailQuery hdq = hs.createHistoricDetailQuery().variableUpdates().processInstanceId(pid).orderByTime().desc();
Map<String, Object> variables = new HashMap<>();
for (HistoricDetail hd : hdq.list()) {
HistoricVariableUpdate hvu = (HistoricVariableUpdate) hd;
String varname = hvu.getVariableName();
Object value = hvu.getValue();
LOGGER.trace(" - found historic variable update: {} <- {}", varname, value);
if (!variables.containsKey(varname)) {
variables.put(varname, value);
}
}
HistoricDetailQuery hdq2 = hs.createHistoricDetailQuery().formProperties().processInstanceId(pid).orderByVariableRevision().desc();
for (HistoricDetail hd : hdq2.list()) {
HistoricFormProperty hfp = (HistoricFormProperty) hd;
String varname = hfp.getPropertyId();
Object value = hfp.getPropertyValue();
LOGGER.trace(" - found historic form property: {} <- {}", varname, value);
variables.put(varname, value);
}
QueryProcessResponse qpr = new QueryProcessResponse(pid, variables, processInterfaceFinder);
ProcessInstance pi = activitiEngine.getProcessEngine().getRuntimeService().createProcessInstanceQuery().processInstanceId(pid).singleResult();
qpr.setRunning(pi != null && !pi.isEnded());
LOGGER.trace("Running process instance = {}, isRunning: {}", pi, qpr.isRunning());
LOGGER.trace("Response to be sent to midPoint: {}", qpr);
wfTaskController.onProcessEvent(qpr, task, result);
}
use of org.activiti.engine.history.HistoricFormProperty in project Activiti by Activiti.
the class RestResponseFactory method createHistoricDetailResponse.
public HistoricDetailResponse createHistoricDetailResponse(HistoricDetail detail, RestUrlBuilder urlBuilder) {
HistoricDetailResponse result = new HistoricDetailResponse();
result.setId(detail.getId());
result.setProcessInstanceId(detail.getProcessInstanceId());
if (StringUtils.isNotEmpty(detail.getProcessInstanceId())) {
result.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, detail.getProcessInstanceId()));
}
result.setExecutionId(detail.getExecutionId());
result.setActivityInstanceId(detail.getActivityInstanceId());
result.setTaskId(detail.getTaskId());
if (StringUtils.isNotEmpty(detail.getTaskId())) {
result.setTaskUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE, detail.getTaskId()));
}
result.setTime(detail.getTime());
if (detail instanceof HistoricFormProperty) {
HistoricFormProperty formProperty = (HistoricFormProperty) detail;
result.setDetailType(HistoricDetailResponse.FORM_PROPERTY);
result.setPropertyId(formProperty.getPropertyId());
result.setPropertyValue(formProperty.getPropertyValue());
} else if (detail instanceof HistoricVariableUpdate) {
HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) detail;
result.setDetailType(HistoricDetailResponse.VARIABLE_UPDATE);
result.setRevision(variableUpdate.getRevision());
result.setVariable(createRestVariable(variableUpdate.getVariableName(), variableUpdate.getValue(), null, detail.getId(), VARIABLE_HISTORY_DETAIL, false, urlBuilder));
}
return result;
}
use of org.activiti.engine.history.HistoricFormProperty in project Activiti by Activiti.
the class FullHistoryTest method testHistoricFormProperties.
@Deployment
public void testHistoricFormProperties() throws Exception {
Date startedDate = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss SSS").parse("01/01/2001 01:23:46 000");
processEngineConfiguration.getClock().setCurrentTime(startedDate);
Map<String, String> formProperties = new HashMap<String, String>();
formProperties.put("formProp1", "Activiti rocks");
formProperties.put("formProp2", "12345");
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("historicFormPropertiesProcess").singleResult();
ProcessInstance processInstance = formService.submitStartFormData(procDef.getId(), formProperties);
// Submit form-properties on the created task
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
// Out execution only has a single activity waiting, the task
List<String> activityIds = runtimeService.getActiveActivityIds(task.getExecutionId());
assertNotNull(activityIds);
assertEquals(1, activityIds.size());
String taskActivityId = activityIds.get(0);
// Submit form properties
formProperties = new HashMap<String, String>();
formProperties.put("formProp3", "Activiti still rocks!!!");
formProperties.put("formProp4", "54321");
formService.submitTaskFormData(task.getId(), formProperties);
// 4 historic form properties should be created. 2 when process started, 2 when task completed
List<HistoricDetail> props = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).orderByFormPropertyId().asc().list();
HistoricFormProperty historicProperty1 = (HistoricFormProperty) props.get(0);
assertEquals("formProp1", historicProperty1.getPropertyId());
assertEquals("Activiti rocks", historicProperty1.getPropertyValue());
assertEquals(startedDate, historicProperty1.getTime());
assertEquals(processInstance.getId(), historicProperty1.getProcessInstanceId());
assertNull(historicProperty1.getTaskId());
assertNotNull(historicProperty1.getActivityInstanceId());
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(historicProperty1.getActivityInstanceId()).singleResult();
assertNotNull(historicActivityInstance);
assertEquals("start", historicActivityInstance.getActivityId());
HistoricFormProperty historicProperty2 = (HistoricFormProperty) props.get(1);
assertEquals("formProp2", historicProperty2.getPropertyId());
assertEquals("12345", historicProperty2.getPropertyValue());
assertEquals(startedDate, historicProperty2.getTime());
assertEquals(processInstance.getId(), historicProperty2.getProcessInstanceId());
assertNull(historicProperty2.getTaskId());
assertNotNull(historicProperty2.getActivityInstanceId());
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(historicProperty2.getActivityInstanceId()).singleResult();
assertNotNull(historicActivityInstance);
assertEquals("start", historicActivityInstance.getActivityId());
HistoricFormProperty historicProperty3 = (HistoricFormProperty) props.get(2);
assertEquals("formProp3", historicProperty3.getPropertyId());
assertEquals("Activiti still rocks!!!", historicProperty3.getPropertyValue());
assertEquals(startedDate, historicProperty3.getTime());
assertEquals(processInstance.getId(), historicProperty3.getProcessInstanceId());
String activityInstanceId = historicProperty3.getActivityInstanceId();
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(activityInstanceId).singleResult();
assertNotNull(historicActivityInstance);
assertEquals(taskActivityId, historicActivityInstance.getActivityId());
assertNotNull(historicProperty3.getTaskId());
HistoricFormProperty historicProperty4 = (HistoricFormProperty) props.get(3);
assertEquals("formProp4", historicProperty4.getPropertyId());
assertEquals("54321", historicProperty4.getPropertyValue());
assertEquals(startedDate, historicProperty4.getTime());
assertEquals(processInstance.getId(), historicProperty4.getProcessInstanceId());
activityInstanceId = historicProperty4.getActivityInstanceId();
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(activityInstanceId).singleResult();
assertNotNull(historicActivityInstance);
assertEquals(taskActivityId, historicActivityInstance.getActivityId());
assertNotNull(historicProperty4.getTaskId());
assertEquals(4, props.size());
}
Aggregations