/** * @see org.openmrs.api.LocationService#unretireLocationAttributeType(org.openmrs.LocationAttributeType) */ @Override public LocationAttributeType unretireLocationAttributeType(LocationAttributeType locationAttributeType) { return Context.getLocationService().saveLocationAttributeType(locationAttributeType); }
/** * @see LocationService#getLocations(String, org.openmrs.Location, java.util.Map, boolean, Integer, Integer) */ @Test public void getLocations_shouldNotFindAnyLocationsIfNoneHaveGivenAttributeValues() { // Save new phone number attribute type LocationAttributeType phoneAttrType = new LocationAttributeType(); phoneAttrType.setName("Facility Phone"); phoneAttrType.setMinOccurs(0); phoneAttrType.setMaxOccurs(1); phoneAttrType.setDatatypeClassname("org.openmrs.customdatatype.datatype.FreeTextDatatype"); Context.getLocationService().saveLocationAttributeType(phoneAttrType); Map<LocationAttributeType, Object> attrValues = new HashMap<>(); attrValues.put(phoneAttrType, "xxxxxx"); Assert.assertEquals(0, Context.getLocationService().getLocations(null, null, attrValues, true, null, null).size()); }
/** * @see LocationService#saveLocationAttributeType(LocationAttributeType) */ @Test public void saveLocationAttributeType_shouldCreateANewLocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertEquals(2, Context.getLocationService().getAllLocationAttributeTypes().size()); LocationAttributeType lat = new LocationAttributeType(); lat.setName("Another one"); lat.setDatatypeClassname(FreeTextDatatype.class.getName()); Context.getLocationService().saveLocationAttributeType(lat); Assert.assertNotNull(lat.getId()); Assert.assertEquals(3, Context.getLocationService().getAllLocationAttributeTypes().size()); }
/** * @see LocationService#saveLocationAttributeType(LocationAttributeType) */ @Test public void saveLocationAttributeType_shouldEditAnExistingLocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); LocationService service = Context.getLocationService(); Assert.assertEquals(2, service.getAllLocationAttributeTypes().size()); LocationAttributeType lat = service.getLocationAttributeType(1); lat.setName("A new name"); service.saveLocationAttributeType(lat); Assert.assertEquals(2, service.getAllLocationAttributeTypes().size()); Assert.assertEquals("A new name", service.getLocationAttributeType(1).getName()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) */ @Override public LocationAttributeType save(LocationAttributeType delegate) { return service().saveLocationAttributeType(delegate); }
phoneAttrType.setMaxOccurs(1); phoneAttrType.setDatatypeClassname("org.openmrs.customdatatype.datatype.FreeTextDatatype"); Context.getLocationService().saveLocationAttributeType(phoneAttrType); emailAttrType.setMaxOccurs(1); emailAttrType.setDatatypeClassname("org.openmrs.customdatatype.datatype.FreeTextDatatype"); Context.getLocationService().saveLocationAttributeType(emailAttrType);