View Javadoc

1   /**
2    * Copyright 2005-2011 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 org.hibernate.annotations.GenericGenerator;
19  import org.hibernate.annotations.Parameter;
20  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21  
22  import javax.persistence.*;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * This class represents and instance of a Notification Channel. A Notification Channel is correlated to a specific class of
28   * notification, or in other words a specific business purpose. For instance, all overdue books from a specific library could
29   * be a channel or a channel for concerts coming to campus could be another channel.
30   * 
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @Entity
34  @Table(name = "KREN_CHNL_T")
35  public class NotificationChannel extends PersistableBusinessObjectBase {
36  	@Id
37  	@GeneratedValue(generator="KREN_CHNL_S")
38  	@GenericGenerator(name="KREN_CHNL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
39  			@Parameter(name="sequence_name",value="KREN_CHNL_S"),
40  			@Parameter(name="value_column",value="id")
41  	})
42  	@Column(name = "CHNL_ID")
43  	private Long id;
44  	@Column(name = "NM", nullable = false)
45  	private String name;
46  	@Column(name = "DESC_TXT", nullable = false)
47  	private String description;
48  	@Column(name = "SUBSCRB_IND", nullable = false)
49  	private boolean subscribable;
50  
51  	// List references
52  	@OneToMany(cascade={CascadeType.REFRESH, CascadeType.DETACH, CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}, 
53  			targetEntity=org.kuali.rice.ken.bo.NotificationRecipientList.class, mappedBy="channel")
54  	@OrderBy ("id ASC")
55  	private List<NotificationRecipientList> recipientLists;
56  	
57  	@ManyToMany(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH, CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST})@JoinTable(name="KREN_CHNL_PRODCR_T", 
58  			joinColumns=@JoinColumn(name="CHNL_ID"), 
59  			inverseJoinColumns=@JoinColumn(name="PRODCR_ID"))
60  	@OrderBy ("id ASC")
61  	private List<NotificationProducer> producers;
62  	
63  	@OneToMany(cascade={CascadeType.REFRESH, CascadeType.DETACH, CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}, 
64  			targetEntity=org.kuali.rice.ken.bo.NotificationChannelReviewer.class, mappedBy="channel")
65  	@OrderBy ("id ASC")
66  	private List<NotificationChannelReviewer> reviewers = new ArrayList<NotificationChannelReviewer>();
67  	
68  	@OneToMany(cascade={CascadeType.REFRESH, CascadeType.DETACH, CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}, 
69  			targetEntity=org.kuali.rice.ken.bo.UserChannelSubscription.class, mappedBy="channel")
70  	@OrderBy ("id ASC")
71  	private List<UserChannelSubscription> subscriptions = new ArrayList<UserChannelSubscription>();
72  
73  
74  	/**
75  	 * Constructs a NotificationChannel instance.
76  	 */
77  	public NotificationChannel() {
78  		super();
79  		recipientLists = new ArrayList<NotificationRecipientList>();
80  		producers = new ArrayList<NotificationProducer>();
81  	}
82  
83  	/**
84  	 * Gets the recipientLists attribute.
85  	 * 
86  	 * @return Returns the recipientLists.
87  	 */
88  	public List<NotificationRecipientList> getRecipientLists() {
89  		return recipientLists;
90  	}
91  
92  	/**
93  	 * Sets the recipientLists attribute value.
94  	 * 
95  	 * @param recipientLists
96  	 *            The recipientLists to set.
97  	 */
98  	public void setRecipientLists(List<NotificationRecipientList> recipientLists) {
99  		this.recipientLists = recipientLists;
100 	}
101 
102 	/**
103 	 * This method adds a recipient list to the overall set of recipient lists that are associated with this channnel.
104 	 * 
105 	 * @param recipientList
106 	 */
107 	public void addRecipientList(NotificationRecipientList recipientList) {
108 		this.recipientLists.add(recipientList);
109 	}
110 
111 	/**
112 	 * This method removes a recipient list object from the overall list.
113 	 * 
114 	 * @param recipientList
115 	 */
116 	public void removeRecipientList(NotificationRecipientList recipientList) {
117 		this.recipientLists.remove(recipientList);
118 	}
119 
120 	/**
121 	 * Gets the description attribute.
122 	 * 
123 	 * @return Returns the description.
124 	 */
125 	public String getDescription() {
126 		return description;
127 	}
128 
129 	/**
130 	 * Sets the description attribute value.
131 	 * 
132 	 * @param description
133 	 *            The description to set.
134 	 */
135 	public void setDescription(String description) {
136 		this.description = description;
137 	}
138 
139 	/**
140 	 * Gets the id attribute.
141 	 * 
142 	 * @return Returns the id.
143 	 */
144 	public Long getId() {
145 		return id;
146 	}
147 
148 	/**
149 	 * Sets the id attribute value.
150 	 * 
151 	 * @param id
152 	 *            The id to set.
153 	 */
154 	public void setId(Long id) {
155 		this.id = id;
156 	}
157 
158 	/**
159 	 * Gets the name attribute.
160 	 * 
161 	 * @return Returns the name.
162 	 */
163 	public String getName() {
164 		return name;
165 	}
166 
167 	/**
168 	 * Sets the name attribute value.
169 	 * 
170 	 * @param name
171 	 *            The name to set.
172 	 */
173 	public void setName(String name) {
174 		this.name = name;
175 	}
176 
177 	/**
178 	 * Gets the subscribable attribute.
179 	 * 
180 	 * @return Returns the subscribable.
181 	 */
182 	public boolean isSubscribable() {
183 		return subscribable;
184 	}
185 
186 	/**
187 	 * Sets the subscribable attribute value.
188 	 * 
189 	 * @param subscribable
190 	 *            The subscribable to set.
191 	 */
192 	public void setSubscribable(boolean subscribable) {
193 		this.subscribable = subscribable;
194 	}
195 
196 	/**
197 	 * Gets the producers attribute.
198 	 * 
199 	 * @return Returns the producers.
200 	 */
201 	public List<NotificationProducer> getProducers() {
202 		return producers;
203 	}
204 
205 	/**
206 	 * Sets the producers attribute value.
207 	 * 
208 	 * @param producers
209 	 *            The producers to set.
210 	 */
211 	public void setProducers(List<NotificationProducer> producers) {
212 		this.producers = producers;
213 	}
214 
215 	/**
216 	 * Gets the list of reviewers for notification publications to this channel
217 	 * 
218 	 * @return the list of reviewers for notification publications to this channel
219 	 */
220 	public List<NotificationChannelReviewer> getReviewers() {
221 		return reviewers;
222 	}
223 
224 	/**
225 	 * Sets the list of reviewers for notification publications to this channel
226 	 * 
227 	 * @param reviewers
228 	 *            the list of reviewers for notification publications to this channel
229 	 */
230 	public void setReviewers(List<NotificationChannelReviewer> reviewers) {
231 		this.reviewers = reviewers;
232 	}
233 
234 	/**
235 	 * Gets the list of subscriptions to this channel
236 	 * 
237 	 * @return the list of subscriptions to this channel
238 	 */
239 	public List<UserChannelSubscription> getSubscriptions() {
240 		return subscriptions;
241 	}
242 
243 	/**
244 	 * Sets the list of subscriptions to this channel
245 	 * 
246 	 * @param subscriptions
247 	 *            the list of subscriptions to this channel
248 	 */
249 	public void setSubscriptions(List<UserChannelSubscription> subscriptions) {
250 		this.subscriptions = subscriptions;
251 	}
252 
253 	/**
254 	 * Compares the id values of each NotificationChannel object.
255 	 * 
256 	 * @see java.lang.Object#equals(java.lang.Object)
257 	 */
258 	@Override
259 	public boolean equals(Object obj) {
260 		NotificationChannel channelToCompare = (NotificationChannel) obj;
261 		return this.getId().equals(channelToCompare.getId());
262 	}
263 }