/* jBilling - The Enterprise Open Source Billing System Copyright (C) 2003-2011 Enterprise jBilling Software Ltd. and Emiliano Conde This file is part of jbilling. jbilling is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. jbilling is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with jbilling. If not, see <http://www.gnu.org/licenses/>. */ package com.sapienter.jbilling.server.report.db; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import javax.persistence.Column; import javax.persistence.DiscriminatorColumn; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.TableGenerator; import javax.persistence.Transient; import java.io.Serializable; /** * ReportParameterDTO * * @author Brian Cowdery * @since 07/03/11 */ @Entity @Table(name = "report_parameter") @TableGenerator( name = "report_parameter_GEN", table = "jbilling_seqs", pkColumnName = "name", valueColumnName = "next_id", pkColumnValue = "report_parameter", allocationSize = 10 ) @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "dtype") public abstract class ReportParameterDTO<T> implements Serializable { private Integer id; private ReportDTO report; private String name; @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "report_parameter_GEN") @Column(name = "id", unique = true, nullable = false) public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "report_id", updatable = false, nullable = false) public ReportDTO getReport() { return report; } public void setReport(ReportDTO report) { this.report = report; } @Column(name = "name", updatable = true, nullable = false) public String getName() { return name; } public void setName(String name) { this.name = name; } /* Value bindings to be implemented by subclasses. This ensures that each "type" of parameter can get and set a value with an appropriate data type. */ @Transient abstract public T getValue(); abstract public void setValue(T value); @Override public String toString() { return "AbstractReportParameter{" + "id=" + id + ", name='" + name + '\'' + '}'; } }