DomainOptions Model

This commit is contained in:
Peter Hormanns 2012-07-18 08:53:46 +00:00
parent 85a879fef5
commit 1f8add4413
3 changed files with 103 additions and 0 deletions

View File

@ -17,6 +17,7 @@
<class>de.hsadmin.mods.pac.INetAddress</class> <class>de.hsadmin.mods.pac.INetAddress</class>
<class>de.hsadmin.mods.user.UnixUser</class> <class>de.hsadmin.mods.user.UnixUser</class>
<class>de.hsadmin.mods.dom.Domain</class> <class>de.hsadmin.mods.dom.Domain</class>
<class>de.hsadmin.mods.dom.DomainOption</class>
<class>de.hsadmin.mods.email.EMailAddress</class> <class>de.hsadmin.mods.email.EMailAddress</class>
<class>de.hsadmin.mods.email.EMailAlias</class> <class>de.hsadmin.mods.email.EMailAlias</class>
<class>de.hsadmin.mods.db.DatabaseUser</class> <class>de.hsadmin.mods.db.DatabaseUser</class>

View File

@ -4,13 +4,16 @@ import static javax.persistence.FetchType.EAGER;
import static javax.persistence.GenerationType.SEQUENCE; import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Date; import java.util.Date;
import java.util.Set;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator; import javax.persistence.SequenceGenerator;
import javax.persistence.Table; import javax.persistence.Table;
@ -64,6 +67,9 @@ public class Domain extends AbstractEntity {
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)") @Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
private String dnsMaster; private String dnsMaster;
@ManyToMany(fetch=FetchType.EAGER, mappedBy="domains")
private Set<DomainOption> domainOptions;
public Domain() { public Domain() {
} }
@ -207,6 +213,14 @@ public class Domain extends AbstractEntity {
"obj.user=:loginUser"; "obj.user=:loginUser";
} }
public Set<DomainOption> getDomainOptions() {
return domainOptions;
}
public void setDomainOptions(Set<DomainOption> domainOptions) {
this.domainOptions = domainOptions;
}
public static enum Status { public static enum Status {
NONE(""), NONE(""),
ERROR("error"), ERROR("error"),

View File

@ -0,0 +1,88 @@
package de.hsadmin.mods.dom;
import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.mods.user.UnixUser;
@Table(name="domain_option")
@Entity(name="DomainOption")
@SequenceGenerator(name = "DomainOptionSeqGen", sequenceName = "domain_option_id_seq")
public class DomainOption extends AbstractEntity {
@Id
@Column(name = "domain_option_id", columnDefinition = "integer")
@GeneratedValue(strategy = SEQUENCE, generator = "DomainOptionSeqGen")
private long id;
@FieldValidation("[a-z0-9]+")
@Column(name = "domain_option_name", columnDefinition = "character varying(256)", nullable = false)
private String name;
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="domain__domain_option",
joinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")},
inverseJoinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")})
private Set<Domain> domains;
@Override
public long id() {
return getId();
}
@Override
public String createStringKey() {
return name;
}
@Override
public boolean isNew() {
return false;
}
@Override
public UnixUser owningUser(EntityManager em) {
// TODO Auto-generated method stub
return null;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Domain> getDomains() {
return domains;
}
public void setDomains(Set<Domain> domains) {
this.domains = domains;
}
}