Search in sources :

Example 1 with JPAEntityListVariableType

use of org.activiti.engine.impl.variable.JPAEntityListVariableType 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;
}
Also used : HistoricDetail(org.activiti.engine.history.HistoricDetail) HistoricJPAEntityVariableType(org.activiti.engine.impl.variable.HistoricJPAEntityVariableType) JPAEntityVariableType(org.activiti.engine.impl.variable.JPAEntityVariableType) HistoricJPAEntityListVariableType(org.activiti.engine.impl.variable.HistoricJPAEntityListVariableType) JPAEntityListVariableType(org.activiti.engine.impl.variable.JPAEntityListVariableType) HistoricDetailVariableInstanceUpdateEntity(org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)

Example 2 with JPAEntityListVariableType

use of org.activiti.engine.impl.variable.JPAEntityListVariableType in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initJpa.

// JPA //////////////////////////////////////////////////////////////////////
protected 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));
        }
    }
}
Also used : EntityManagerSessionFactory(org.activiti.engine.impl.variable.EntityManagerSessionFactory) JPAEntityListVariableType(org.activiti.engine.impl.variable.JPAEntityListVariableType) VariableType(org.activiti.engine.impl.variable.VariableType) JPAEntityVariableType(org.activiti.engine.impl.variable.JPAEntityVariableType) JPAEntityVariableType(org.activiti.engine.impl.variable.JPAEntityVariableType) JPAEntityListVariableType(org.activiti.engine.impl.variable.JPAEntityListVariableType)

Aggregations

JPAEntityListVariableType (org.activiti.engine.impl.variable.JPAEntityListVariableType)2 JPAEntityVariableType (org.activiti.engine.impl.variable.JPAEntityVariableType)2 HistoricDetail (org.activiti.engine.history.HistoricDetail)1 HistoricDetailVariableInstanceUpdateEntity (org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)1 EntityManagerSessionFactory (org.activiti.engine.impl.variable.EntityManagerSessionFactory)1 HistoricJPAEntityListVariableType (org.activiti.engine.impl.variable.HistoricJPAEntityListVariableType)1 HistoricJPAEntityVariableType (org.activiti.engine.impl.variable.HistoricJPAEntityVariableType)1 VariableType (org.activiti.engine.impl.variable.VariableType)1