This commit is contained in:
peter 2013-04-30 22:12:52 +02:00
parent 14645dc911
commit 651a2f1c20

View File

@ -127,7 +127,9 @@ public class PacModuleImpl extends AbstractModuleImpl {
Pac newState = (Pac) entity; Pac newState = (Pac) entity;
EntityManager em = getTransaction().getEntityManager(); EntityManager em = getTransaction().getEntityManager();
Pac oldState = em.find(Pac.class, newState.getId()); 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(); Set<PacComponent> oldPacComponents = oldState.getPacComponents();
Map<String, Integer> oldQuantities = new HashMap<String, Integer>(); Map<String, Integer> oldQuantities = new HashMap<String, Integer>();
for (PacComponent c : oldPacComponents) { for (PacComponent c : oldPacComponents) {
@ -139,9 +141,10 @@ public class PacModuleImpl extends AbstractModuleImpl {
em.flush(); em.flush();
newState.initPacComponents(em, newState.getBasepac()); newState.initPacComponents(em, newState.getBasepac());
Set<PacComponent> newPacComponents = newState.getPacComponents(); Set<PacComponent> newPacComponents = newState.getPacComponents();
for (PacComponent c : newPacComponents) { for (PacComponent pc : newPacComponents) {
String feature = c.getBaseComponent().getFeature(); BaseComponent bc = pc.getBaseComponent();
c.setQuantity(oldQuantities.get(feature).intValue()); String feature = bc.getFeature();
pc.setQuantity(oldQuantities.get(feature).intValue());
} }
} }
return super.update(entity); return super.update(entity);