HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2011-03-23 39c0c3b8c2f86627832ca2725d07d359722a1604
Kann Pakete in HSDB anlegen
3 files modified
30 ■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/Pac.java 2 ●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacComponent.java 18 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java 10 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/Pac.java
@@ -39,7 +39,7 @@
    @Id
    @GeneratedValue(strategy = SEQUENCE, generator = "PacsSeqGen")
    @Column(name = "packet_id")
    @Column(name = "packet_id", columnDefinition = "integer")
    private long id;
    @Column(name = "packet_name", unique = true)
hsarback/src/de/hsadmin/mods/pac/PacComponent.java
@@ -58,8 +58,17 @@
    public PacComponent(BasePac basePac, BaseComponent baseComp, Pac pac,
            int quantity, Date created, Date cancelled) {
        this.basePac = basePac;
        if (basePac != null) {
            this.basePacId = basePac.id();
        }
        this.pac = pac;
        if (pac != null) {
            this.pacId = pac.id();
        }
        this.baseComponent = baseComp;
        if (baseComponent != null) {
            this.baseComponentId = baseComp.id();
        }
        this.quantity = quantity;
        this.created = created;
        this.cancelled = cancelled;
@@ -71,6 +80,9 @@
    public void setbasePac(BasePac basePac) {
        this.basePac = basePac;
        if (basePac != null) {
            this.basePacId = basePac.id();
        }
    }
    public BaseComponent getBaseComponent() {
@@ -79,6 +91,9 @@
    public void setBaseComponent(BaseComponent baseComponent) {
        this.baseComponent = baseComponent;
        if (baseComponent != null) {
            this.baseComponentId = baseComponent.id();
        }
    }
    public Pac getPac() {
@@ -87,6 +102,9 @@
    public void setPac(Pac pac) {
        this.pac = pac;
        if (pac != null) {
            this.pacId = pac.id();
        }
    }
    public int getQuantity() {
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
@@ -26,9 +26,10 @@
    @Override
    public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
        Date now = new Date();
        EntityManager em = getTransaction().getEntityManager();
        Pac pac = (Pac) newEntity;
        Date now = new Date();
        pac.setCreated(now);
        BasePac basepac = pac.getBasepac();
        if (basepac == null || basepac.getName() == null || basepac.getName().length() == 0) {
            throw new HSAdminException("basepac required");
@@ -38,8 +39,6 @@
        qBasepac.setParameter("valid", Boolean.TRUE);
        basepac = (BasePac) qBasepac.getSingleResult();
        pac.setBasepac(basepac);
        Query qComponents = em.createQuery("SELECT c FROM Components c WHERE c.basePacId = :basepac");
        qComponents.setParameter("basepac", basepac.id());
        INetAddress curINetAddr = pac.getCurINetAddr();
        if (curINetAddr == null || curINetAddr.getInetAddr() == null || curINetAddr.getInetAddr().length() == 0) {
            throw new HSAdminException("curinetaddr required");
@@ -63,7 +62,8 @@
        qHive.setParameter("name", hive.getName());
        hive = (Hive) qHive.getSingleResult();
        pac.setHive(hive);
//        em.persist(newEntity);
        Query qComponents = em.createQuery("SELECT c FROM Components c WHERE c.basePacId = :basepac");
        qComponents.setParameter("basepac", basepac.id());
        List<?> componentsList = qComponents.getResultList();
        Set<PacComponent> pacComponents = new HashSet<PacComponent>();
        for (Object cObj : componentsList) {
@@ -74,7 +74,7 @@
            pacComponent.setCreated(now);
            pacComponent.setPac(pac);
            pacComponent.setQuantity(comp.getDefaultQuantity());
//            em.persist(pacComponent);
            pacComponents.add(pacComponent);
        }
        pac.setPacComponents(pacComponents);
        return super.add(newEntity);