From c9ba182a2e488956a8bfe8c05dc7491c46e7f1a2 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Fri, 30 Mar 2018 21:22:28 +0200 Subject: [PATCH] search acl without type --- .../com/sismics/docs/core/dao/AclDao.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/AclDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/AclDao.java index b63ce63f..31743a5f 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/AclDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/AclDao.java @@ -68,17 +68,22 @@ public class AclDao { public List getBySourceId(String sourceId, AclType type) { EntityManager em = ThreadLocalContext.get().getEntityManager(); StringBuilder sb = new StringBuilder("select a.ACL_ID_C, a.ACL_PERM_C, a.ACL_TARGETID_C, ") - .append(" u.USE_USERNAME_C, s.SHA_ID_C, s.SHA_NAME_C, g.GRP_NAME_C ") - .append(" from T_ACL a ") - .append(" left join T_USER u on u.USE_ID_C = a.ACL_TARGETID_C ") - .append(" left join T_SHARE s on s.SHA_ID_C = a.ACL_TARGETID_C ") - .append(" left join T_GROUP g on g.GRP_ID_C = a.ACL_TARGETID_C ") - .append(" where a.ACL_DELETEDATE_D is null and a.ACL_SOURCEID_C = :sourceId and a.ACL_TYPE_C = :type "); + .append(" u.USE_USERNAME_C, s.SHA_ID_C, s.SHA_NAME_C, g.GRP_NAME_C ") + .append(" from T_ACL a ") + .append(" left join T_USER u on u.USE_ID_C = a.ACL_TARGETID_C ") + .append(" left join T_SHARE s on s.SHA_ID_C = a.ACL_TARGETID_C ") + .append(" left join T_GROUP g on g.GRP_ID_C = a.ACL_TARGETID_C ") + .append(" where a.ACL_DELETEDATE_D is null and a.ACL_SOURCEID_C = :sourceId "); + if (type != null) { + sb.append(" and a.ACL_TYPE_C = :type"); + } // Perform the query Query q = em.createNativeQuery(sb.toString()); q.setParameter("sourceId", sourceId); - q.setParameter("type", type.name()); + if (type != null) { + q.setParameter("type", type.name()); + } List l = q.getResultList(); // Assemble results