package de.hsadmin.mods.cust; import static javax.persistence.FetchType.EAGER; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.mods.user.UnixUser; @Entity(name = "CustomersTariffs") @Table(name = "billdata") public class CustomersTariff extends AbstractEntity implements Serializable { private static final long serialVersionUID = -3628577459027111705L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "billdata_id", columnDefinition = "integer") private long id; @JoinColumn(name = "bp_id", columnDefinition = "integer") @OneToOne(fetch = EAGER) private Customer customer; @Column(name = "tariff_domain_discount_since", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date domainDiscountSince; @Column(name = "tariff_domain_discount_until", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date domainDiscountUntil; @Column(name = "tariff_traffic_discount_since", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date trafficDiscountSince; @Column(name = "tariff_traffic_discount_until", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date trafficDiscountUntil; @Column(name = "tariff_quota_discount_since", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date quotaDiscountSince; @Column(name = "tariff_quota_discount_until", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date quotaDiscountUntil; @Column(name = "tariff_discount_since", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date discountSince; @Column(name = "tariff_discount_until", columnDefinition = "date") @Temporal(javax.persistence.TemporalType.DATE) private Date discountUntil; public CustomersTariff() { } public CustomersTariff(Customer cust) { this.customer = cust; } public static String createQueryFromStringKey(String humanKey) { return "customer.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 Date getDomainDiscountSince() { return domainDiscountSince; } public void setDomainDiscountSince(Date domainDiscountSince) { this.domainDiscountSince = domainDiscountSince; } public Date getDomainDiscountUntil() { return domainDiscountUntil; } public void setDomainDiscountUntil(Date domainDiscountUntil) { this.domainDiscountUntil = domainDiscountUntil; } public Date getTrafficDiscountSince() { return trafficDiscountSince; } public void setTrafficDiscountSince(Date trafficDiscountSince) { this.trafficDiscountSince = trafficDiscountSince; } public Date getTrafficDiscountUntil() { return trafficDiscountUntil; } public void setTrafficDiscountUntil(Date trafficDiscountUntil) { this.trafficDiscountUntil = trafficDiscountUntil; } public Date getQuotaDiscountSince() { return quotaDiscountSince; } public void setQuotaDiscountSince(Date quotaDiscountSince) { this.quotaDiscountSince = quotaDiscountSince; } public Date getQuotaDiscountUntil() { return quotaDiscountUntil; } public void setQuotaDiscountUntil(Date quotaDiscountUntil) { this.quotaDiscountUntil = quotaDiscountUntil; } public Date getDiscountSince() { return discountSince; } public void setDiscountSince(Date discountSince) { this.discountSince = discountSince; } public Date getDiscountUntil() { return discountUntil; } public void setDiscountUntil(Date discountUntil) { this.discountUntil = discountUntil; } @Override public boolean isNew() { return id == 0; } @Override public UnixUser owningUser(EntityManager em) { return customer.owningUser(em); } }