/src/classes/com/sapienter/jbilling/server/report/db/ReportDTO.java

https://github.com/othmanelmoulat/jbilling-2.2-Extentions · Java · 211 lines · 158 code · 34 blank · 19 comment · 0 complexity · a0a13f532e23f4e744a35615ee0a7989 MD5 · raw file

  1. /*
  2. jBilling - The Enterprise Open Source Billing System
  3. Copyright (C) 2003-2009 Enterprise jBilling Software Ltd. and Emiliano Conde
  4. This file is part of jbilling.
  5. jbilling is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Affero General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. jbilling is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Affero General Public License for more details.
  13. You should have received a copy of the GNU Affero General Public License
  14. along with jbilling. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. package com.sapienter.jbilling.server.report.db;
  17. import java.io.Serializable;
  18. import java.util.HashSet;
  19. import java.util.Set;
  20. import javax.persistence.CascadeType;
  21. import javax.persistence.Column;
  22. import javax.persistence.Entity;
  23. import javax.persistence.FetchType;
  24. import javax.persistence.GeneratedValue;
  25. import javax.persistence.GenerationType;
  26. import javax.persistence.Id;
  27. import javax.persistence.JoinColumn;
  28. import javax.persistence.JoinTable;
  29. import javax.persistence.ManyToMany;
  30. import javax.persistence.OneToMany;
  31. import javax.persistence.Table;
  32. import javax.persistence.TableGenerator;
  33. import javax.persistence.Version;
  34. import org.hibernate.annotations.OrderBy;
  35. import com.sapienter.jbilling.server.user.db.CompanyDTO;
  36. @Entity
  37. @TableGenerator(
  38. name = "report_GEN",
  39. table = "jbilling_seqs",
  40. pkColumnName = "name",
  41. valueColumnName = "next_id",
  42. pkColumnValue = "report",
  43. allocationSize = 100)
  44. @Table(name = "report")
  45. public class ReportDTO implements Serializable {
  46. private int id;
  47. private String titleKey;
  48. private String instructionskey;
  49. private String tablesList;
  50. private String whereStr;
  51. private int idColumn;
  52. private String link;
  53. private Set<CompanyDTO> entities = new HashSet<CompanyDTO>(0);
  54. private Set<ReportFieldDTO> reportFields = new HashSet<ReportFieldDTO>(0);
  55. private Set<ReportTypeDTO> reportTypes = new HashSet<ReportTypeDTO>(0);
  56. private Set<ReportUserDTO> reportUsers = new HashSet<ReportUserDTO>(0);
  57. private int versionNum;
  58. public ReportDTO() {
  59. }
  60. public ReportDTO(int id, String tablesList, String whereStr, int idColumn) {
  61. this.id = id;
  62. this.tablesList = tablesList;
  63. this.whereStr = whereStr;
  64. this.idColumn = idColumn;
  65. }
  66. public ReportDTO(int id, String titlekey, String instructionskey,
  67. String tablesList, String whereStr, int idColumn, String link,
  68. Set<CompanyDTO> entities, Set<ReportFieldDTO> reportFields,
  69. Set<ReportTypeDTO> reportTypes, Set<ReportUserDTO> reportUsers) {
  70. this.id = id;
  71. this.titleKey = titlekey;
  72. this.instructionskey = instructionskey;
  73. this.tablesList = tablesList;
  74. this.whereStr = whereStr;
  75. this.idColumn = idColumn;
  76. this.link = link;
  77. this.entities = entities;
  78. this.reportFields = reportFields;
  79. this.reportTypes = reportTypes;
  80. this.reportUsers = reportUsers;
  81. }
  82. @Id
  83. @GeneratedValue(strategy = GenerationType.TABLE, generator = "report_GEN")
  84. @Column(name = "id", unique = true, nullable = false)
  85. public int getId() {
  86. return this.id;
  87. }
  88. public void setId(int id) {
  89. this.id = id;
  90. }
  91. @Column(name = "titlekey", length = 50)
  92. public String getTitleKey() {
  93. return this.titleKey;
  94. }
  95. public void setTitleKey(String titlekey) {
  96. this.titleKey = titlekey;
  97. }
  98. @Column(name = "instructionskey", length = 50)
  99. public String getInstructionsKey() {
  100. return this.instructionskey;
  101. }
  102. public void setInstructionsKey(String instructionskey) {
  103. this.instructionskey = instructionskey;
  104. }
  105. @Column(name = "tables_list", nullable = false, length = 1000)
  106. public String getTablesList() {
  107. return this.tablesList;
  108. }
  109. public void setTablesList(String tablesList) {
  110. this.tablesList = tablesList;
  111. }
  112. @Column(name = "where_str", nullable = false, length = 1000)
  113. public String getWhereStr() {
  114. return this.whereStr;
  115. }
  116. public void setWhereStr(String whereStr) {
  117. this.whereStr = whereStr;
  118. }
  119. @Column(name = "id_column", nullable = false)
  120. public int getIdColumn() {
  121. return this.idColumn;
  122. }
  123. public void setIdColumn(int idColumn) {
  124. this.idColumn = idColumn;
  125. }
  126. @Column(name = "link", length = 200)
  127. public String getLink() {
  128. return this.link;
  129. }
  130. public void setLink(String link) {
  131. this.link = link;
  132. }
  133. @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  134. @JoinTable(name = "report_entity_map", joinColumns = { @JoinColumn(name = "report_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "entity_id", updatable = false) })
  135. public Set<CompanyDTO> getEntities() {
  136. return this.entities;
  137. }
  138. public void setEntities(Set<CompanyDTO> entities) {
  139. this.entities = entities;
  140. }
  141. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "report")
  142. @OrderBy( clause="position_number, id" )
  143. public Set<ReportFieldDTO> getReportFields() {
  144. return this.reportFields;
  145. }
  146. public void setReportFields(Set<ReportFieldDTO> reportFields) {
  147. this.reportFields = reportFields;
  148. }
  149. @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  150. @JoinTable(name = "report_type_map", joinColumns = { @JoinColumn(name = "report_id", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "type_id", updatable = false) })
  151. public Set<ReportTypeDTO> getReportTypes() {
  152. return this.reportTypes;
  153. }
  154. public void setReportTypes(Set<ReportTypeDTO> reportTypes) {
  155. this.reportTypes = reportTypes;
  156. }
  157. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "report")
  158. @OrderBy( clause="id")
  159. public Set<ReportUserDTO> getReportUsers() {
  160. return this.reportUsers;
  161. }
  162. public void setReportUsers(Set<ReportUserDTO> reportUsers) {
  163. this.reportUsers = reportUsers;
  164. }
  165. @Version
  166. @Column(name = "OPTLOCK")
  167. public int getVersionNum() {
  168. return versionNum;
  169. }
  170. public void setVersionNum(int versionNum) {
  171. this.versionNum = versionNum;
  172. }
  173. }