Search in sources :

Example 11 with SandBoxManagementImpl

use of org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl in project BroadleafCommerce by BroadleafCommerce.

the class SandBoxDaoImpl method createSandBox.

@Override
public SandBox createSandBox(String sandBoxName, SandBoxType sandBoxType) {
    TransactionStatus status = TransactionUtils.createTransaction("createSandBox", TransactionDefinition.PROPAGATION_REQUIRES_NEW, transactionManager);
    try {
        SandBox approvalSandbox = retrieveNamedSandBox(sandBoxType, sandBoxName);
        if (approvalSandbox == null) {
            approvalSandbox = new SandBoxImpl();
            approvalSandbox.setName(sandBoxName);
            approvalSandbox.setSandBoxType(sandBoxType);
            approvalSandbox = persist(approvalSandbox);
            SandBoxManagement mgmt = new SandBoxManagementImpl();
            mgmt.setSandBox(approvalSandbox);
            sandBoxEntityManager.persist(mgmt);
            sandBoxEntityManager.flush();
        }
        TransactionUtils.finalizeTransaction(status, transactionManager, false);
        return approvalSandbox;
    } catch (Exception ex) {
        TransactionUtils.finalizeTransaction(status, transactionManager, true);
        throw new RuntimeException(ex);
    }
}
Also used : SandBox(org.broadleafcommerce.common.sandbox.domain.SandBox) SandBoxManagement(org.broadleafcommerce.common.sandbox.domain.SandBoxManagement) TransactionStatus(org.springframework.transaction.TransactionStatus) SandBoxImpl(org.broadleafcommerce.common.sandbox.domain.SandBoxImpl) SandBoxManagementImpl(org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl)

Aggregations

SandBox (org.broadleafcommerce.common.sandbox.domain.SandBox)11 SandBoxManagementImpl (org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl)11 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)8 ArrayList (java.util.ArrayList)3 Predicate (javax.persistence.criteria.Predicate)3 SandBoxImpl (org.broadleafcommerce.common.sandbox.domain.SandBoxImpl)3 SandBoxManagement (org.broadleafcommerce.common.sandbox.domain.SandBoxManagement)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3 HashMap (java.util.HashMap)1