/** Gets a Location entity by its exact name. */ public static Location getLocationByName(String locationName, Location parent) { LocationService locationService = Context.getLocationService(); Location location = locationService.getLocation(locationName); if (location == null) { location = new Location(); location.setName(locationName); location.setDescription(locationName); if (parent != null) { location.setParentLocation(parent); } locationService.saveLocation(location); } return location; }