HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2013-05-14 266756b2680fb0beadc21950c4b91fde8d8837cf
migration of pacs is working
3 files modified
45 ■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java 37 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/CustomerTest.java 2 ●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/PacTest.java 6 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
@@ -136,16 +136,34 @@
        String oldBasepacName = oldState.getBasepac().getName();
        BasePac newBasepac = newState.getBasepac();
        String newBasepacName = newBasepac.getName();
        if (!oldBasepacName.equals(newBasepacName)) {
            Set<PacComponent> oldPacComponents = oldState.getPacComponents();
            Map<String, Integer> oldQuantities = new HashMap<String, Integer>();
            for (PacComponent c : oldPacComponents) {
                String feature = c.getBaseComponent().getFeature();
                int quantity = c.getQuantity();
                oldQuantities.put(feature, new Integer(quantity));
                em.remove(c);
        Set<PacComponent> oldPacComponents = oldState.getPacComponents();
        Map<String, Integer> oldQuantities = new HashMap<String, Integer>();
        for (PacComponent c : oldPacComponents) {
            String feature = c.getBaseComponent().getFeature();
            int quantity = c.getQuantity();
            oldQuantities.put(feature, new Integer(quantity));
            em.remove(c);
        }
        oldPacComponents.clear();
        em.flush();
        if (oldBasepacName.equals(newBasepacName)) {
            Set<PacComponent> newPacComponents = newState.getPacComponents();
            for (PacComponent pc : newPacComponents) {
                BaseComponent bc = pc.getBaseComponent();
                String feature = bc.getFeature();
                int quantity = pc.getQuantity();
                if (quantity < 0) {
                    quantity = oldQuantities.get(feature).intValue();
                    pc.setQuantity(quantity);
                }
                int increment = newBasepac.getComponent(feature).getIncrementQuantity();
                if (quantity % increment != 0) {
                    throw new AuthorisationException(loginUser, "update", entity, feature + "=" + quantity);
                }
                em.persist(pc);
            }
            oldPacComponents.clear();
        }
        else {
            newState.getPacComponents().clear();
            em.flush();
            newState.setBasepac(newBasepac);
@@ -161,6 +179,7 @@
                    quantity = increment * numOfIncrements + increment;
                }
                pc.setQuantity(quantity);
                em.persist(pc);
            }
        }
        em.flush();
hsarback/test/de/hsadmin/remote/CustomerTest.java
@@ -216,7 +216,7 @@
        }
    }
    @Test
//    @Test
    public void testDeleteAsHostmaster() {
        String user = "ad";
        int membersCount = -9999;
hsarback/test/de/hsadmin/remote/PacTest.java
@@ -109,7 +109,7 @@
        String user = "ad";
        String grantingTicketURL = cas.getGrantingTicketURL(user);
        Map<String, String> componentsMap = new HashMap<String,String>();
        componentsMap.put("QUOTA", "640");
        componentsMap.put("QUOTA", "4096");
        Map<String, Object> setParams = new HashMap<String,Object>();
        Map<String, Object> whereParams = new HashMap<String,Object>();
        setParams.put("components", componentsMap);
@@ -136,8 +136,8 @@
            assertTrue(compMapObj instanceof Map<?,?>);
            @SuppressWarnings("unchecked")
            Map<String,String> compMap = (Map<String, String>) compMapObj;
            assertEquals("640", compMap.get("QUOTA"));
            assertEquals("2", compMap.get("TRAFFIC"));
            assertEquals("4096", compMap.get("QUOTA"));
            assertEquals("5", compMap.get("TRAFFIC"));
            assertEquals("1", compMap.get("MULTI"));
        } catch (XmlRpcException e) {
            fail(e.getMessage());