/** * Sets attributes on the given Location. * * @param instance * @param attrs */ @PropertySetter("attributes") public static void setAttributes(Location instance, List<LocationAttribute> attrs) { for (LocationAttribute attr : attrs) { instance.addAttribute(attr); } }
la1a.setAttributeType(phoneAttrType); la1a.setValue("0123456789"); location1.addAttribute(la1a); LocationAttribute la1b = new LocationAttribute(); la1b.setAttributeType(emailAttrType); la1b.setValue("admin@facility.com"); location1.addAttribute(la1b); Context.getLocationService().saveLocation(location1); la2.setAttributeType(phoneAttrType); la2.setValue("0123456789"); location2.addAttribute(la2); Context.getLocationService().saveLocation(location2);
/** * @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; }