Skip to content

Commit 8b2961a

Browse files
author
Chad Harchar
committed
BroadleafCommerce/QA#935 - Only show APPROVAL sandboxes in the "Include my changes" list if there is no USER sandbox
1 parent 64de43b commit 8b2961a

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

common/src/main/java/org/broadleafcommerce/common/sandbox/dao/SandBoxDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public interface SandBoxDao {
4444

4545
public Map<Long, String> retrieveAuthorNamesForSandBoxes(Set<Long> sandBoxIds);
4646

47+
List<SandBox> retrieveSandBoxesForAuthor(Long authorId, SandBoxType sandBoxType);
48+
4749
public SandBox persist(SandBox entity);
4850

4951
public SandBox createSandBox(String sandBoxName, SandBoxType sandBoxType);

common/src/main/java/org/broadleafcommerce/common/sandbox/dao/SandBoxDaoImpl.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,25 @@ public Map<Long, String> retrieveAuthorNamesForSandBoxes(Set<Long> sandBoxIds) {
231231

232232
@Override
233233
public List<SandBox> retrieveSandBoxesForAuthor(Long authorId) {
234+
return retrieveSandBoxesForAuthor(authorId, null);
235+
}
236+
237+
@Override
238+
public List<SandBox> retrieveSandBoxesForAuthor(Long authorId, SandBoxType sandBoxType) {
234239
CriteriaBuilder builder = sandBoxEntityManager.getCriteriaBuilder();
235240
CriteriaQuery<SandBox> criteria = builder.createQuery(SandBox.class);
236241
Root<SandBoxManagementImpl> sandbox = criteria.from(SandBoxManagementImpl.class);
237242
criteria.select(sandbox.get("sandBox").as(SandBox.class));
238-
criteria.where(
239-
builder.and(builder.equal(sandbox.get("sandBox").get("author"), authorId),
240-
builder.or(builder.isNull(sandbox.get("sandBox").get("archiveStatus").get("archived").as(String.class)),
241-
builder.notEqual(sandbox.get("sandBox").get("archiveStatus").get("archived").as(Character.class), 'Y')))
243+
List<Predicate> restrictions = new ArrayList<Predicate>();
244+
restrictions.add(builder.equal(sandbox.get("sandBox").get("author"), authorId));
245+
if (sandBoxType != null) {
246+
restrictions.add(builder.equal(sandbox.get("sandBox").get("sandboxType"), sandBoxType.getType()));
247+
}
248+
restrictions.add(
249+
builder.or(builder.isNull(sandbox.get("sandBox").get("archiveStatus").get("archived").as(String.class)),
250+
builder.notEqual(sandbox.get("sandBox").get("archiveStatus").get("archived").as(Character.class), 'Y'))
242251
);
252+
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
243253
TypedQuery<SandBox> query = sandBoxEntityManager.createQuery(criteria);
244254
return query.getResultList();
245255
}

common/src/main/java/org/broadleafcommerce/common/sandbox/service/SandBoxServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public SandBox retrieveSandBoxManagementById(Long sandBoxId) {
7171
@Override
7272
public List<SandBox> retrievePreviewSandBoxes(Long authorId) {
7373
List<SandBox> returnList = new ArrayList<SandBox>();
74-
List<SandBox> authorBoxes = sandBoxDao.retrieveSandBoxesForAuthor(authorId);
74+
List<SandBox> authorBoxes = sandBoxDao.retrieveSandBoxesForAuthor(authorId, SandBoxType.USER);
7575
List<SandBox> approvalBoxes = sandBoxDao.retrieveSandBoxesByType(SandBoxType.APPROVAL);
7676
List<SandBox> defaultBoxes = sandBoxDao.retrieveSandBoxesByType(SandBoxType.DEFAULT);
7777

0 commit comments

Comments
 (0)