View Javadoc

1   /**
2    * Copyright 2011-2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.mobility.admin.entity;
17  
18  import java.io.Serializable;
19  
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.NamedQueries;
29  import javax.persistence.NamedQuery;
30  import javax.persistence.OneToOne;
31  import javax.persistence.Table;
32  import javax.persistence.Transient;
33  import javax.persistence.Version;
34  import javax.xml.bind.annotation.XmlRootElement;
35  
36  import org.kuali.mobility.security.authz.entity.AclExpression;
37  
38  /**
39   * Defines a "tool" to show on a home screen. It can be assigned to HomeScreens through HomeTool objects.
40   * @author Kuali Mobility Team (mobility.dev@kuali.org)
41   * @since 1.0.0
42   */
43  @NamedQueries({
44  	// Gets all the tools
45  	@NamedQuery(
46  		name="Tool.getAllTools",
47  		query="SELECT t FROM Tool t"
48  	),
49  	// Gets a tool by id
50  	@NamedQuery(
51  		name="Tool.getToolById",
52  		query="SELECT t FROM Tool t WHERE t.toolId = :id"
53  	),
54  	// Deletes a tool by ID
55  	@NamedQuery(
56  		name="Tool.deleteToolById",
57  		query="delete from Tool t where t.toolId = :toolId"
58  	)
59  })
60  @Entity
61  @Table(name="TL_T")
62  @XmlRootElement(name="tool")
63  public class Tool implements Serializable, Comparable<Tool> {
64  
65  	// Constants used for the Requisites field. 
66  	// !!! DON'T CHANGE VALUES!!! Matches values in ToolFromXML.java.
67  	public static final int UNDEFINED_REQUISITES = 0;
68  	public static final int NATIVE 			= 1;
69  	public static final int IOS				= 2;
70  	public static final int ANDROID			= 4;
71  	public static final int WINDOWS_PHONE	= 8;
72  	public static final int BLACKBERRY		= 16;
73  	public static final int NON_NATIVE 		= 32;
74  	public static final int ALL_PLATFORMS 	= IOS | ANDROID | WINDOWS_PHONE | BLACKBERRY;
75  	public static final int ANY	 			= NATIVE | NON_NATIVE | IOS | ANDROID | WINDOWS_PHONE | BLACKBERRY;
76  
77  
78  	private static final long serialVersionUID = 4709451428489759275L;
79  
80  	/**
81  	 * ID for this <code>Tool</code>
82  	 */
83  	@Id
84  	@GeneratedValue(strategy = GenerationType.TABLE)
85  	@Column(name="ID")
86  	private Long toolId;
87  
88  	/**
89  	 * Alias for this <code>Tool</code>
90  	 */
91  	@Column(name="ALIAS")
92  	private String alias;
93  
94  	/**
95  	 * Title for this <code>Tool</code>
96  	 */
97  	@Column(name="TTL")
98  	private String title;
99  
100 	/**
101 	 * Subtitle for this <code>Tool</code>
102 	 */
103 	@Column(name="SB_TTL")
104 	private String subtitle;
105 
106 	/**
107 	 * Url for this <code>Tool</code>
108 	 */
109 	@Column(name="URL")
110 	private String url;
111 
112 	/**
113 	 * Description for this <code>Tool</code>
114 	 */
115 	@Column(name="DESC_TXT")
116 	private String description;
117 
118 	/**
119 	 * Icon URL for this <code>Tool</code>
120 	 */
121 	@Column(name="ICN_URL")
122 	private String iconUrl;
123 
124 	/**
125 	 * Contacts for this <code>Tool</code>
126 	 */
127 	@Column(name="CONTACTS")
128 	private String contacts;
129 
130 	/**
131 	 * Keywords for this <code>Tool</code>
132 	 */
133 	@Column(name="KEYWORDS")
134 	private String keywords;
135 
136 	/**
137 	 * Requisites for this <code>Tool</code>
138 	 */
139 	@Column(name="REQUISITES")
140 	private int requisites;
141 
142 	/**
143 	 * ACL Viewing ID for this <code>Tool</code>
144 	 */
145 	@Column(name="ACL_VIEW_ID", insertable=false, updatable=false)
146 	private Long aclViewingId;
147 
148 	/**
149 	 * ACL Publising ID for this <code>Tool</code>
150 	 */
151 	@Column(name="ACL_PUB_ID", insertable=false, updatable=false)
152 	private Long aclPublishingId;
153 
154 	/**
155 	 * Viewing permissions for this <code>Tool</code>
156 	 */
157 	@OneToOne(fetch=FetchType.EAGER, cascade={ CascadeType.ALL } )
158 	@JoinColumn(name="ACL_VIEW_ID", referencedColumnName="ID", nullable=true)
159 	private AclExpression viewingPermission;
160 
161 	/**
162 	 * Publishing permissions for this <code>Tool</code>
163 	 */
164 	@OneToOne(fetch=FetchType.EAGER, cascade={ CascadeType.ALL } )
165 	@JoinColumn(name="ACL_PUB_ID", referencedColumnName="ID", nullable=true)
166 	private AclExpression publishingPermission;
167 
168 	/**
169 	 * Version for this <code>Tool</code>
170 	 */
171 	@Version
172 	@Column(name="VER_NBR")
173 	private Long versionNumber;
174 
175 	/**
176 	 * Badge count for this <code>Tool</code>
177 	 */
178 	@Transient
179 	private String badgeCount;
180 
181 	/**
182 	 * Badge text for this <code>Tool</code>
183 	 */
184 	@Transient
185 	private String badgeText;
186 
187 	/**
188 	 * Gets the toolId for this <code>Tool</code>.
189 	 * @return the toolId
190 	 */
191 	public Long getToolId() {
192 		return toolId;
193 	}
194 
195 	/**
196 	 * Sets the toolId for this <code>Tool</code>.
197 	 * @param toolId the toolId to set
198 	 */
199 	public void setToolId(Long toolId) {
200 		this.toolId = toolId;
201 	}
202 
203 	/**
204 	 * Gets the alias for this <code>Tool</code>.
205 	 * @return the alias
206 	 */
207 	public String getAlias() {
208 		return alias;
209 	}
210 
211 	/**
212 	 * Sets the alias for this <code>Tool</code>.
213 	 * @param alias the alias to set
214 	 */
215 	public void setAlias(String alias) {
216 		this.alias = alias;
217 	}
218 
219 	/**
220 	 * Gets the title for this <code>Tool</code>.
221 	 * @return the title
222 	 */
223 	public String getTitle() {
224 		return title;
225 	}
226 
227 	/**
228 	 * Sets the title for this <code>Tool</code>.
229 	 * @param title the title to set
230 	 */
231 	public void setTitle(String title) {
232 		this.title = title;
233 	}
234 
235 	/**
236 	 * Gets the url for this <code>Tool</code>.
237 	 * @return the url
238 	 */
239 	public String getUrl() {
240 		return url;
241 	}
242 
243 	/**
244 	 * Sets the url for this <code>Tool</code>.
245 	 * @param url the url to set
246 	 */
247 	public void setUrl(String url) {
248 		this.url = url;
249 	}
250 
251 	/**
252 	 * Gets the description for this <code>Tool</code>.
253 	 * @return the description
254 	 */
255 	public String getDescription() {
256 		return description;
257 	}
258 
259 	/**
260 	 * Sets the description for this <code>Tool</code>.
261 	 * @param description the description to set
262 	 */
263 	public void setDescription(String description) {
264 		this.description = description;
265 	}
266 
267 	/**
268 	 * Gets the badgeCount for this <code>Tool</code>.
269 	 * @return the badgeCount
270 	 */
271 	public String getBadgeCount() {
272 		return badgeCount;
273 	}
274 
275 	/**
276 	 * Sets the badgeCount for this <code>Tool</code>.
277 	 * @param badgeCount the badgeCount to set
278 	 */
279 	public void setBadgeCount(String badgeCount) {
280 		this.badgeCount = badgeCount;
281 	}
282 
283 	/**
284 	 * Gets the iconUrl for this <code>Tool</code>.
285 	 * @return the iconUrl
286 	 */
287 	public String getIconUrl() {
288 		return iconUrl;
289 	}
290 
291 	/**
292 	 * Sets the iconUrl for this <code>Tool</code>.
293 	 * @param iconUrl the iconUrl to set
294 	 */
295 	public void setIconUrl(String iconUrl) {
296 		this.iconUrl = iconUrl;
297 	}
298 
299 	/**
300 	 * Gets the versionNumber for this <code>Tool</code>.
301 	 * @return the versionNumber
302 	 */
303 	public Long getVersionNumber() {
304 		return versionNumber;
305 	}
306 
307 	/**
308 	 * Sets the versionNumber for this <code>Tool</code>.
309 	 * @param versionNumber the versionNumber to set
310 	 */
311 	public void setVersionNumber(Long versionNumber) {
312 		this.versionNumber = versionNumber;
313 	}
314 
315 	/*
316 	 * (non-Javadoc)
317 	 * @see java.lang.Comparable#compareTo(java.lang.Object)
318 	 */
319 	@Override
320 	public int compareTo(Tool that) {
321 		if (that == null) {
322 			return -1;
323 		}
324 		return this.title.compareTo(that.title);
325 	}
326 
327 	/*
328 	 * (non-Javadoc)
329 	 * @see java.lang.Object#equals(java.lang.Object)
330 	 */
331 	@Override
332 	public boolean equals(Object that) {
333 		if (that == null) {
334 			return false;
335 		}
336 		if (that instanceof Tool) {
337 			return this.toolId.equals(((Tool)that).toolId);
338 		}
339 		return false;
340 	}
341 
342 
343 	/**
344 	 * Gets the contacts for this <code>Tool</code>.
345 	 * @return the contacts
346 	 */
347 	public String getContacts() {
348 		return contacts;
349 	}
350 
351 	/**
352 	 * Sets the contacts for this <code>Tool</code>.
353 	 * @param contacts the contacts to set
354 	 */
355 	public void setContacts(String contacts) {
356 		this.contacts = contacts;
357 	}
358 
359 	/**
360 	 * Gets the requisites for this <code>Tool</code>.
361 	 * @return the requisites
362 	 */
363 	public int getRequisites() {
364 		return requisites;
365 	}
366 
367 	/**
368 	 * Sets the requisites for this <code>Tool</code>.
369 	 * @param requisites the requisites to set
370 	 */
371 	public void setRequisites(int requisites) {
372 		this.requisites = requisites;
373 	}
374 
375 
376 	/**
377 	 * Gets the subtitle for this <code>Tool</code>.
378 	 * @return the subtitle
379 	 */
380 	public String getSubtitle() {
381 		return subtitle;
382 	}
383 
384 	/**
385 	 * Sets the subtitle for this <code>Tool</code>.
386 	 * @param subtitle the subtitle to set
387 	 */
388 	public void setSubtitle(String subtitle) {
389 		this.subtitle = subtitle;
390 	}
391 
392 	/**
393 	 * Gets the keywords for this <code>Tool</code>.
394 	 * @return the keywords
395 	 */
396 	public String getKeywords() {
397 		return keywords;
398 	}
399 
400 	/**
401 	 * Sets the keywords for this <code>Tool</code>.
402 	 * @param keywords the keywords to set
403 	 */
404 	public void setKeywords(String keywords) {
405 		this.keywords = keywords;
406 	}
407 
408 	/**
409 	 * Gets the badgeText for this <code>Tool</code>.
410 	 * @return the badgeText
411 	 */
412 	public String getBadgeText() {
413 		return badgeText;
414 	}
415 
416 	/**
417 	 * Sets the badgeText for this <code>Tool</code>.
418 	 * @param badgeText the badgeText to set
419 	 */
420 	public void setBadgeText(String badgeText) {
421 		this.badgeText = badgeText;
422 	}
423 
424 	/**
425 	 * Gets the aclViewingId for this <code>Tool</code>.
426 	 * @return the aclViewingId
427 	 */
428 	public Long getAclViewingId() {
429 		return aclViewingId;
430 	}
431 
432 	/**
433 	 * Sets the aclViewingId for this <code>Tool</code>.
434 	 * @param aclViewingId the aclViewingId to set
435 	 */
436 	public void setAclViewingId(Long aclViewingId) {
437 		this.aclViewingId = aclViewingId;
438 	}
439 
440 	/**
441 	 * Gets the aclPublishingId for this <code>Tool</code>.
442 	 * @return the aclPublishingId
443 	 */
444 	public Long getAclPublishingId() {
445 		return aclPublishingId;
446 	}
447 
448 	/**
449 	 * Sets the aclPublishingId for this <code>Tool</code>.
450 	 * @param aclPublishingId the aclPublishingId to set
451 	 */
452 	public void setAclPublishingId(Long aclPublishingId) {
453 		this.aclPublishingId = aclPublishingId;
454 	}
455 
456 	/**
457 	 * Gets the viewingPermission for this <code>Tool</code>.
458 	 * @return the viewingPermission
459 	 */
460 	public AclExpression getViewingPermission() {
461 		return viewingPermission;
462 	}
463 
464 	/**
465 	 * Sets the viewingPermission for this <code>Tool</code>.
466 	 * @param viewingPermission the viewingPermission to set
467 	 */
468 	public void setViewingPermission(AclExpression viewingPermission) {
469 		this.viewingPermission = viewingPermission;
470 	}
471 
472 	/**
473 	 * Gets the publishingPermission for this <code>Tool</code>.
474 	 * @return the publishingPermission
475 	 */
476 	public AclExpression getPublishingPermission() {
477 		return publishingPermission;
478 	}
479 
480 	/**
481 	 * Sets the publishingPermission for this <code>Tool</code>.
482 	 * @param publishingPermission the publishingPermission to set
483 	 */
484 	public void setPublishingPermission(AclExpression publishingPermission) {
485 		this.publishingPermission = publishingPermission;
486 	}
487 
488 }