View Javadoc

1   /*
2    * Copyright 2007-2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ken.bo;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.persistence.CascadeType;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.FetchType;
25  import javax.persistence.Id;
26  import javax.persistence.JoinColumn;
27  import javax.persistence.JoinTable;
28  import javax.persistence.ManyToMany;
29  import javax.persistence.OneToMany;
30  import javax.persistence.Table;
31  import javax.persistence.Transient;
32  
33  /**
34   * This class represents and instance of a Notification Channel. A Notification Channel is correlated to a specific class of
35   * notification, or in other words a specific business purpose. For instance, all overdue books from a specific library could
36   * be a channel or a channel for concerts coming to campus could be another channel.
37   * 
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  @Entity
41  @Table(name = "KREN_CHNL_T")
42  public class NotificationChannel {
43      @Id
44      @Column(name = "CHNL_ID")
45      private Long id;
46      @Column(name = "NM", nullable = false)
47      private String name;
48      @Column(name = "DESC_TXT", nullable = false)
49      private String description;
50      @Column(name = "SUBSCRB_IND", nullable = false)
51      private boolean subscribable;
52  
53      // List references
54      @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, targetEntity = org.kuali.rice.ken.bo.NotificationRecipientList.class, mappedBy = "channel")
55      private List<NotificationRecipientList> recipientLists;
56      @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
57      @JoinTable(name = "NOTIFICATION_CHANNEL_PRODUCERS", joinColumns = @JoinColumn(name = "CHNL_ID"), inverseJoinColumns = @JoinColumn(name = "PRODCR_ID"))
58      private List<NotificationProducer> producers;
59      @Transient
60      private List<NotificationChannelReviewer> reviewers = new ArrayList<NotificationChannelReviewer>();
61      @Transient
62      private List<UserChannelSubscription> subscriptions = new ArrayList<UserChannelSubscription>();
63  
64      /**
65       * Constructs a NotificationChannel instance.
66       */
67      public NotificationChannel() {
68          super();
69          recipientLists = new ArrayList<NotificationRecipientList>();
70          producers = new ArrayList<NotificationProducer>();
71      }
72  
73      /**
74       * Gets the recipientLists attribute.
75       * 
76       * @return Returns the recipientLists.
77       */
78      public List<NotificationRecipientList> getRecipientLists() {
79          return recipientLists;
80      }
81  
82      /**
83       * Sets the recipientLists attribute value.
84       * 
85       * @param recipientLists
86       *            The recipientLists to set.
87       */
88      public void setRecipientLists(List<NotificationRecipientList> recipientLists) {
89          this.recipientLists = recipientLists;
90      }
91  
92      /**
93       * This method adds a recipient list to the overall set of recipient lists that are associated with this channnel.
94       * 
95       * @param recipientList
96       */
97      public void addRecipientList(NotificationRecipientList recipientList) {
98          this.recipientLists.add(recipientList);
99      }
100 
101     /**
102      * This method removes a recipient list object from the overall list.
103      * 
104      * @param recipientList
105      */
106     public void removeRecipientList(NotificationRecipientList recipientList) {
107         this.recipientLists.remove(recipientList);
108     }
109 
110     /**
111      * Gets the description attribute.
112      * 
113      * @return Returns the description.
114      */
115     public String getDescription() {
116         return description;
117     }
118 
119     /**
120      * Sets the description attribute value.
121      * 
122      * @param description
123      *            The description to set.
124      */
125     public void setDescription(String description) {
126         this.description = description;
127     }
128 
129     /**
130      * Gets the id attribute.
131      * 
132      * @return Returns the id.
133      */
134     public Long getId() {
135         return id;
136     }
137 
138     /**
139      * Sets the id attribute value.
140      * 
141      * @param id
142      *            The id to set.
143      */
144     public void setId(Long id) {
145         this.id = id;
146     }
147 
148     /**
149      * Gets the name attribute.
150      * 
151      * @return Returns the name.
152      */
153     public String getName() {
154         return name;
155     }
156 
157     /**
158      * Sets the name attribute value.
159      * 
160      * @param name
161      *            The name to set.
162      */
163     public void setName(String name) {
164         this.name = name;
165     }
166 
167     /**
168      * Gets the subscribable attribute.
169      * 
170      * @return Returns the subscribable.
171      */
172     public boolean isSubscribable() {
173         return subscribable;
174     }
175 
176     /**
177      * Sets the subscribable attribute value.
178      * 
179      * @param subscribable
180      *            The subscribable to set.
181      */
182     public void setSubscribable(boolean subscribable) {
183         this.subscribable = subscribable;
184     }
185 
186     /**
187      * Gets the producers attribute.
188      * 
189      * @return Returns the producers.
190      */
191     public List<NotificationProducer> getProducers() {
192         return producers;
193     }
194 
195     /**
196      * Sets the producers attribute value.
197      * 
198      * @param producers
199      *            The producers to set.
200      */
201     public void setProducers(List<NotificationProducer> producers) {
202         this.producers = producers;
203     }
204 
205     /**
206      * Gets the list of reviewers for notification publications to this channel
207      * 
208      * @return the list of reviewers for notification publications to this channel
209      */
210     public List<NotificationChannelReviewer> getReviewers() {
211         return reviewers;
212     }
213 
214     /**
215      * Sets the list of reviewers for notification publications to this channel
216      * 
217      * @param reviewers
218      *            the list of reviewers for notification publications to this channel
219      */
220     public void setReviewers(List<NotificationChannelReviewer> reviewers) {
221         this.reviewers = reviewers;
222     }
223 
224     /**
225      * Gets the list of subscriptions to this channel
226      * 
227      * @return the list of subscriptions to this channel
228      */
229     public List<UserChannelSubscription> getSubscriptions() {
230         return subscriptions;
231     }
232 
233     /**
234      * Sets the list of subscriptions to this channel
235      * 
236      * @param subscriptions
237      *            the list of subscriptions to this channel
238      */
239     public void setSubscriptions(List<UserChannelSubscription> subscriptions) {
240         this.subscriptions = subscriptions;
241     }
242 
243     /**
244      * Compares the id values of each NotificationChannel object.
245      * 
246      * @see java.lang.Object#equals(java.lang.Object)
247      */
248     @Override
249     public boolean equals(Object obj) {
250         NotificationChannel channelToCompare = (NotificationChannel) obj;
251         return this.getId().equals(channelToCompare.getId());
252     }
253 
254 }