Exemple #1
0
 private void checkNoCodeRepeatedAtNewMaterials(
         final List<MaterialCategory> categories) throws ValidationException {
     List<Material> allMaterials = MaterialCategory
             .getAllMaterialsWithoutAutogeneratedCodeFrom(categories);
     Map<String, Material> byCode = new HashMap<String, Material>();
     for (Material each : allMaterials) {
         if (byCode.containsKey(each.getCode())) {
             throw new ValidationException(sameCodeMessage(each, byCode
                     .get(each.getCode())));
         }
         byCode.put(each.getCode(), each);
     }
 }
Exemple #2
0
 private void storeOldCodes(MaterialCategory materialCategory) {
     // it stores temporaly the autogenerated code.
     if (materialCategory.isCodeAutogenerated()) {
         oldCodes.put(materialCategory, materialCategory.getCode());
         for (Material child : materialCategory.getMaterials()) {
             oldMaterialCodes.put(child, child.getCode());
         }
     }
 }
Exemple #3
0
 private String asStringForUser(Material material) {
     return String.format("{code: %s, description: %s}", material.getCode(),
             material
             .getDescription());
 }