HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2012-07-18 1f8add441383e17daae8b99ca86ebb242e16a67f
DomainOptions Model
2 files modified
1 files added
103 ■■■■■ changed files
hsarback/conf/META-INF/persistence.xml 1 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/Domain.java 14 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainOption.java 88 ●●●●● patch | view | raw | blame | history
hsarback/conf/META-INF/persistence.xml
@@ -17,6 +17,7 @@
        <class>de.hsadmin.mods.pac.INetAddress</class>
        <class>de.hsadmin.mods.user.UnixUser</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.EMailAlias</class> 
        <class>de.hsadmin.mods.db.DatabaseUser</class> 
hsarback/src/de/hsadmin/mods/dom/Domain.java
@@ -4,13 +4,16 @@
import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Date;
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.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@@ -64,6 +67,9 @@
    @Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
    private String dnsMaster;
    @ManyToMany(fetch=FetchType.EAGER, mappedBy="domains")
    private Set<DomainOption> domainOptions;
    public Domain() {
    }
@@ -207,6 +213,14 @@
            "obj.user=:loginUser";
    }
    public Set<DomainOption> getDomainOptions() {
        return domainOptions;
    }
    public void setDomainOptions(Set<DomainOption> domainOptions) {
        this.domainOptions = domainOptions;
    }
    public static enum Status {
        NONE(""), 
        ERROR("error"), 
hsarback/src/de/hsadmin/mods/dom/DomainOption.java
New 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;
    }
}