package de.hsadmin.mods.cust; import static javax.persistence.FetchType.EAGER; import java.io.Serializable; import javax.persistence.EntityManager; import javax.persistence.GenerationType; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.mods.user.UnixUser; @javax.persistence.Entity(name = "Contacts") @javax.persistence.Table(name = "contact") public class Contact extends AbstractEntity implements Serializable { private static final long serialVersionUID = 9119607911598098558L; @javax.persistence.Id @javax.persistence.GeneratedValue(strategy = GenerationType.IDENTITY) @javax.persistence.Column(name = "contact_id", columnDefinition = "integer") private long id; @javax.persistence.JoinColumn(name = "bp_id", columnDefinition = "integer") @javax.persistence.ManyToOne(fetch = EAGER) private Customer customer; @javax.persistence.Column(name = "salut", columnDefinition = "character varying(30)") private String salut; @javax.persistence.Column(name = "first_name", columnDefinition = "character varying(40)") private String firstName; @javax.persistence.Column(name = "last_name", columnDefinition = "character varying(40)") private String lastName; @javax.persistence.Column(name = "title", columnDefinition = "character varying(20)") private String title; @javax.persistence.Column(name = "firma", columnDefinition = "character varying(120)") private String firma; @javax.persistence.Column(name = "co", columnDefinition = "character varying(50)") private String co; @javax.persistence.Column(name = "street", columnDefinition = "character varying(50)") private String street; @javax.persistence.Column(name = "zipcode", columnDefinition = "character varying(10)") private String zipCode; @javax.persistence.Column(name = "city", columnDefinition = "character varying(40)") private String city; @javax.persistence.Column(name = "country", columnDefinition = "character varying(30)") private String country; @javax.persistence.Column(name = "phone_private", columnDefinition = "character varying(30)") private String phonePrivate; @javax.persistence.Column(name = "phone_office", columnDefinition = "character varying(30)") private String phoneOffice; @javax.persistence.Column(name = "phone_mobile", columnDefinition = "character varying(30)") private String phoneMobile; @javax.persistence.Column(name = "fax", columnDefinition = "character varying(30)") private String fax; @javax.persistence.Column(name = "email", columnDefinition = "character varying(50)") private String email; public Contact() { } public Contact(Customer cust) { this.customer = cust; } public Contact(Customer cust, String salut, String title, String firstName, String lastName, String firma, String co, String street, String zipCode, String city, String country, String phonePrivate, String phoneOffice, String phoneMobile, String fax, String email) { this.customer = cust; this.salut = salut; this.title = title; this.firstName = firstName; this.lastName = lastName; this.firma = firma; this.co = co; this.street = street; this.zipCode = zipCode; this.city = city; this.country = country; this.phonePrivate = phonePrivate; this.phoneOffice = phoneOffice; this.phoneMobile = phoneMobile; this.fax = fax; this.email = email; } public static String createQueryFromStringKey(String humanKey) { return "name='" + humanKey + "'"; } @Override public String createStringKey() { return getCustomer().getName(); } @Override public long id() { return id; } public long getId() { return id; } public void setId(long id) { this.id = id; } public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } public String getSalut() { return salut; } public void setSalut(String salut) { this.salut = salut; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getFirma() { return firma; } public void setFirma(String firma) { this.firma = firma; } public String getCo() { return co; } public void setCo(String co) { this.co = co; } public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getZipCode() { return zipCode; } public void setZipCode(String zipCode) { this.zipCode = zipCode; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public String getPhonePrivate() { return phonePrivate; } public void setPhonePrivate(String phonePrivate) { this.phonePrivate = phonePrivate; } public String getPhoneOffice() { return phoneOffice; } public void setPhoneOffice(String phoneOffice) { this.phoneOffice = phoneOffice; } public String getPhoneMobile() { return phoneMobile; } public void setPhoneMobile(String phoneMobile) { this.phoneMobile = phoneMobile; } public String getFax() { return fax; } public void setFax(String fax) { this.fax = fax; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Override public boolean isNew() { return id == 0; } @Override public UnixUser owningUser(EntityManager em) { return null; // TODO: no access yet } }