use of nikita.webapp.odata.NikitaODataToHQLWalker in project nikita-noark5-core by HiOA-ABI.
the class OdataTest method testOdata.
@RequestMapping(method = RequestMethod.GET, value = "arkivstruktur/{\\w*}")
public ResponseEntity<String> testOdata(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) throws Exception {
String uqueryString = request.getQueryString();
String decoded = URLDecoder.decode(uqueryString, UTF_8);
StringBuffer originalRequest = request.getRequestURL();
originalRequest.append("?" + decoded);
CharStream stream = CharStreams.fromString(originalRequest.toString());
ODataLexer lexer = new ODataLexer(stream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
ODataParser parser = new ODataParser(tokens);
ParseTree tree = parser.odataURL();
ParseTreeWalker walker = new ParseTreeWalker();
// Make the HQL Statement
NikitaODataToHQLWalker hqlWalker = new NikitaODataToHQLWalker();
walker.walk(hqlWalker, tree);
Session session = entityManager.unwrap(org.hibernate.Session.class);
Query query = hqlWalker.getHqlStatment(session);
String queryString = query.getQueryString();
System.out.println(queryString);
List<NoarkEntity> list = query.getResultList();
return ResponseEntity.status(HttpStatus.CREATED).body(list.toString());
}
Aggregations