Example #1
0
 public void removeLocation() {
   while (hasChildren()) {
     for (Location child : children) {
       child.removeLocation();
       child = null;
     }
   }
   if (parent != null) {
     parent.children.remove(this);
     if (parent.children.isEmpty()) {
       parent.children = null;
     }
     parent = null;
   }
 }
Example #2
0
 public void updateLocation(Location newLoc) {
   Location loc = findLocationById(newLoc.getId());
   if (loc != null) {
     if (loc.parent != null) {
       loc.parent.children.remove(loc);
       loc.parent.children.add(newLoc);
     }
     if (loc.children != null) {
       for (Location child : children) {
         child.parent = newLoc;
       }
     }
     newLoc.parent = loc.parent;
     newLoc.children = loc.children;
   }
 }