001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.roles;
017
018 import java.sql.Date;
019 import java.sql.Timestamp;
020
021 import org.kuali.hr.core.KPMEConstants;
022 import org.kuali.hr.location.Location;
023 import org.kuali.hr.time.HrBusinessObject;
024 import org.kuali.hr.time.department.Department;
025 import org.kuali.hr.time.position.Position;
026 import org.kuali.hr.time.service.base.TkServiceLocator;
027 import org.kuali.hr.time.util.TKUtils;
028 import org.kuali.hr.time.workarea.WorkArea;
029 import org.kuali.kfs.coa.businessobject.Chart;
030 import org.kuali.rice.kim.api.identity.Person;
031 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
032
033 public class TkRole extends HrBusinessObject {
034 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "TkRole";
035 /**
036 *
037 */
038 private static final long serialVersionUID = 1L;
039 private String hrRolesId;
040 private String principalId;
041 private String roleName;
042 private String userPrincipalId;
043 private Long workArea;
044 private String department;
045 private String chart;
046 private Long hrDeptId;
047 private String positionNumber;
048 private Date expirationDate;
049
050 /**
051 * These objects are used by Lookups to provide links on the maintenance
052 * page. They are not necessarily going to be populated.
053 */
054 private Person person;
055 private Department departmentObj;
056 private WorkArea workAreaObj;
057 private Chart chartObj;
058 private Position positionObj;
059
060 private Location locationObj;
061
062 public Chart getChartObj() {
063 return chartObj;
064 }
065
066 public void setChartObj(Chart chartObj) {
067 this.chartObj = chartObj;
068 }
069
070 public Department getDepartmentObj() {
071 return departmentObj;
072 }
073
074 public void setDepartmentObj(Department departmentObj) {
075 this.departmentObj = departmentObj;
076 if (departmentObj != null) {
077 this.department = departmentObj.getDept();
078 this.workAreaObj= null;
079 this.workArea = null;
080 }
081 }
082
083 public WorkArea getWorkAreaObj() {
084 return workAreaObj;
085 }
086
087 public void setWorkAreaObj(WorkArea workAreaObj) {
088 this.workAreaObj = workAreaObj;
089 if (workAreaObj != null) {
090 this.workArea = workAreaObj.getWorkArea();
091 this.departmentObj = TkServiceLocator.getDepartmentService().getDepartment(workAreaObj.getDept(), TKUtils.getCurrentDate());
092 this.department = workAreaObj.getDept();
093 }
094 }
095
096 public String getHrRolesId() {
097 return hrRolesId;
098 }
099 public void setHrRolesId(String hrRolesId) {
100 this.hrRolesId = hrRolesId;
101 }
102 public String getPrincipalId() {
103 return principalId;
104 }
105 public void setPrincipalId(String principalId) {
106 this.principalId = principalId;
107 setPerson(KimApiServiceLocator.getPersonService().getPerson(this.principalId));
108 }
109 public String getRoleName() {
110 return roleName;
111 }
112 public void setRoleName(String roleName) {
113 this.roleName = roleName;
114 }
115 public String getUserPrincipalId() {
116 return userPrincipalId;
117 }
118 public void setUserPrincipalId(String userPrincipalId) {
119 this.userPrincipalId = userPrincipalId;
120 }
121 public Long getWorkArea() {
122 return workArea;
123 }
124 public void setWorkArea(Long workArea) {
125 this.workArea = workArea;
126 }
127 public String getDepartment() {
128 return department;
129 }
130 public void setDepartment(String department) {
131 this.department = department;
132 }
133
134 public Date getEffectiveDate() {
135 return effectiveDate;
136 }
137 public void setEffectiveDate(Date effectiveDate) {
138 this.effectiveDate = effectiveDate;
139 }
140 public Timestamp getTimestamp() {
141 return timestamp;
142 }
143 public void setTimestamp(Timestamp timestamp) {
144 this.timestamp = timestamp;
145 }
146 public boolean isActive() {
147 return active;
148 }
149 public void setActive(boolean active) {
150 this.active = active;
151 }
152 public Person getPerson() {
153 return person;
154 }
155 public void setPerson(Person person) {
156 this.person = person;
157 }
158 public Long getHrDeptId() {
159 return hrDeptId;
160 }
161 public void setHrDeptId(Long hrDeptId) {
162 this.hrDeptId = hrDeptId;
163 }
164
165 public String getChart() {
166 return chart;
167 }
168
169 public void setChart(String chart) {
170 this.chart = chart;
171 }
172
173 /**
174 * This method supports maintenance and lookup pages.
175 */
176 public String getUserName() {
177 if (person == null) {
178 person = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
179 }
180
181 return (person != null) ? person.getName() : "";
182 }
183
184 public void setPositionNumber(String positionNumber) {
185 this.positionNumber = positionNumber;
186 }
187
188 public String getPositionNumber() {
189 return positionNumber;
190 }
191
192 public Date getExpirationDate() {
193 return expirationDate;
194 }
195
196 public void setExpirationDate(Date expirationDate) {
197 this.expirationDate = expirationDate;
198 }
199
200 public void setPositionObj(Position positionObj) {
201 this.positionObj = positionObj;
202 }
203
204 public Position getPositionObj() {
205 return positionObj;
206 }
207
208 @Override
209 public String getUniqueKey() {
210 return principalId + "_" + positionNumber != null ? positionNumber.toString() : "" +"_"+
211 roleName + "_" + workArea != null ? workArea.toString() : "" + "_" +
212 department + "_" + chart;
213 }
214
215 @Override
216 public String getId() {
217 return getHrRolesId();
218 }
219
220 @Override
221 public void setId(String id) {
222 setHrRolesId(id);
223 }
224
225 public Location getLocationObj() {
226 return locationObj;
227 }
228
229 public void setLocationObj(Location locationObj) {
230 this.locationObj = locationObj;
231 }
232 }