/** * Compares storage name with Set<StorageUnit> for uniqueness. * * @pre container != null * @param container * @return boolean true if container.name == Unique, otherwise false. */ private boolean isUniqueStorageUnitName(Container container) { assert container != null; for (StorageUnit storageUnit : storageUnits) { if (container.getName().equals(storageUnit.getName())) { return false; } } return true; }
private void setProductGroups( TreeMap<Integer, Set<ProductGroup>> parentToChild, Set<ProductGroup> containers) { if (containers == null) { for (StorageUnit storageUnit : storageUnits) { Set<ProductGroup> children = parentToChild.get(storageUnit.getId()); setChildren(parentToChild, children, storageUnit); } } else { for (Container container : containers) { Set<ProductGroup> children = parentToChild.get(container.getId()); setChildren(parentToChild, children, container); } } }
public void load() { Collection<ContainerDTO> productContainers = containerDAO.readAll(); TreeMap<Integer, Set<ProductGroup>> parentToChild = new TreeMap<Integer, Set<ProductGroup>>(); for (ContainerDTO containerDTO : productContainers) { if (containerDTO.getContainerId() == -1) { StorageUnit storageUnit = new StorageUnit().storageUnitConverter(containerDTO); storageUnits.add(storageUnit); idToContainer.put(storageUnit.getId(), storageUnit); } else { addToMap(containerDTO, parentToChild); } } setProductGroups(parentToChild, null); }