private SearchCondition<Person> getSearchCondition(SearchContext context, String expression) { return context.getCondition(expression, Person.class, beanPropertiesMap); }
private SearchCondition<LogRecord> getCurrentCondition() { SearchCondition<LogRecord> current = context.getContext(SearchContext.class) .getCondition(LogRecord.class); if (current == null) { return readableStorageCondition; } else { return current; } }
@Override public <T, E> E getConvertedExpression(String originalExpression, Class<T> beanClass, Class<E> queryClass) { SearchConditionVisitor<T, E> visitor = getVisitor(); if (visitor == null) { return null; } SearchCondition<T> cond = searchContext.getCondition(originalExpression, beanClass); if (cond == null) { return null; } cond.accept(visitor); return queryClass.cast(visitor.getQuery()); }
public <T, E> E getConvertedExpression(String originalExpression, Class<T> beanClass, Class<E> queryClass) { SearchConditionVisitor<T, E> visitor = getVisitor(); if (visitor == null) { return null; } SearchCondition<T> cond = searchContext.getCondition(originalExpression, beanClass); if (cond == null) { return null; } cond.accept(visitor); return queryClass.cast(visitor.getQuery()); }
@Override public <T, E> E getConvertedExpression(String originalExpression, Class<T> beanClass, Class<E> queryClass) { SearchConditionVisitor<T, E> visitor = getVisitor(); if (visitor == null) { return null; } SearchCondition<T> cond = searchContext.getCondition(originalExpression, beanClass); if (cond == null) { return null; } cond.accept(visitor); return queryClass.cast(visitor.getQuery()); }
@GET @Produces(MediaType.APPLICATION_JSON) public Collection<ScoreDoc> findBook(@Context SearchContext searchContext) throws IOException { IndexReader reader = DirectoryReader.open(directory); IndexSearcher searcher = new IndexSearcher(reader); try { visitor.visit(searchContext.getCondition(SearchBean.class)); return Arrays.asList(searcher.search(visitor.getQuery(), null, 1000).scoreDocs); } finally { reader.close(); } }
@GET @Path("/books/{search}/chapter/{chapter}") @Produces("application/xml") public Chapter getChapterFromSelectedBook(@Context SearchContext searchContext, @PathParam("search") String expression, @PathParam("chapter") int chapter) { SearchCondition<Book> sc = searchContext.getCondition(expression, Book.class); if (sc == null) { throw new WebApplicationException(404); } List<Book> found = sc.findAll(books.values()); if (found.size() != 1) { throw new WebApplicationException(404); } Book selectedBook = found.get(0); return selectedBook.getChapter(chapter); }
@GET @Path("/books/search") @Produces("application/xml") public Book getBook(@Context SearchContext searchContext) throws BookNotFoundFault { SearchCondition<Book> sc = searchContext.getCondition(Book.class); if (sc == null) { throw new BookNotFoundFault("Search exception"); } List<Book> found = sc.findAll(books.values()); if (found.size() != 1) { throw new BookNotFoundFault("Single book is expected"); } return found.get(0); }
protected SearchCond getSearchCond(final String fiql, final String realm) { try { SearchCondVisitor visitor = new SearchCondVisitor(); visitor.setRealm(realm); SearchCondition<SearchBean> sc = searchContext.getCondition(fiql, SearchBean.class); sc.accept(visitor); return visitor.getQuery(); } catch (Exception e) { LOG.error("Invalid FIQL expression: {}", fiql, e); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchExpression); sce.getElements().add(fiql); sce.getElements().add(ExceptionUtils.getRootCauseMessage(e)); throw sce; } }
throws UserNotFoundFault { SearchCondition<User> sc = searchContext.getCondition(query, User.class); if (sc == null) { throw new UserNotFoundFault("Search exception");