Search in sources :

Example 1 with SandBoxManagement

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

the class SandBoxDaoImpl method createDefaultSandBox.

@Override
public SandBox createDefaultSandBox() {
    TransactionStatus status = TransactionUtils.createTransaction("createSandBox", TransactionDefinition.PROPAGATION_REQUIRES_NEW, transactionManager);
    try {
        SandBox defaultSB = new SandBoxImpl();
        defaultSB.setName("Default");
        defaultSB.setSandBoxType(SandBoxType.DEFAULT);
        defaultSB.setColor("#20C0F0");
        defaultSB = persist(defaultSB);
        SandBoxManagement mgmt = new SandBoxManagementImpl();
        mgmt.setSandBox(defaultSB);
        sandBoxEntityManager.persist(mgmt);
        sandBoxEntityManager.flush();
        TransactionUtils.finalizeTransaction(status, transactionManager, false);
        return defaultSB;
    } 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)

Example 2 with SandBoxManagement

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

the class SandBoxDaoImpl method createUserSandBox.

@Override
public SandBox createUserSandBox(Long authorId, SandBox approvalSandBox) {
    TransactionStatus status = TransactionUtils.createTransaction("createSandBox", TransactionDefinition.PROPAGATION_REQUIRES_NEW, transactionManager);
    try {
        SandBox userSandBox = new SandBoxImpl();
        userSandBox.setName(approvalSandBox.getName());
        userSandBox.setAuthor(authorId);
        userSandBox.setParentSandBox(approvalSandBox);
        userSandBox.setSandBoxType(SandBoxType.USER);
        userSandBox = persist(userSandBox);
        SandBoxManagement mgmt = new SandBoxManagementImpl();
        mgmt.setSandBox(userSandBox);
        sandBoxEntityManager.persist(mgmt);
        sandBoxEntityManager.flush();
        TransactionUtils.finalizeTransaction(status, transactionManager, false);
        return userSandBox;
    } 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)

Example 3 with SandBoxManagement

use of org.broadleafcommerce.common.sandbox.domain.SandBoxManagement 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)3 SandBoxImpl (org.broadleafcommerce.common.sandbox.domain.SandBoxImpl)3 SandBoxManagement (org.broadleafcommerce.common.sandbox.domain.SandBoxManagement)3 SandBoxManagementImpl (org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3