private SimpleObject getVisits(RequestContext context, String patientParameter, String includeInactiveParameter, Date minStartDate, String locationParameter) { Collection<Patient> patients = patientParameter == null ? null : Arrays.asList(getPatient(patientParameter)); Collection<Location> locations = locationParameter == null ? null : Arrays.asList(getLocation(locationParameter)); boolean includeInactive = includeInactiveParameter == null ? true : Boolean.parseBoolean(includeInactiveParameter); return new NeedsPaging<Visit>(Context.getVisitService().getVisits(null, patients, locations, null, minStartDate, null, null, null, null, includeInactive, context.getIncludeAll()), context).toSimpleObject(this); }
@Override public SimpleObject search(RequestContext context) throws ResponseException { String query = context.getParameter("q"); List<ConceptClass> conceptClasses = null; String[] classUuids = context.getRequest().getParameterValues("conceptClasses"); if (classUuids != null) { for (String uuid : classUuids) { if (conceptClasses == null) { conceptClasses = new ArrayList<ConceptClass>(); } ConceptClass cc = (ConceptClass) ConversionUtil.convert(uuid, ConceptClass.class); if (cc != null) { conceptClasses.add(cc); } } } List<Locale> locales = new ArrayList<Locale>(); locales.add(Context.getLocale()); return new NeedsPaging<ConceptSearchResult>(Context.getConceptService().getConcepts(query, locales, context.getIncludeAll(), conceptClasses, null, null, null, null, context.getStartIndex(), context.getLimit()), context).toSimpleObject(this); }
context).toSimpleObject(this);
/** * @see BasePageableResult#toSimpleObject(Converter) * @verifies add property totalCount if context contains parameter totalCount which is true */ @Test public void toSimpleObject_shouldAddPropertyTotalCountIfContextContainsParameterTotalCountWhichIsTrue() throws Exception { request.addParameter("totalCount", "true"); NeedsPaging<Order> needsPaging = new NeedsPaging<Order>(orders, context); SimpleObject result = needsPaging.toSimpleObject(converter); assertTrue(result.containsKey("totalCount")); assertThat((Long) result.get("totalCount"), is((long) orders.size())); assertThat(needsPaging.getTotalCount(), is((long) orders.size())); }
/** * @see BasePageableResult#toSimpleObject(Converter) * @verifies not add property totalCount if context does not contains parameter totalCount */ @Test public void toSimpleObject_shouldNotAddPropertyTotalCountIfContextDoesNotContainsParameterTotalCount() throws Exception { NeedsPaging<Order> needsPaging = new NeedsPaging<Order>(orders, context); SimpleObject result = needsPaging.toSimpleObject(converter); assertFalse(result.containsKey("totalCount")); } }
/** * @see BasePageableResult#toSimpleObject(Converter) * @verifies not add property totalCount if context contains parameter totalCount which is false */ @Test public void toSimpleObject_shouldNotAddPropertyTotalCountIfContextContainsParameterTotalCountWhichIsFalse() throws Exception { request.addParameter("totalCount", "false"); NeedsPaging<Order> needsPaging = new NeedsPaging<Order>(orders, context); SimpleObject result = needsPaging.toSimpleObject(converter); assertFalse(result.containsKey("totalCount")); }