Ejemplo n.º 1
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Location other = (Location) obj;
   if (getId() == null) {
     if (other.getId() != null) return false;
   } else if (!getId().equals(other.getId())) return false;
   return true;
 }
Ejemplo n.º 2
0
 private void buildTree(Location root, TreeNode attach) {
   if (root != null && root.getChildren() != null) {
     for (Location child : root.getChildren()) {
       TreeNode node = new DefaultTreeNode(child, attach);
       if (logger.isDebugEnabled()) {
         logger.debug(String.format("Tree node created to bind %s with %s", root, attach));
       }
       buildTree(child, node);
     }
   }
 }
Ejemplo n.º 3
0
 public Location findLocationById(Long id) {
   if (this.getId() != null && this.getId().equals(id)) {
     return this;
   }
   if (hasChildren()) {
     for (Location child : children) {
       Location found = child.findLocationById(id);
       if (found != null) {
         return found;
       }
     }
   }
   return null;
 }
Ejemplo n.º 4
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;
   }
 }
Ejemplo n.º 5
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;
   }
 }