HSAdmin Backend Domains, E-Mail, Datenbanken
peter
2013-04-30 651a2f1c201c768d6c16d8a4bd43e57d3618e019
prepare
1 files modified
11 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java 11 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
@@ -127,7 +127,9 @@
        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 @@
            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);