From 80a50e94aa83cd6311756c4f98e7577155f2ca13 Mon Sep 17 00:00:00 2001 From: Arimihanta Date: Tue, 16 Nov 2021 10:05:33 +0100 Subject: [PATCH] endpoint document (carto/basic) --- .../fr/lirmm/aren/service/DocumentService.java | 15 +++++++++++++++ .../fr/lirmm/aren/ws/rest/DocumentRESTFacade.java | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/lirmm/aren/service/DocumentService.java b/src/main/java/fr/lirmm/aren/service/DocumentService.java index 48719b3..bdb0f19 100644 --- a/src/main/java/fr/lirmm/aren/service/DocumentService.java +++ b/src/main/java/fr/lirmm/aren/service/DocumentService.java @@ -82,6 +82,21 @@ public class DocumentService extends AbstractService { return new HashSet(generateQuery(null, withDebates).getResultList()); } + public Set findAllByType(boolean withDebates, String type){ + TypedQuery query = getEntityManager().createQuery("SELECT do " + + "FROM Document do " + + (withDebates + ? "LEFT JOIN FETCH do.debates d " + : "") + + (type.equalsIgnoreCase("CARTO") + ?"WHERE do.type = :type " + :"WHERE do.type = :type OR do.type = NULL "), + Document.class) + .setParameter("type",type); + + return new HashSet(query.getResultList()); + } + /** * * @param document diff --git a/src/main/java/fr/lirmm/aren/ws/rest/DocumentRESTFacade.java b/src/main/java/fr/lirmm/aren/ws/rest/DocumentRESTFacade.java index 505f095..0a04f3b 100644 --- a/src/main/java/fr/lirmm/aren/ws/rest/DocumentRESTFacade.java +++ b/src/main/java/fr/lirmm/aren/ws/rest/DocumentRESTFacade.java @@ -43,6 +43,13 @@ public class DocumentRESTFacade extends AbstractRESTFacade { return documentService.findAll(withDebates); } + @Path("{type}") + @RolesAllowed({"MODO"}) + public Set findAllByType(@PathParam("type") String type) { + boolean withDebates = this.overview == null; + return documentService.findAllByType(withDebates, type); + } + /** * * @param id @@ -57,7 +64,7 @@ public class DocumentRESTFacade extends AbstractRESTFacade { /** * - * @param id + * @param doc * @return */ @Override