public ClusterVO getParent(Integer tenantId, ClusterVO cluster) { DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree = clusters.get(tenantId); // root has no parent if (tree.isRoot(cluster)) return null; return tree.getParent(cluster); }
public List<ClusterVO> getSiblings(Integer tenantId, ClusterVO cluster) { DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree = clusters.get(tenantId); if (tree.isRoot(cluster)) return null; //root has no siblings ClusterVO parent = tree.getParent(cluster); Collection<ClusterVO> sibl = tree.getChildren(parent); List<ClusterVO> siblings = new ArrayList<ClusterVO>(); for (ClusterVO clusterVO : sibl) { if (!clusterVO.equals(cluster)) siblings.add(clusterVO); } return siblings; }
/** * Returns <code>true</code> if <code>v</code> is neither a leaf nor the * root of this tree. * * @return <code>true</code> if <code>v</code> is neither a leaf nor the * root of this tree */ public boolean isInternal(V v) { if (!delegate.containsVertex(v)) { return false; } return isLeaf(v) == false && isRoot(v) == false; }
/** * @param v the vertex to test * @return <code>true</code> if <code>v</code> is neither * a leaf nor the root of this tree */ public boolean isInternal(V v) { if (!delegate.containsVertex(v)) return false; return isLeaf(v) == false && isRoot(v) == false; }
public void updateClusterDescription(Integer tenantId, String clusterName, String newDescription) throws ClusterException { ClusterVO cluster = loadCluster(tenantId, idMappingDAO.lookup(clusterName), itemTypeDAO.getIdOfType(tenantId, ClusterService.ITEMTYPE_CLUSTER)); DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree = clusters.get(tenantId); if (tree.isRoot(cluster)) throw new ClusterException("ROOT cluster description cannot be changed!"); cluster.setDescription(newDescription); storeCluster(cluster); }
public void renameCluster(Integer tenantId, String clusterName, String newName) throws ClusterException { ClusterVO cluster = loadCluster(tenantId, idMappingDAO.lookup(clusterName), itemTypeDAO.getIdOfType(tenantId, ClusterService.ITEMTYPE_CLUSTER)); DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree = clusters.get(tenantId); if (tree.isRoot(cluster)) throw new ClusterException("ROOT cluster cannot be renamed!"); ClusterVO parent = tree.getParent(cluster); ClusterVO newCluster = new ClusterVO(tenantId, idMappingDAO.lookup(newName), itemTypeDAO.getIdOfType(tenantId, ClusterService.ITEMTYPE_CLUSTER), newName, cluster.getDescription()); // add the new cluster addCluster(newCluster, parent); // move all children to the new cluster for (ClusterVO child : tree.getChildren(cluster)) { moveCluster(tenantId, child.getName(), newName); } if (logger.isDebugEnabled()) { logger.debug("removed all children: " + tree.isLeaf(cluster)); } // move all items to the new cluster for (ItemVO<Integer, Integer> item : getItemsOfCluster(cluster)) { addItemToCluster(newCluster, item); } // delete the old cluster removeCluster(tenantId, clusterName); }