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;
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) {
@ -139,9 +141,10 @@ public class PacModuleImpl extends AbstractModuleImpl {
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);