HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2013-05-02 3b61da9c17f4b403b455fd6ccdc35910ec14bb98
better mapping of paccomponent
4 files modified
82 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/pac/Pac.java 9 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacComponent.java 46 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacComponentId.java 24 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java 3 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/Pac.java
@@ -10,7 +10,6 @@
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
@@ -97,9 +96,11 @@
        pacComponents = new HashSet<PacComponent>();
        Date today = new Date();
        for (Component comp : basepac.getComponents()) {
            PacComponent pacComp = new PacComponent(basepac,
                    comp.getBaseComponent(), this, comp.getDefaultQuantity(),
                    today, null);
            PacComponent pacComp = new PacComponent();
            pacComp.setCreated(today);
            pacComp.setComponent(comp);
            pacComp.setPac(this);
            pacComp.setQuantity(comp.getDefaultQuantity());
            pacComponents.add(pacComp);
        }
    }
hsarback/src/de/hsadmin/mods/pac/PacComponent.java
@@ -8,6 +8,7 @@
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
@@ -27,13 +28,11 @@
    
    @Id
    @ManyToOne
    @JoinColumn(name = "basecomponent_id")
    private BaseComponent baseComponent;
    @Id
    @ManyToOne
    @JoinColumn(name = "basepacket_id")
    private BasePac basePac;
    @JoinColumns({
        @JoinColumn(name = "basecomponent_id"),
        @JoinColumn(name = "basepacket_id")
    })
    private Component component;
    @Column(name = "quantity", columnDefinition = "integer")
    private int quantity;
@@ -46,33 +45,12 @@
    @Temporal(TemporalType.DATE)
    private Date cancelled;
    public PacComponent() {
    }
    public PacComponent(BasePac basePac, BaseComponent baseComp, Pac pac,
            int quantity, Date created, Date cancelled) {
        this.basePac = basePac;
        this.pac = pac;
        this.baseComponent = baseComp;
        this.quantity = quantity;
        this.created = created;
        this.cancelled = cancelled;
    }
    public BasePac getBasePac() {
        return basePac;
    }
    public void setbasePac(BasePac basePac) {
        this.basePac = basePac;
        return getComponent().getBasePac();
    }
    public BaseComponent getBaseComponent() {
        return baseComponent;
    }
    public void setBaseComponent(BaseComponent baseComponent) {
        this.baseComponent = baseComponent;
        return getComponent().getBaseComponent();
    }
    public Pac getPac() {
@@ -107,4 +85,12 @@
        this.cancelled = cancelled;
    }
    public Component getComponent() {
        return component;
    }
    public void setComponent(Component component) {
        this.component = component;
    }
}
hsarback/src/de/hsadmin/mods/pac/PacComponentId.java
@@ -3,27 +3,25 @@
import java.io.Serializable;
public class PacComponentId implements Serializable {
    private static final long serialVersionUID = 1L;
    
    private long pac;
    private long basePac;
    private long baseComponent;
    private ComponentId component;
    
    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj instanceof PacComponentId) {
            PacComponentId other = (PacComponentId) obj;
            return getPac() == other.getPac() && getBaseComponent() == other.getBaseComponent() && getBasePac() == other.getBasePac();
            return getPac() == other.getPac() && getComponent().equals(other.getComponent());
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return (new Long(getPac() ^ getBaseComponent() ^ getBasePac() % Integer.MAX_VALUE)).intValue();
        return (new Long(getPac() ^ component.hashCode() % Integer.MAX_VALUE)).intValue();
    }
    public void setPac(long pacId) {
@@ -34,20 +32,12 @@
        return pac;
    }
    public void setBaseComponent(long baseComponentId) {
        this.baseComponent = baseComponentId;
    public ComponentId getComponent() {
        return component;
    }
    public long getBaseComponent() {
        return baseComponent;
    }
    public void setBasePac(long basePacId) {
        this.basePac = basePacId;
    }
    public long getBasePac() {
        return basePac;
    public void setComponent(ComponentId component) {
        this.component = component;
    }
}
hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
@@ -79,8 +79,7 @@
            Component comp = (Component) cObj;
            PacComponent pacComponent = new PacComponent();
            BaseComponent baseComponent = comp.getBaseComponent();
            pacComponent.setBaseComponent(baseComponent);
            pacComponent.setbasePac(comp.getBasePac());
            pacComponent.setComponent(comp);
            pacComponent.setCreated(now);
            pacComponent.setPac(pac);
            String feature = baseComponent.getFeature();