package de.hsadmin.mods.cust; import static javax.persistence.FetchType.EAGER; import static javax.persistence.GenerationType.SEQUENCE; import java.util.Date; import javax.persistence.EntityManager; import de.hsadmin.mods.user.UnixUser; @javax.persistence.Entity(name = "CustomersTariffs") @javax.persistence.Table(name = "billdata") @javax.persistence.SequenceGenerator(name = "CustomersTariffsSeqGen", sequenceName = "billdata_billdata_id_seq") public class CustomersTariff extends de.hsadmin.core.model.Entity implements java.io.Serializable { private static final long serialVersionUID = -3628577459027111705L; // / bean ctor public CustomersTariff() { } public CustomersTariff(Customer cust) { this.customer = cust; } // / {@inheritDoc} public static String createQueryFromStringKey(String humanKey) { return "customer.name = '" + humanKey + "'"; } // / {@inheritDoc} @Override public String createStringKey() { return getCustomer().getName(); } // / {@inheritDoc} @Override public long id() { return id; } // attribute id @javax.persistence.Id @javax.persistence.GeneratedValue(strategy = SEQUENCE, generator = "CustomersTariffsSeqGen") @javax.persistence.Column(name = "billdata_id", columnDefinition = "integer") private long id; public long getId() { return id; } public void setId(long id) { this.id = id; } // attribute customer @javax.persistence.JoinColumn(name = "bp_id", columnDefinition = "integer") @javax.persistence.OneToOne(fetch = EAGER) // TODO: das will ich gar nicht, geht aber nicht ohne?!? private Customer customer; public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } // attribute domainDiscountSince @javax.persistence.Column(name = "tariff_domain_discount_since", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date domainDiscountSince; public Date getDomainDiscountSince() { return domainDiscountSince; } public void setDomainDiscountSince(Date domainDiscountSince) { this.domainDiscountSince = domainDiscountSince; } // attribute domainDiscountUntil @javax.persistence.Column(name = "tariff_domain_discount_until", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date domainDiscountUntil; public Date getDomainDiscountUntil() { return domainDiscountUntil; } public void setDomainDiscountUntil(Date domainDiscountUntil) { this.domainDiscountUntil = domainDiscountUntil; } // attribute trafficDiscountSince @javax.persistence.Column(name = "tariff_traffic_discount_since", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date trafficDiscountSince; public Date getTrafficDiscountSince() { return trafficDiscountSince; } public void setTrafficDiscountSince(Date trafficDiscountSince) { this.trafficDiscountSince = trafficDiscountSince; } // attribute trafficDiscountUntil @javax.persistence.Column(name = "tariff_traffic_discount_until", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date trafficDiscountUntil; public Date getTrafficDiscountUntil() { return trafficDiscountUntil; } public void setTrafficDiscountUntil(Date trafficDiscountUntil) { this.trafficDiscountUntil = trafficDiscountUntil; } // attribute quotaDiscountSince @javax.persistence.Column(name = "tariff_quota_discount_since", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date quotaDiscountSince; public Date getQuotaDiscountSince() { return quotaDiscountSince; } public void setQuotaDiscountSince(Date quotaDiscountSince) { this.quotaDiscountSince = quotaDiscountSince; } // attribute quotaDiscountUntil @javax.persistence.Column(name = "tariff_quota_discount_until", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date quotaDiscountUntil; public Date getQuotaDiscountUntil() { return quotaDiscountUntil; } public void setQuotaDiscountUntil(Date quotaDiscountUntil) { this.quotaDiscountUntil = quotaDiscountUntil; } // attribute discountSince @javax.persistence.Column(name = "tariff_discount_since", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date discountSince; public Date getDiscountSince() { return discountSince; } public void setDiscountSince(Date discountSince) { this.discountSince = discountSince; } // attribute discountUntil @javax.persistence.Column(name = "tariff_discount_until", columnDefinition = "date") @javax.persistence.Temporal(javax.persistence.TemporalType.DATE) private Date discountUntil; public Date getDiscountUntil() { return discountUntil; } public void setDiscountUntil(Date discountUntil) { this.discountUntil = discountUntil; } // / {$inheritDoc} @Override public boolean isNew() { return id == 0; } // / {@inheritDoc} @Override public UnixUser owningUser(EntityManager em) { return customer.owningUser(em); } }