use of org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl in project BroadleafCommerce by BroadleafCommerce.
the class SandBoxDaoImpl method retrieveSandboxNamesForSandBoxes.
@Override
public Map<Long, String> retrieveSandboxNamesForSandBoxes(Set<Long> sandBoxIds) {
CriteriaBuilder builder = sandBoxEntityManager.getCriteriaBuilder();
CriteriaQuery<SandBox> criteria = builder.createQuery(SandBox.class);
Root<SandBoxManagementImpl> sandbox = criteria.from(SandBoxManagementImpl.class);
criteria.select(sandbox.get("sandBox").as(SandBox.class));
criteria.where(builder.and(builder.in(sandbox.get("sandBox").get("id")).value(sandBoxIds), builder.or(builder.isNull(sandbox.get("sandBox").get("archiveStatus").get("archived").as(String.class)), builder.notEqual(sandbox.get("sandBox").get("archiveStatus").get("archived").as(Character.class), 'Y'))));
TypedQuery<SandBox> query = sandBoxEntityManager.createQuery(criteria);
List<SandBox> results = query.getResultList();
Map<Long, String> map = new HashMap<Long, String>();
for (SandBox result : results) {
map.put(result.getId(), result.getName());
}
return map;
}
use of org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl in project BroadleafCommerce by BroadleafCommerce.
the class SandBoxDaoImpl method retrieveNamedSandBox.
@Override
public SandBox retrieveNamedSandBox(SandBoxType sandBoxType, String sandboxName, Long authorId) {
CriteriaBuilder builder = sandBoxEntityManager.getCriteriaBuilder();
CriteriaQuery<SandBox> criteria = builder.createQuery(SandBox.class);
Root<SandBoxManagementImpl> sandbox = criteria.from(SandBoxManagementImpl.class);
criteria.select(sandbox.get("sandBox").as(SandBox.class));
List<Predicate> restrictions = new ArrayList<Predicate>();
restrictions.add(builder.equal(sandbox.get("sandBox").get("sandboxType"), sandBoxType.getType()));
restrictions.add(builder.equal(sandbox.get("sandBox").get("name"), sandboxName));
if (authorId != null) {
restrictions.add(builder.equal(sandbox.get("sandBox").get("author"), authorId));
}
restrictions.add(builder.or(builder.isNull(sandbox.get("sandBox").get("archiveStatus").get("archived").as(String.class)), builder.notEqual(sandbox.get("sandBox").get("archiveStatus").get("archived").as(Character.class), 'Y')));
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
TypedQuery<SandBox> query = sandBoxEntityManager.createQuery(criteria);
if (query.getResultList() != null && query.getResultList().size() == 1) {
return query.getSingleResult();
} else {
return null;
}
}
use of org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl 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.SandBoxManagementImpl in project BroadleafCommerce by BroadleafCommerce.
the class SandBoxDaoImpl method retrieveSandBoxesByType.
@Override
public List<SandBox> retrieveSandBoxesByType(SandBoxType sandboxType) {
CriteriaBuilder builder = sandBoxEntityManager.getCriteriaBuilder();
CriteriaQuery<SandBox> criteria = builder.createQuery(SandBox.class);
Root<SandBoxManagementImpl> sandbox = criteria.from(SandBoxManagementImpl.class);
criteria.select(sandbox.get("sandBox").as(SandBox.class));
criteria.where(builder.and(builder.equal(sandbox.get("sandBox").get("sandboxType"), sandboxType.getType()), builder.or(builder.isNotNull(sandbox.get("sandBox").get("name")), builder.notEqual(sandbox.get("sandBox").get("name").as(String.class), "")), builder.or(builder.isNull(sandbox.get("sandBox").get("archiveStatus").get("archived").as(String.class)), builder.notEqual(sandbox.get("sandBox").get("archiveStatus").get("archived").as(Character.class), 'Y'))));
TypedQuery<SandBox> query = sandBoxEntityManager.createQuery(criteria);
return query.getResultList();
}
use of org.broadleafcommerce.common.sandbox.domain.SandBoxManagementImpl in project BroadleafCommerce by BroadleafCommerce.
the class SandBoxDaoImpl method retrieveSandBoxManagementById.
public SandBox retrieveSandBoxManagementById(Long sandBoxId) {
CriteriaBuilder builder = sandBoxEntityManager.getCriteriaBuilder();
CriteriaQuery<SandBox> criteria = builder.createQuery(SandBox.class);
Root<SandBoxManagementImpl> sandbox = criteria.from(SandBoxManagementImpl.class);
criteria.select(sandbox.get("sandBox").as(SandBox.class));
criteria.where(builder.and(builder.equal(sandbox.get("sandBox").get("id"), sandBoxId), builder.or(builder.isNull(sandbox.get("sandBox").get("archiveStatus").get("archived").as(String.class)), builder.notEqual(sandbox.get("sandBox").get("archiveStatus").get("archived").as(Character.class), 'Y'))));
TypedQuery<SandBox> query = sandBoxEntityManager.createQuery(criteria);
List<SandBox> results = query.getResultList();
if (results == null || results.size() == 0) {
return null;
}
return results.get(0);
}
Aggregations