@Override public void addChild(Location parent, Location newChild) { if (this.manager != null) { parent.getChildLocations().add(newChild); newChild.setParentLocation(parent); manager.persistLocation(newChild); } }
@Override public boolean removeChild(Location child) { if (child.getParentLocation() != null && manager != null) { child.getParentLocation().getChildLocations().remove(child); child.setParentLocation(null); manager.cascadeDeleteLocation(child.getId()); return true; } return false; }
/** 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; }