mirror of
https://github.com/ArenMg/aren.git
synced 2025-01-24 06:50:49 +00:00
endpoint document (carto/basic)
This commit is contained in:
parent
bf8f6997e3
commit
80a50e94aa
2 changed files with 23 additions and 1 deletions
|
@ -82,6 +82,21 @@ public class DocumentService extends AbstractService<Document> {
|
||||||
return new HashSet<Document>(generateQuery(null, withDebates).getResultList());
|
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
|
* @param document
|
||||||
|
|
|
@ -43,6 +43,13 @@ public class DocumentRESTFacade extends AbstractRESTFacade<Document> {
|
||||||
return documentService.findAll(withDebates);
|
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
|
* @param id
|
||||||
|
@ -57,7 +64,7 @@ public class DocumentRESTFacade extends AbstractRESTFacade<Document> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id
|
* @param doc
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue