/** * Make sure that purging a location removes the row from the database * * @see LocationService#purgeLocation(Location) */ @Test public void purgeLocation_shouldDeleteLocationSuccessfully() { LocationService ls = Context.getLocationService(); // fetch the encounter to delete from the db Location locationToDelete = ls.getLocation(4); ls.purgeLocation(locationToDelete); // try to refetch the location. should get a null object Location l = ls.getLocation(locationToDelete.getLocationId()); assertNull("We shouldn't find the location after deletion", l); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void purge(Location location, RequestContext context) throws ResponseException { if (location == null) return; Context.getLocationService().purgeLocation(location); }
@Override public void deleteFacility(String facilityId) { Location existingOpenMrsFacility = locationService.getLocation(Integer.parseInt(facilityId)); if (existingOpenMrsFacility != null) { locationService.purgeLocation(existingOpenMrsFacility); eventRelay.sendEventMessage(new MotechEvent(EventKeys.DELETED_FACILITY_SUBJECT, EventHelper.facilityParameters(convertLocationToFacility(existingOpenMrsFacility)))); } }