/src/classes/com/sapienter/jbilling/server/notification/db/NotificationMessageDTO.java

https://github.com/bibulous/SkyrackJbill2.2 · Java · 168 lines · 124 code · 25 blank · 19 comment · 0 complexity · db1f54152228207bcba71b36d2759321 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.notification.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.ManyToOne;
  29. import javax.persistence.OneToMany;
  30. import javax.persistence.Table;
  31. import javax.persistence.TableGenerator;
  32. import javax.persistence.Version;
  33. import org.hibernate.annotations.Cache;
  34. import org.hibernate.annotations.CacheConcurrencyStrategy;
  35. import org.hibernate.annotations.Fetch;
  36. import org.hibernate.annotations.FetchMode;
  37. import org.hibernate.annotations.OrderBy;
  38. import com.sapienter.jbilling.server.user.db.CompanyDTO;
  39. import com.sapienter.jbilling.server.util.db.LanguageDTO;
  40. @Entity
  41. @TableGenerator(
  42. name = "notification_message_GEN",
  43. table = "jbilling_seqs",
  44. pkColumnName = "name",
  45. valueColumnName = "next_id",
  46. pkColumnValue = "notification_message",
  47. allocationSize = 100)
  48. @Table(name = "notification_message")
  49. @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  50. public class NotificationMessageDTO implements Serializable {
  51. private int id;
  52. private NotificationMessageTypeDTO notificationMessageType;
  53. private CompanyDTO entity;
  54. private LanguageDTO language;
  55. private short useFlag;
  56. private Set<NotificationMessageSectionDTO> notificationMessageSections = new HashSet<NotificationMessageSectionDTO>(
  57. 0);
  58. private int versionNum;
  59. public NotificationMessageDTO() {
  60. }
  61. public NotificationMessageDTO(int id, CompanyDTO entity,
  62. LanguageDTO language, short useFlag) {
  63. this.id = id;
  64. this.entity = entity;
  65. this.language = language;
  66. this.useFlag = useFlag;
  67. }
  68. public NotificationMessageDTO(int id,
  69. NotificationMessageTypeDTO notificationMessageType,
  70. CompanyDTO entity, LanguageDTO language, short useFlag,
  71. Set<NotificationMessageSectionDTO> notificationMessageSections) {
  72. this.id = id;
  73. this.notificationMessageType = notificationMessageType;
  74. this.entity = entity;
  75. this.language = language;
  76. this.useFlag = useFlag;
  77. this.notificationMessageSections = notificationMessageSections;
  78. }
  79. @Id
  80. @GeneratedValue(strategy = GenerationType.TABLE, generator = "notification_message_GEN")
  81. @Column(name = "id", unique = true, nullable = false)
  82. public int getId() {
  83. return this.id;
  84. }
  85. public void setId(int id) {
  86. this.id = id;
  87. }
  88. @ManyToOne(fetch = FetchType.LAZY)
  89. @JoinColumn(name = "type_id")
  90. public NotificationMessageTypeDTO getNotificationMessageType() {
  91. return this.notificationMessageType;
  92. }
  93. public void setNotificationMessageType(
  94. NotificationMessageTypeDTO notificationMessageType) {
  95. this.notificationMessageType = notificationMessageType;
  96. }
  97. @ManyToOne(fetch = FetchType.LAZY)
  98. @JoinColumn(name = "entity_id", nullable = false)
  99. public CompanyDTO getEntity() {
  100. return this.entity;
  101. }
  102. public void setEntity(CompanyDTO entity) {
  103. this.entity = entity;
  104. }
  105. @ManyToOne(fetch = FetchType.LAZY)
  106. @JoinColumn(name = "language_id", nullable = false)
  107. public LanguageDTO getLanguage() {
  108. return this.language;
  109. }
  110. public void setLanguage(LanguageDTO language) {
  111. this.language = language;
  112. }
  113. @Column(name = "use_flag", nullable = false)
  114. public short getUseFlag() {
  115. return this.useFlag;
  116. }
  117. public void setUseFlag(short useFlag) {
  118. this.useFlag = useFlag;
  119. }
  120. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "notificationMessage")
  121. @OrderBy(clause="section")
  122. @Fetch( FetchMode.JOIN )
  123. @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  124. public Set<NotificationMessageSectionDTO> getNotificationMessageSections() {
  125. return this.notificationMessageSections;
  126. }
  127. public void setNotificationMessageSections(
  128. Set<NotificationMessageSectionDTO> notificationMessageSections) {
  129. this.notificationMessageSections = notificationMessageSections;
  130. }
  131. @Version
  132. @Column(name="OPTLOCK")
  133. public int getVersionNum() {
  134. return versionNum;
  135. }
  136. public void setVersionNum(int versionNum) {
  137. this.versionNum = versionNum;
  138. }
  139. }