use of org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceQueryImpl method executeList.
public List<HistoricVariableInstance> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
ensureVariablesInitialized();
List<HistoricVariableInstance> historicVariableInstances = commandContext.getHistoricVariableInstanceManager().findHistoricVariableInstancesByQueryCriteria(this, page);
if (historicVariableInstances != null) {
for (HistoricVariableInstance historicVariableInstance : historicVariableInstances) {
HistoricVariableInstanceEntity variableInstanceEntity = (HistoricVariableInstanceEntity) historicVariableInstance;
if (shouldFetchValue(variableInstanceEntity)) {
try {
variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled);
} catch (Exception t) {
// do not fail if one of the variables fails to load
LOG.exceptionWhileGettingValueForVariable(t);
}
}
}
}
return historicVariableInstances;
}
use of org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project camunda-bpm-platform by camunda.
the class DbHistoryEventHandler method insertHistoricVariableUpdateEntity.
/**
* customized insert behavior for HistoricVariableUpdateEventEntity
*/
protected void insertHistoricVariableUpdateEntity(HistoricVariableUpdateEventEntity historyEvent) {
DbEntityManager dbEntityManager = getDbEntityManager();
// insert update only if history level = FULL
if (shouldWriteHistoricDetail(historyEvent)) {
// insert byte array entity (if applicable)
byte[] byteValue = historyEvent.getByteValue();
if (byteValue != null) {
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(historyEvent.getVariableName(), byteValue);
Context.getCommandContext().getDbEntityManager().insert(byteArrayEntity);
historyEvent.setByteArrayId(byteArrayEntity.getId());
}
dbEntityManager.insert(historyEvent);
}
// always insert/update HistoricProcessVariableInstance
if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_CREATE)) {
HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent);
dbEntityManager.insert(persistentObject);
} else if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_UPDATE) || historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_MIGRATE)) {
HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId());
if (historicVariableInstanceEntity != null) {
historicVariableInstanceEntity.updateFromEvent(historyEvent);
historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_CREATED);
} else {
// #CAM-1344 / #SUPPORT-688
// this is a FIX for process instances which were started in camunda fox 6.1 and migrated to camunda BPM 7.0.
// in fox 6.1 the HistoricVariable instances were flushed to the DB when the process instance completed.
// Since fox 6.2 we populate the HistoricVariable table as we go.
HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent);
dbEntityManager.insert(persistentObject);
}
} else if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_DELETE)) {
HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId());
if (historicVariableInstanceEntity != null) {
historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_DELETED);
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project camunda-bpm-platform by camunda.
the class DeserializableVariableTest method testVariableDeserializationOnProcessApplicationRestart.
@Test
@OperateOnDeployment("clientDeployment")
public void testVariableDeserializationOnProcessApplicationRestart() {
// given
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testDeserializeVariable");
// when
Assert.assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult());
runtimeService.restartProcessInstances(pi.getProcessDefinitionId()).startAfterActivity("servicetask1").processInstanceIds(pi.getId()).execute();
// then
// Since the variable retrieval is done outside the Process Application Context as well,
// custom object deserialization is disabled and a null check is performed
List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery().disableCustomObjectDeserialization().list();
for (HistoricVariableInstance variable : variableInstances) {
if (variable.getProcessInstanceId() != pi.getId() && variable instanceof HistoricVariableInstanceEntity) {
Assert.assertNotNull(((HistoricVariableInstanceEntity) variable).getByteArrayValue());
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceTest method testHistoricVariableInstanceRevision.
@Deployment
public void testHistoricVariableInstanceRevision() {
// given:
// a finished process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
assertProcessEnded(processInstance.getId());
// when
// then
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().singleResult();
assertNotNull(variable);
HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) variable;
// the revision has to be 0
assertEquals(0, variableEntity.getRevision());
if (isFullHistoryEnabled()) {
List<HistoricDetail> details = historyService.createHistoricDetailQuery().orderByVariableRevision().asc().list();
for (HistoricDetail detail : details) {
HistoricVariableUpdate variableDetail = (HistoricVariableUpdate) detail;
assertEquals(0, variableDetail.getRevision());
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceTest method testParallelNoWaitState.
@Deployment
public void testParallelNoWaitState() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc");
assertProcessEnded(processInstance.getId());
List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(1, variables.size());
HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0);
assertEquals("test456", historicVariable.getTextValue());
assertEquals(7, historyService.createHistoricActivityInstanceQuery().count());
if (isFullHistoryEnabled()) {
assertEquals(2, historyService.createHistoricDetailQuery().count());
}
}
Aggregations