/src/classes/com/sapienter/jbilling/server/list/db/ListEntityDTO.java

https://github.com/othmanelmoulat/jbilling-2.2-Extentions · Java · 154 lines · 113 code · 22 blank · 19 comment · 0 complexity · 01121f7548b364b09ae781bae54570a9 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.list.db;
  17. import java.io.Serializable;
  18. import java.util.Date;
  19. import java.util.HashSet;
  20. import java.util.Set;
  21. import javax.persistence.CascadeType;
  22. import javax.persistence.Column;
  23. import javax.persistence.Entity;
  24. import javax.persistence.FetchType;
  25. import javax.persistence.GeneratedValue;
  26. import javax.persistence.GenerationType;
  27. import javax.persistence.Id;
  28. import javax.persistence.JoinColumn;
  29. import javax.persistence.ManyToOne;
  30. import javax.persistence.OneToMany;
  31. import javax.persistence.Table;
  32. import javax.persistence.TableGenerator;
  33. import javax.persistence.UniqueConstraint;
  34. import javax.persistence.Version;
  35. import com.sapienter.jbilling.server.user.db.CompanyDTO;
  36. @Entity
  37. @TableGenerator(
  38. name = "list_entity_GEN",
  39. table = "jbilling_seqs",
  40. pkColumnName = "name",
  41. valueColumnName = "next_id",
  42. pkColumnValue = "list_entity",
  43. allocationSize = 100)
  44. @Table(name = "list_entity", uniqueConstraints = @UniqueConstraint(columnNames = {
  45. "list_id", "entity_id" }))
  46. public class ListEntityDTO implements Serializable {
  47. private int id;
  48. private ListDTO list;
  49. private CompanyDTO entity;
  50. private int totalRecords;
  51. private Date lastUpdate;
  52. private Set<ListFieldEntityDTO> listFieldEntities = new HashSet<ListFieldEntityDTO>(
  53. 0);
  54. private int versionNum;
  55. public ListEntityDTO() {
  56. }
  57. public ListEntityDTO(int id, CompanyDTO entity, int totalRecords,
  58. Date lastUpdate) {
  59. this.id = id;
  60. this.entity = entity;
  61. this.totalRecords = totalRecords;
  62. this.lastUpdate = lastUpdate;
  63. }
  64. public ListEntityDTO(int id, ListDTO list, CompanyDTO entity,
  65. int totalRecords, Date lastUpdate,
  66. Set<ListFieldEntityDTO> listFieldEntities) {
  67. this.id = id;
  68. this.list = list;
  69. this.entity = entity;
  70. this.totalRecords = totalRecords;
  71. this.lastUpdate = lastUpdate;
  72. this.listFieldEntities = listFieldEntities;
  73. }
  74. @Id
  75. @GeneratedValue(strategy = GenerationType.TABLE, generator = "list_entity_GEN")
  76. @Column(name = "id", unique = true, nullable = false)
  77. public int getId() {
  78. return this.id;
  79. }
  80. public void setId(int id) {
  81. this.id = id;
  82. }
  83. @ManyToOne(fetch = FetchType.LAZY)
  84. @JoinColumn(name = "list_id")
  85. public ListDTO getList() {
  86. return this.list;
  87. }
  88. public void setList(ListDTO list) {
  89. this.list = list;
  90. }
  91. @ManyToOne(fetch = FetchType.LAZY)
  92. @JoinColumn(name = "entity_id", nullable = false)
  93. public CompanyDTO getEntity() {
  94. return this.entity;
  95. }
  96. public void setEntity(CompanyDTO entity) {
  97. this.entity = entity;
  98. }
  99. @Column(name = "total_records", nullable = false)
  100. public int getTotalRecords() {
  101. return this.totalRecords;
  102. }
  103. public void setTotalRecords(int totalRecords) {
  104. this.totalRecords = totalRecords;
  105. }
  106. @Column(name = "last_update", nullable = false, length = 13)
  107. public Date getLastUpdate() {
  108. return this.lastUpdate;
  109. }
  110. public void setLastUpdate(Date lastUpdate) {
  111. this.lastUpdate = lastUpdate;
  112. }
  113. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "listEntity")
  114. public Set<ListFieldEntityDTO> getListFieldEntities() {
  115. return this.listFieldEntities;
  116. }
  117. public void setListFieldEntities(Set<ListFieldEntityDTO> listFieldEntities) {
  118. this.listFieldEntities = listFieldEntities;
  119. }
  120. @Version
  121. @Column(name="OPTLOCK")
  122. public int getVersionNum() {
  123. return versionNum;
  124. }
  125. public void setVersionNum(int versionNum) {
  126. this.versionNum = versionNum;
  127. }
  128. }