@Override
 @Transactional
 public void updatePart(PartModel partModel, String modelNumber) {
   log.debug("Update Part model: {}", partModel);
   if (partModel == null) {
     throw new IllegalArgumentException("Cannot update null Part");
   }
   try {
     Part part = bindPart(partModel);
     log.debug("Update part: part: {}", part);
     if (modelNumber != null) {
       try {
         HeliParts heliParts = null;
         Heli heli = entityManager.find(Heli.class, modelNumber);
         if (heli != null) {
           heliParts = heliPartsService.getHeliPart(modelNumber, part.getPartNumber());
           if (heliParts == null) {
             log.debug("Update part heli: {}", heli);
             log.debug("Update part helipart: {}", heliParts);
             heliPartsService.createHeliPart(heli, part);
           }
         }
       } catch (NoResultException e) {
         log.debug("Update part error: {}", e.getMessage());
       }
     }
     log.debug("Part updated in database: {}", part);
     entityManager.merge(part);
   } catch (Exception e) {
     throw new IllegalArgumentException(e.getMessage());
   }
 }
Пример #2
0
 public Result heliParts(String modelNumber) {
   List<PartModel> partModel = heliPartsService.getHelisParts(modelNumber);
   log.debug("Heli Parts: {}", partModel);
   return ok(parts.render("RC Helicopter Part Inventory", partModel));
 }