Search in sources :

Example 6 with PersistenceManager

use of org.broadleafcommerce.openadmin.server.service.persistence.PersistenceManager in project BroadleafCommerce by BroadleafCommerce.

the class AbstractRuleBuilderFieldService method onApplicationEvent.

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
    // This bean only is valid when the following bean is active. (admin)
    if (applicationContext.containsBean(PersistenceManagerFactory.getPersistenceManagerRef()) && applicationContext.containsBean("blPersistenceManagerFactory")) {
        // initialize the factory bean
        applicationContext.getBean("blPersistenceManagerFactory");
        PersistenceManager persistenceManager = PersistenceManagerFactory.getDefaultPersistenceManager();
        dynamicEntityDao = persistenceManager.getDynamicEntityDao();
        setFields(new ArrayList<FieldData>());
        // This cannot be null during startup as we do not want to remove the null safety checks in a multi-tenant env.
        boolean contextWasNull = false;
        if (BroadleafRequestContext.getBroadleafRequestContext() == null) {
            BroadleafRequestContext brc = new BroadleafRequestContext();
            brc.setIgnoreSite(true);
            BroadleafRequestContext.setBroadleafRequestContext(brc);
            contextWasNull = true;
        }
        try {
            init();
            // Initialize additional static fields method for the component.
            if (extensionManager != null) {
                extensionManager.getProxy().addFields(fields, getName(), getDtoClassName());
            }
            validateRuleBuilderState(this);
        } finally {
            if (contextWasNull) {
                BroadleafRequestContext.setBroadleafRequestContext(null);
            }
        }
    }
}
Also used : FieldData(org.broadleafcommerce.openadmin.web.rulebuilder.dto.FieldData) PersistenceManager(org.broadleafcommerce.openadmin.server.service.persistence.PersistenceManager) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext)

Aggregations

PersistenceManager (org.broadleafcommerce.openadmin.server.service.persistence.PersistenceManager)6 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 From (javax.persistence.criteria.From)1 Path (javax.persistence.criteria.Path)1 ServiceException (org.broadleafcommerce.common.exception.ServiceException)1 BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)1 ProductOptionValueImpl (org.broadleafcommerce.core.catalog.domain.ProductOptionValueImpl)1 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)1 BasicFieldMetadata (org.broadleafcommerce.openadmin.dto.BasicFieldMetadata)1 ClassMetadata (org.broadleafcommerce.openadmin.dto.ClassMetadata)1 DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)1 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)1