use of org.activiti.engine.history.HistoricDetail in project Activiti by Activiti.
the class FullHistoryTest method testHistoricFormPropertiesOnReEnteringActivity.
/**
* Test created to validate ACT-621 fix.
*/
@Deployment
public void testHistoricFormPropertiesOnReEnteringActivity() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("comeBack", Boolean.TRUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("HistoricFormPropertiesProcess", variables);
assertNotNull(processInstance);
// Submit form on task
Map<String, String> data = new HashMap<String, String>();
data.put("formProp1", "Property value");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
formService.submitTaskFormData(task.getId(), data);
// Historic property should be available
List<HistoricDetail> details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
assertNotNull(details);
assertEquals(1, details.size());
// Task should be active in the same activity as the previous one
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
formService.submitTaskFormData(task.getId(), data);
details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
assertNotNull(details);
assertEquals(2, details.size());
// Should have 2 different historic activity instance ID's, with the same activityId
assertNotSame(details.get(0).getActivityInstanceId(), details.get(1).getActivityInstanceId());
HistoricActivityInstance historicActInst1 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(0).getActivityInstanceId()).singleResult();
HistoricActivityInstance historicActInst2 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(1).getActivityInstanceId()).singleResult();
assertEquals(historicActInst1.getActivityId(), historicActInst2.getActivityId());
}
use of org.activiti.engine.history.HistoricDetail in project Activiti by Activiti.
the class HistoricDetailQueryImpl method executeList.
public List<HistoricDetail> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
List<HistoricDetail> historicDetails = commandContext.getHistoricDetailEntityManager().findHistoricDetailsByQueryCriteria(this, page);
HistoricDetailVariableInstanceUpdateEntity varUpdate = null;
if (historicDetails != null) {
for (HistoricDetail historicDetail : historicDetails) {
if (historicDetail instanceof HistoricDetailVariableInstanceUpdateEntity) {
varUpdate = (HistoricDetailVariableInstanceUpdateEntity) historicDetail;
// Touch byte-array to ensure initialized inside context
// TODO there should be a generic way to initialize variable values
varUpdate.getBytes();
// cached value
if (varUpdate.getVariableType() instanceof JPAEntityVariableType) {
// Use HistoricJPAEntityVariableType to force caching of value to return from query
varUpdate.setVariableType(HistoricJPAEntityVariableType.getSharedInstance());
varUpdate.getValue();
} else if (varUpdate.getVariableType() instanceof JPAEntityListVariableType) {
// Use HistoricJPAEntityListVariableType to force caching of list to return from query
varUpdate.setVariableType(HistoricJPAEntityListVariableType.getSharedInstance());
varUpdate.getValue();
}
}
}
}
return historicDetails;
}
use of org.activiti.engine.history.HistoricDetail 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.HistoricDetail 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.HistoricDetail in project Activiti by Activiti.
the class RuntimeServiceTest method checkHistoricVariableUpdateEntity.
private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
boolean deletedVariableUpdateFound = false;
List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
for (HistoricDetail currentHistoricDetail : resultSet) {
assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;
if (historicVariableUpdate.getName().equals(variableName)) {
if (historicVariableUpdate.getValue() == null) {
if (deletedVariableUpdateFound) {
fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
} else {
deletedVariableUpdateFound = true;
}
}
}
}
assertTrue(deletedVariableUpdateFound);
}
}
Aggregations