/** * @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); }
/** * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return service.getLocationByUuid(RestTestConstants1_9.LOCATION_UUID).getActiveAttributes().size(); }
@Override public PageableResult search(String parentUuid, RequestContext context) throws ResponseException { String attributeType = context.getParameter("attributeType"); if (StringUtils.isBlank(attributeType) || StringUtils.isBlank(parentUuid)) { return new EmptySearchResult(); } Location parentLocation = Context.getLocationService().getLocationByUuid(parentUuid); List<LocationAttribute> results = new ArrayList<LocationAttribute>(); for (LocationAttribute activeAttribute : parentLocation.getActiveAttributes()) { if (activeAttribute.getAttributeType().getUuid().equals(attributeType)) { results.add(activeAttribute); } } return new AlreadyPaged<LocationAttribute>(context, results, false); } }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) */ @Override public LocationAttribute save(LocationAttribute delegate) { // make sure it has not already been added to the location boolean needToAdd = true; for (LocationAttribute pa : delegate.getLocation().getActiveAttributes()) { if (pa.equals(delegate)) { needToAdd = false; break; } } if (needToAdd) { delegate.getLocation().addAttribute(delegate); } Context.getLocationService().saveLocation(delegate.getLocation()); return delegate; }