| | |
| | | Pac newState = (Pac) entity; |
| | | EntityManager em = getTransaction().getEntityManager(); |
| | | Pac oldState = em.find(Pac.class, newState.getId()); |
| | | if (!oldState.getBasepac().getName().equals(newState.getBasepac().getName())) { |
| | | String oldBasepacName = oldState.getBasepac().getName(); |
| | | String newBasepacName = newState.getBasepac().getName(); |
| | | if (!oldBasepacName.equals(newBasepacName)) { |
| | | Set<PacComponent> oldPacComponents = oldState.getPacComponents(); |
| | | Map<String, Integer> oldQuantities = new HashMap<String, Integer>(); |
| | | for (PacComponent c : oldPacComponents) { |
| | |
| | | em.flush(); |
| | | newState.initPacComponents(em, newState.getBasepac()); |
| | | Set<PacComponent> newPacComponents = newState.getPacComponents(); |
| | | for (PacComponent c : newPacComponents) { |
| | | String feature = c.getBaseComponent().getFeature(); |
| | | c.setQuantity(oldQuantities.get(feature).intValue()); |
| | | for (PacComponent pc : newPacComponents) { |
| | | BaseComponent bc = pc.getBaseComponent(); |
| | | String feature = bc.getFeature(); |
| | | pc.setQuantity(oldQuantities.get(feature).intValue()); |
| | | } |
| | | } |
| | | return super.update(entity); |