private void addToMap( ContainerDTO containerDTO, TreeMap<Integer, Set<ProductGroup>> parentToChild) { ProductGroup productGroup = new ProductGroup().productGroupConverter(containerDTO); if (parentToChild.containsKey(containerDTO.getContainerId())) { parentToChild.get(containerDTO.getContainerId()).add(productGroup); } else { Set<ProductGroup> productGroups = new TreeSet<ProductGroup>(); productGroups.add(productGroup); parentToChild.put(containerDTO.getContainerId(), productGroups); } idToContainer.put(productGroup.getId(), productGroup); }
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); }