endpoint document (carto/basic)

This commit is contained in:
Arimihanta 2021-11-16 10:05:33 +01:00
parent bf8f6997e3
commit 80a50e94aa
2 changed files with 23 additions and 1 deletions

View file

@ -82,6 +82,21 @@ public class DocumentService extends AbstractService<Document> {
return new HashSet<Document>(generateQuery(null, withDebates).getResultList());
}
public Set<Document> findAllByType(boolean withDebates, String type){
TypedQuery<Document> 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<Document>(query.getResultList());
}
/**
*
* @param document

View file

@ -43,6 +43,13 @@ public class DocumentRESTFacade extends AbstractRESTFacade<Document> {
return documentService.findAll(withDebates);
}
@Path("{type}")
@RolesAllowed({"MODO"})
public Set<Document> 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<Document> {
/**
*
* @param id
* @param doc
* @return
*/
@Override