Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 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);
     }
   }
 }
Пример #3
0
 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);
 }