Search in sources :

Example 1 with QueryDescriptor

use of org.hibernate.search.query.engine.spi.QueryDescriptor in project nikita-noark5-core by HiOA-ABI.

the class FondsHateoasController method findAllFonds.

// Find all fonds using elasticsearch ... This is experimental and not part of the standard
// No swagger documentation on this. If we decide to drop db for es, then all re
// GET [contextPath][api]/arkivstruktur/arkiv/all/
@RequestMapping(method = RequestMethod.GET, value = FONDS + SLASH + "all" + SLASH)
public ResponseEntity<FondsHateoas> findAllFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "filter", required = false) String filter) {
    Session session = entityManager.unwrap(Session.class);
    FullTextSession fullTextSession = Search.getFullTextSession(session);
    QueryDescriptor query = ElasticsearchQueries.fromQueryString("title:test fonds");
    List<Fonds> result = fullTextSession.createFullTextQuery(query, Fonds.class).list();
    FondsHateoas fondsHateoas = new FondsHateoas((ArrayList<INikitaEntity>) (ArrayList) result);
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsHateoas);
}
Also used : QueryDescriptor(org.hibernate.search.query.engine.spi.QueryDescriptor) FullTextSession(org.hibernate.search.FullTextSession) FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) Fonds(nikita.model.noark5.v4.Fonds) FullTextSession(org.hibernate.search.FullTextSession) Session(org.hibernate.Session)

Aggregations

ArrayList (java.util.ArrayList)1 Fonds (nikita.model.noark5.v4.Fonds)1 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)1 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)1 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)1 Session (org.hibernate.Session)1 FullTextSession (org.hibernate.search.FullTextSession)1 QueryDescriptor (org.hibernate.search.query.engine.spi.QueryDescriptor)1