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  package org.kuali.mobility.admin.entity;
16  
17  import java.io.Serializable;
18  
19  import javax.persistence.Column;
20  import javax.persistence.Entity;
21  import javax.persistence.FetchType;
22  import javax.persistence.GeneratedValue;
23  import javax.persistence.GenerationType;
24  import javax.persistence.Id;
25  import javax.persistence.JoinColumn;
26  import javax.persistence.ManyToOne;
27  import javax.persistence.Table;
28  import javax.persistence.Version;
29  import javax.xml.bind.annotation.XmlRootElement;
30  import javax.xml.bind.annotation.XmlTransient;
31  
32  /**
33   * Defines an object to link HomeScreen objects with Tool objects
34   * @author Kuali Mobility Team (mobility.dev@kuali.org)
35   * @since 1.0.0
36   */
37  @Entity
38  @Table(name="KME_HM_TL_T")
39  @XmlRootElement(name="homeTool")
40  public class HomeTool implements Serializable, Comparable<HomeTool> {
41  
42  	private static final long serialVersionUID = -8942674782383943102L;
43  
44  	/**
45  	 * ID for this <code>HomeTool</code>.
46  	 */
47  	@Id
48  	@GeneratedValue(strategy = GenerationType.TABLE)
49  	@Column(name="ID")
50  	private Long homeToolId;
51  
52  	/**
53  	 * Home Screen ID for this <code>HomeTool</code>.
54  	 */
55  	@Column(name="HM_SCRN_ID", insertable=false, updatable=false)
56  	private Long homeScreenId;
57  
58  	/**
59  	 * Tool ID for this <code>HomeTool</code>.
60  	 */
61  	@Column(name="TL_ID", insertable=false, updatable=false)
62  	private Long toolId;
63  
64  	/**
65  	 * Order index for this <code>HomeTool</code>.
66  	 */
67  	@Column(name="ORDR")
68  	private int order;
69  
70  	/**
71  	 * Home screen this <code>HomeTool</code> is linked too.
72  	 */
73  	@ManyToOne
74  	@JoinColumn(name="HM_SCRN_ID")
75  	private HomeScreen homeScreen;
76  
77  	/**
78  	 * Tool <code>HomeTool</code> is linked too.
79  	 */
80  	@ManyToOne(fetch = FetchType.EAGER)
81  	@JoinColumn(name="TL_ID")
82  	private Tool tool;
83  
84  	/**
85  	 * Version of this <code>HomeTool</code>.
86  	 */
87  	@Version
88  	@Column(name="VER_NBR")
89  	private Long versionNumber;
90  
91  	/**
92  	 * Creates a new instance of a <code>HomeTool</code>
93  	 */
94  	public HomeTool() {}
95  
96  	/**
97  	 * Creates a new instance of a <code>HomeTool</code>.
98  	 * @param homeScreen <code>Homescreen</code> this <code>HomeTool</code> is linked to.
99  	 * @param tool <code>Tool</code> this <code>HomeTool</code> is linked to.
100 	 * @param order Order for this <code>HomeTool</code>.
101 	 */
102 	public HomeTool(HomeScreen homeScreen, Tool tool, int order) {
103 		this.homeScreen = homeScreen;
104 		this.homeScreenId = homeScreen.getHomeScreenId();
105 		this.tool = tool;
106 		this.toolId = tool.getToolId();
107 		this.order = order;
108 	}
109 
110 
111 
112 	/**
113 	 * Gets the homeToolId for this <code>HomeTool</code>.
114 	 * @return the homeToolId
115 	 */
116 	public Long getHomeToolId() {
117 		return homeToolId;
118 	}
119 
120 	/**
121 	 * Sets the homeToolId for this <code>HomeTool</code>.
122 	 * @param homeToolId the homeToolId to set
123 	 */
124 	public void setHomeToolId(Long homeToolId) {
125 		this.homeToolId = homeToolId;
126 	}
127 
128 	/**
129 	 * Gets the homeScreenId for this <code>HomeTool</code>.
130 	 * @return the homeScreenId
131 	 */
132 	public Long getHomeScreenId() {
133 		return homeScreenId;
134 	}
135 
136 	/**
137 	 * Sets the homeScreenId for this <code>HomeTool</code>.
138 	 * @param homeScreenId the homeScreenId to set
139 	 */
140 	public void setHomeScreenId(Long homeScreenId) {
141 		this.homeScreenId = homeScreenId;
142 	}
143 
144 	/**
145 	 * Gets the toolId for this <code>HomeTool</code>.
146 	 * @return the toolId
147 	 */
148 	public Long getToolId() {
149 		return toolId;
150 	}
151 
152 	/**
153 	 * Sets the toolId for this <code>HomeTool</code>.
154 	 * @param toolId the toolId to set
155 	 */
156 	public void setToolId(Long toolId) {
157 		this.toolId = toolId;
158 	}
159 
160 	/**
161 	 * Gets the order for this <code>HomeTool</code>.
162 	 * @return the order
163 	 */
164 	public int getOrder() {
165 		return order;
166 	}
167 
168 	/**
169 	 * Sets the order for this <code>HomeTool</code>.
170 	 * @param order the order to set
171 	 */
172 	public void setOrder(int order) {
173 		this.order = order;
174 	}
175 
176 	/**
177 	 * Gets the versionNumber for this <code>HomeTool</code>.
178 	 * @return the versionNumber
179 	 */
180 	public Long getVersionNumber() {
181 		return versionNumber;
182 	}
183 
184 	/**
185 	 * Sets the versionNumber for this <code>HomeTool</code>.
186 	 * @param versionNumber the versionNumber to set
187 	 */
188 	public void setVersionNumber(Long versionNumber) {
189 		this.versionNumber = versionNumber;
190 	}
191 
192 	/**
193 	 * Gets the homeScreen for this <code>HomeTool</code>.
194 	 * @return the homeScreen
195 	 */
196 	@XmlTransient
197 	public HomeScreen getHomeScreen() {
198 		return homeScreen;
199 	}
200 
201 	/**
202 	 * Sets the homeScreen for this <code>HomeTool</code>.
203 	 * @param homeScreen the homeScreen to set
204 	 */
205 	public void setHomeScreen(HomeScreen homeScreen) {
206 		this.homeScreen = homeScreen;
207 	}
208 
209 	/**
210 	 * Gets the tool for this <code>HomeTool</code>.
211 	 * @return the tool
212 	 */
213 	public Tool getTool() {
214 		return tool;
215 	}
216 
217 	/**
218 	 * Sets the tool for this <code>HomeTool</code>.
219 	 * @param tool the tool to set
220 	 */
221 	public void setTool(Tool tool) {
222 		this.tool = tool;
223 	}
224 
225 	/*
226 	 * (non-Javadoc)
227 	 * @see java.lang.Comparable#compareTo(java.lang.Object)
228 	 */
229 	@Override
230 	public int compareTo(HomeTool that) {
231 		if (that == null) {
232 			return -1;
233 		}
234 		if (this.order == that.order) {
235 			return 0;
236 		}
237 		return this.order < that.order ? -1 : 1;
238 	}
239 
240 }