From 651a2f1c201c768d6c16d8a4bd43e57d3618e019 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 30 Apr 2013 22:12:52 +0200 Subject: [PATCH] prepare --- hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java index f5dfa12..f957e6d 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java @@ -127,7 +127,9 @@ public class PacModuleImpl extends AbstractModuleImpl { 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 oldPacComponents = oldState.getPacComponents(); Map oldQuantities = new HashMap(); for (PacComponent c : oldPacComponents) { @@ -139,9 +141,10 @@ public class PacModuleImpl extends AbstractModuleImpl { em.flush(); newState.initPacComponents(em, newState.getBasepac()); Set 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);