use of org.broadleafcommerce.common.sandbox.domain.SandBoxImpl 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);
}
}
use of org.broadleafcommerce.common.sandbox.domain.SandBoxImpl 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);
}
}
use of org.broadleafcommerce.common.sandbox.domain.SandBoxImpl 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);
}
}
Aggregations