2010-10-01 21:52:51 +02:00
|
|
|
package de.hsadmin.mods.pac;
|
|
|
|
|
|
|
|
import static javax.persistence.CascadeType.ALL;
|
|
|
|
import static javax.persistence.GenerationType.SEQUENCE;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2010-10-06 15:06:01 +02:00
|
|
|
import javax.persistence.Column;
|
|
|
|
import javax.persistence.Entity;
|
2012-04-05 15:24:05 +02:00
|
|
|
import javax.persistence.FetchType;
|
2010-10-06 15:06:01 +02:00
|
|
|
import javax.persistence.GeneratedValue;
|
|
|
|
import javax.persistence.Id;
|
|
|
|
import javax.persistence.OneToMany;
|
|
|
|
import javax.persistence.SequenceGenerator;
|
|
|
|
import javax.persistence.Table;
|
|
|
|
|
|
|
|
@Entity(name = "BasePacs")
|
|
|
|
@Table(name = "basepacket")
|
|
|
|
@SequenceGenerator(name = "BasePacsSeqGen", sequenceName = "basepacket_basepacket_id_seq")
|
2010-10-01 21:52:51 +02:00
|
|
|
public class BasePac implements Serializable {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1491121619195513435L;
|
|
|
|
|
|
|
|
public BasePac() {
|
2013-02-20 17:24:23 +01:00
|
|
|
components = new HashSet<Component>();
|
2010-10-01 21:52:51 +02:00
|
|
|
}
|
|
|
|
|
2010-10-06 15:06:01 +02:00
|
|
|
@Id
|
|
|
|
@GeneratedValue(strategy = SEQUENCE, generator = "BasePacsSeqGen")
|
|
|
|
@Column(name = "basepacket_id", columnDefinition = "integer")
|
2011-03-22 23:02:06 +01:00
|
|
|
private long basePacId;
|
2010-10-01 21:52:51 +02:00
|
|
|
|
2010-10-06 15:06:01 +02:00
|
|
|
@Column(name = "basepacket_code", columnDefinition = "character varying(10)")
|
2010-10-01 21:52:51 +02:00
|
|
|
private String name;
|
|
|
|
|
2010-10-06 15:06:01 +02:00
|
|
|
@Column(name = "description", columnDefinition = "character varying(100)")
|
2010-10-01 21:52:51 +02:00
|
|
|
private String description;
|
|
|
|
|
2013-04-18 11:57:16 +02:00
|
|
|
@Column(name = "article_number", columnDefinition = "integer", nullable=false)
|
|
|
|
private int articleNumber;
|
|
|
|
|
2010-10-06 15:06:01 +02:00
|
|
|
@Column(name = "sorting", columnDefinition = "integer")
|
2010-10-01 21:52:51 +02:00
|
|
|
private int sorting;
|
|
|
|
|
2010-10-06 15:06:01 +02:00
|
|
|
@Column(name = "valid", columnDefinition = "boolean")
|
2010-10-01 21:52:51 +02:00
|
|
|
private boolean valid;
|
|
|
|
|
2013-05-02 17:10:45 +02:00
|
|
|
@OneToMany(fetch = FetchType.LAZY, cascade=ALL, mappedBy="basePac")
|
2010-10-01 21:52:51 +02:00
|
|
|
private Set<Component> components;
|
|
|
|
|
2011-03-22 23:02:06 +01:00
|
|
|
public long id() {
|
|
|
|
return basePacId;
|
2010-10-01 21:52:51 +02:00
|
|
|
}
|
|
|
|
|
2011-03-22 23:02:06 +01:00
|
|
|
public long getBasePacId() {
|
|
|
|
return basePacId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBasePacId(long id) {
|
|
|
|
this.basePacId = id;
|
2010-10-01 21:52:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescription(String description) {
|
|
|
|
this.description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSorting() {
|
|
|
|
return sorting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSorting(int sorting) {
|
|
|
|
this.sorting = sorting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isValid() {
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setValid(boolean valid) {
|
|
|
|
this.valid = valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Component> getComponents() {
|
|
|
|
return components != null ? components
|
|
|
|
: (components = new HashSet<Component>());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setComponents(Set<Component> components) {
|
|
|
|
this.components = components;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Component getComponent(String feature) {
|
|
|
|
for (Component comp : getComponents())
|
|
|
|
if (feature.equals(comp.getBaseComponent().getFeature()))
|
|
|
|
return comp;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addComponent(Component comp) {
|
|
|
|
getComponents().add(comp);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeComponent(Component comp) {
|
|
|
|
getComponents().remove(comp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// generic
|
|
|
|
public boolean equals(Object aOther) {
|
|
|
|
if (aOther == null || aOther.getClass() != getClass())
|
|
|
|
return false;
|
|
|
|
BasePac aOtherBP = (BasePac) aOther;
|
2011-03-22 23:02:06 +01:00
|
|
|
if (basePacId != aOtherBP.basePacId)
|
2010-10-01 21:52:51 +02:00
|
|
|
return false;
|
|
|
|
if (name != null && !name.equals(aOtherBP.name))
|
|
|
|
return false;
|
|
|
|
if (description != null && description.equals(aOtherBP.description))
|
|
|
|
return false;
|
|
|
|
if (sorting != aOtherBP.sorting)
|
|
|
|
return false;
|
|
|
|
if (valid != aOtherBP.valid)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
2013-04-18 11:57:16 +02:00
|
|
|
|
|
|
|
public int getArticleNumber() {
|
|
|
|
return articleNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setArticleNumber(int articleNumber) {
|
|
|
|
this.articleNumber = articleNumber;
|
|
|
|
}
|
2013-04-25 12:08:39 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "BasePac \"" + getName() + "\"";
|
|
|
|
}
|
2010-10-01 21:52:51 +02:00
|
|
|
}
|