/** * Finds and invokes a search method whose name is given by searchMethod and whose signature * includes one String, two Integers, and any number of boolean or Booleans * * @param service * @param query * @param context * @return */ private List<T> doPagedSearch(OpenmrsService service, String query, RequestContext context) { try { for (Method candidate : serviceClass.getMethods()) { if (candidate.getName().equals(searchMethod) && hasRightParameterTypes(candidate, 1, 2)) return invokePagedSearchMethod(service, candidate, query, context); } } catch (Exception ex) { throw new RuntimeException(searchMethod + " failed", ex); } throw new RuntimeException("Cannot find suitable method"); }
/** * Finds and invokes a count method whose name is given by countMethod and whose signature * includes one String, and any number of boolean or Booleans * * @param service * @param query * @param context * @return */ private int doCount(OpenmrsService service, String query, RequestContext context) { try { for (Method candidate : serviceClass.getMethods()) { if (candidate.getName().equals(countMethod) && hasRightParameterTypes(candidate, 1, 0)) { return invokeCountMethod(service, candidate, query, context); } } } catch (Exception ex) { throw new RuntimeException(countMethod + " failed", ex); } throw new RuntimeException("Cannot find suitable method"); }