use of org.activiti.engine.impl.variable.EntityManagerSessionFactory in project Activiti by Activiti.
the class HistoricJPAVariableTest method initializeProcessEngine.
@Override
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class);
entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
}
processEngine = cachedProcessEngine;
}
use of org.activiti.engine.impl.variable.EntityManagerSessionFactory in project Activiti by Activiti.
the class JPAVariableTest method initializeProcessEngine.
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class);
entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
}
processEngine = cachedProcessEngine;
}
use of org.activiti.engine.impl.variable.EntityManagerSessionFactory in project Activiti by Activiti.
the class ProcessEngineConfigurationImpl method initJpa.
// JPA
// //////////////////////////////////////////////////////////////////////
public void initJpa() {
if (jpaPersistenceUnitName != null) {
jpaEntityManagerFactory = JpaHelper.createEntityManagerFactory(jpaPersistenceUnitName);
}
if (jpaEntityManagerFactory != null) {
sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(jpaEntityManagerFactory, jpaHandleTransaction, jpaCloseEntityManager));
VariableType jpaType = variableTypes.getVariableType(JPAEntityVariableType.TYPE_NAME);
// Add JPA-type
if (jpaType == null) {
// We try adding the variable right before SerializableType, if
// available
int serializableIndex = variableTypes.getTypeIndex(SerializableType.TYPE_NAME);
if (serializableIndex > -1) {
variableTypes.addType(new JPAEntityVariableType(), serializableIndex);
} else {
variableTypes.addType(new JPAEntityVariableType());
}
}
jpaType = variableTypes.getVariableType(JPAEntityListVariableType.TYPE_NAME);
// Add JPA-list type after regular JPA type if not already present
if (jpaType == null) {
variableTypes.addType(new JPAEntityListVariableType(), variableTypes.getTypeIndex(JPAEntityVariableType.TYPE_NAME));
}
}
}
use of org.activiti.engine.impl.variable.EntityManagerSessionFactory in project Activiti by Activiti.
the class FullHistoryTest method testReadJpaVariableValueFromHistoricVariableUpdate.
@Deployment(resources = { "org/activiti/standalone/jpa/JPAVariableTest.testQueryJPAVariable.bpmn20.xml" })
public void testReadJpaVariableValueFromHistoricVariableUpdate() {
EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class);
EntityManagerFactory entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
String executionId = runtimeService.startProcessInstanceByKey("JPAVariableProcess").getProcessInstanceId();
String variableName = "name";
FieldAccessJPAEntity entity = new FieldAccessJPAEntity();
entity.setId(1L);
entity.setValue("Test");
EntityManager manager = entityManagerFactory.createEntityManager();
manager.getTransaction().begin();
manager.persist(entity);
manager.flush();
manager.getTransaction().commit();
manager.close();
Task task = taskService.createTaskQuery().processInstanceId(executionId).taskName("my task").singleResult();
runtimeService.setVariable(executionId, variableName, entity);
taskService.complete(task.getId());
List<HistoricDetail> variableUpdates = historyService.createHistoricDetailQuery().processInstanceId(executionId).variableUpdates().list();
assertThat(variableUpdates.size()).isEqualTo(1);
HistoricVariableUpdate update = (HistoricVariableUpdate) variableUpdates.get(0);
assertThat(update.getValue()).isNotNull();
assertThat(update.getValue()).isInstanceOf(FieldAccessJPAEntity.class);
assertThat(((FieldAccessJPAEntity) update.getValue()).getId()).isEqualTo(entity.getId());
}
use of org.activiti.engine.impl.variable.EntityManagerSessionFactory in project Activiti by Activiti.
the class JPAEnhancedVariableTest method initializeProcessEngine.
@Override
protected void initializeProcessEngine() {
if (cachedProcessEngine == null) {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/standalone/jpa/activiti.cfg.xml");
cachedProcessEngine = processEngineConfiguration.buildProcessEngine();
EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration.getSessionFactories().get(EntityManagerSession.class);
entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
setupJPAVariables();
}
processEngine = cachedProcessEngine;
}
Aggregations