/** * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public NeedsPaging<DrugIngredient> doGetAll(Drug parent, RequestContext context) throws ResponseException { List<DrugIngredient> ingredients = new ArrayList<DrugIngredient>(); if (parent != null) { ingredients.addAll(parent.getIngredients()); } return new NeedsPaging<DrugIngredient>(ingredients, context); }
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); }
/** * @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())); }
@Test public void ensureGetAllReturnsAllTheAttributes() { RequestContext context = new RequestContext(); context.setLimit(100); context.setStartIndex(0); NeedsPaging<ProgramAttributeType> programAttributeTypes = getResource().doGetAll(context); assertEquals(2, programAttributeTypes.getPageOfResults().size()); assertEquals("d7477c21-bfc3-4922-9591-e89d8b9c8efb", programAttributeTypes.getPageOfResults().get(0).getUuid()); assertEquals("d7477c21-bfc3-4922-9591-e89d8b9c8efe", programAttributeTypes.getPageOfResults().get(1).getUuid()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(Object, * RequestContext) */ @Override public NeedsPaging<ConceptAttribute> doGetAll(Concept parent, RequestContext context) throws ResponseException { return new NeedsPaging<ConceptAttribute>((List<ConceptAttribute>) parent.getActiveAttributes(), context); }
@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); }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public NeedsPaging<PersonName> doGetAll(Person parent, RequestContext context) throws ResponseException { List<PersonName> names = new ArrayList<PersonName>(); if (parent != null) { names.addAll(parent.getNames()); } return new NeedsPaging<PersonName>(names, context); }
/** * @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 org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public NeedsPaging<ProviderAttribute> doGetAll(Provider parent, RequestContext context) throws ResponseException { return new NeedsPaging<ProviderAttribute>((List<ProviderAttribute>) parent.getActiveAttributes(), context); }
/** * @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")); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public NeedsPaging<LocationAttribute> doGetAll(Location parent, RequestContext context) throws ResponseException { return new NeedsPaging<LocationAttribute>((List<LocationAttribute>) parent.getActiveAttributes(), context); }
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);
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public PageableResult doGetAll(Concept parent, RequestContext context) throws ResponseException { List<ConceptMap> maps = new ArrayList<ConceptMap>(parent.getConceptMappings()); return new NeedsPaging<ConceptMap>(maps, context); }
@Override public PageableResult doGetAll(ProgramWorkflow parent, RequestContext context) throws ResponseException { List<ProgramWorkflowState> states = new ArrayList<ProgramWorkflowState>(); if (parent != null) { for (ProgramWorkflowState state : parent.getStates()) { states.add(state); } } return new NeedsPaging<ProgramWorkflowState>(states, context); }
@Override public PageableResult doGetAll(OrderSet parent, RequestContext context) throws ResponseException { List<OrderSetMember> orderSetMembers = new ArrayList<OrderSetMember>(); if (parent != null) { for (OrderSetMember orderSetMember : parent.getOrderSetMembers()) { orderSetMembers.add(orderSetMember); } } return new NeedsPaging<OrderSetMember>(orderSetMembers, context); } }
@Override public PageableResult doGetAll(PatientProgram parent, RequestContext context) throws ResponseException { return new NeedsPaging<PatientProgramAttribute>((List<PatientProgramAttribute>) parent.getActiveAttributes(), context); }
@Override public PageableResult doGetAll(Cohort parent, RequestContext context) throws ResponseException { return new NeedsPaging<CohortMembership>(new ArrayList<CohortMembership>(parent.getMemberships()), context); }
protected NeedsPaging<ConceptSource> doGetAll(RequestContext context, List<ConceptSource> sources) { if (context.getIncludeAll()) { return new NeedsPaging<ConceptSource>(sources, context); } List<ConceptSource> unretiredSources = new ArrayList<ConceptSource>(); for (ConceptSource conceptSource : sources) { if (!conceptSource.isRetired()) unretiredSources.add(conceptSource); } return new NeedsPaging<ConceptSource>(unretiredSources, context); }
@Override protected PageableResult doGetAll(RequestContext context) throws ResponseException { List<CustomDatatypeRepresentation> datatypes = getAllCustomDatatypes(); return new NeedsPaging<CustomDatatypeRepresentation>(datatypes, context); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public NeedsPaging<PersonAttribute> doGetAll(Person parent, RequestContext context) throws ResponseException { return new NeedsPaging<PersonAttribute>(parent.getActiveAttributes(), context); }