Search in sources :

Example 1 with SystemPropertyImpl

use of org.broadleafcommerce.common.config.domain.SystemPropertyImpl in project BroadleafCommerce by BroadleafCommerce.

the class SystemPropertiesTest method testOverridesPropertyFiles.

@Test
@Transactional
public void testOverridesPropertyFiles() {
    String propertyFileResolved = env.getProperty("property.file.override.test", String.class);
    Assert.assertEquals(propertyFileResolved, "propertyfile");
    clearSystemPropertiesCache();
    SystemProperty prop = new SystemPropertyImpl();
    prop.setName("property.file.override.test");
    prop.setValue("testngtest");
    prop = propsDao.saveSystemProperty(prop);
    String resolvedProperty = env.getProperty(prop.getName(), String.class);
    Assert.assertEquals(resolvedProperty, prop.getValue());
    propsDao.deleteSystemProperty(prop);
    clearSystemPropertiesCache();
    String fromPropertiesFile = propsSvc.resolveSystemProperty("property.file.override.test");
    Assert.assertEquals(fromPropertiesFile, "propertyfile");
}
Also used : SystemPropertyImpl(org.broadleafcommerce.common.config.domain.SystemPropertyImpl) SystemProperty(org.broadleafcommerce.common.config.domain.SystemProperty) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SystemPropertyImpl

use of org.broadleafcommerce.common.config.domain.SystemPropertyImpl in project BroadleafCommerce by BroadleafCommerce.

the class SystemPropertiesTest method testEnvironmentResolvedFromDatabase.

@Test
@Transactional
public void testEnvironmentResolvedFromDatabase() {
    SystemProperty prop = new SystemPropertyImpl();
    prop.setName("test.property.with.environment");
    prop.setValue("database");
    propsDao.saveSystemProperty(prop);
    String resolvedProperty = env.getProperty(prop.getName(), String.class);
    Assert.assertEquals(resolvedProperty, prop.getValue());
}
Also used : SystemPropertyImpl(org.broadleafcommerce.common.config.domain.SystemPropertyImpl) SystemProperty(org.broadleafcommerce.common.config.domain.SystemProperty) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SystemPropertyImpl

use of org.broadleafcommerce.common.config.domain.SystemPropertyImpl in project BroadleafCommerce by BroadleafCommerce.

the class SystemPropertiesDaoImpl method readAllSystemProperties.

@Override
public List<SystemProperty> readAllSystemProperties() {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<SystemProperty> criteria = builder.createQuery(SystemProperty.class);
    Root<SystemPropertyImpl> handler = criteria.from(SystemPropertyImpl.class);
    criteria.select(handler);
    List<Predicate> restrictions = new ArrayList<Predicate>();
    List<Order> sorts = new ArrayList<Order>();
    try {
        if (queryExtensionManager != null) {
            queryExtensionManager.getProxy().setup(SystemPropertyImpl.class, null);
            queryExtensionManager.getProxy().refineRetrieve(SystemPropertyImpl.class, null, builder, criteria, handler, restrictions);
            queryExtensionManager.getProxy().refineOrder(SystemPropertyImpl.class, null, builder, criteria, handler, sorts);
        }
        criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
        return em.createQuery(criteria).getResultList();
    } catch (NoResultException e) {
        LOG.error(e);
        return new ArrayList<SystemProperty>();
    } finally {
        if (queryExtensionManager != null) {
            queryExtensionManager.getProxy().breakdown(SystemPropertyImpl.class, null);
        }
    }
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Order(javax.persistence.criteria.Order) SystemPropertyImpl(org.broadleafcommerce.common.config.domain.SystemPropertyImpl) ArrayList(java.util.ArrayList) NoResultException(javax.persistence.NoResultException) SystemProperty(org.broadleafcommerce.common.config.domain.SystemProperty) Predicate(javax.persistence.criteria.Predicate)

Aggregations

SystemProperty (org.broadleafcommerce.common.config.domain.SystemProperty)3 SystemPropertyImpl (org.broadleafcommerce.common.config.domain.SystemPropertyImpl)3 Transactional (org.springframework.transaction.annotation.Transactional)2 Test (org.testng.annotations.Test)2 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Order (javax.persistence.criteria.Order)1 Predicate (javax.persistence.criteria.Predicate)1