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.clock.location;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.kuali.hr.core.KPMEConstants;
022 import org.kuali.hr.job.Job;
023 import org.kuali.hr.time.authorization.DepartmentalRule;
024 import org.kuali.hr.time.department.Department;
025 import org.kuali.hr.time.rule.TkRule;
026 import org.kuali.hr.time.service.base.TkServiceLocator;
027 import org.kuali.hr.time.workarea.WorkArea;
028 import org.kuali.rice.kim.api.identity.Person;
029
030 public class ClockLocationRule extends TkRule implements DepartmentalRule {
031
032 private static final long serialVersionUID = 959554402289679184L;
033
034 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "ClockLocationRule";
035
036 private String tkClockLocationRuleId;
037
038 private Department department;
039 private String dept;
040 private String hrDeptId;
041
042 private Long workArea;
043 private String tkWorkAreaId;
044 private String principalId;
045 private Long jobNumber;
046 private String hrJobId;
047
048 private List<ClockLocationRuleIpAddress> ipAddresses = new ArrayList<ClockLocationRuleIpAddress>();
049 private String userPrincipalId;
050 private Boolean history;
051
052 private WorkArea workAreaObj;
053 private Job job;
054 private transient Person principal;
055
056 public Long getWorkArea() {
057 return workArea;
058 }
059
060 public void setWorkArea(Long workArea) {
061 this.workArea = workArea;
062 }
063
064 public String getPrincipalId() {
065 return principalId;
066 }
067
068 public void setPrincipalId(String principalId) {
069 this.principalId = principalId;
070 }
071
072 public String getUserPrincipalId() {
073 return userPrincipalId;
074 }
075
076 public void setUserPrincipalId(String userPrincipalId) {
077 this.userPrincipalId = userPrincipalId;
078 }
079
080 public Long getJobNumber() {
081 return jobNumber;
082 }
083
084 public void setJobNumber(Long jobNumber) {
085 this.jobNumber = jobNumber;
086 }
087 public Department getDepartment() {
088 return department;
089 }
090
091 public void setDepartment(Department department) {
092 this.department = department;
093 }
094
095 public WorkArea getWorkAreaObj() {
096 return workAreaObj;
097 }
098
099 public void setWorkAreaObj(WorkArea workAreaObj) {
100 this.workAreaObj = workAreaObj;
101 }
102
103 public Job getJob() {
104 return job;
105 }
106
107 public void setJob(Job job) {
108 this.job = job;
109 }
110
111 public String getTkClockLocationRuleId() {
112 return tkClockLocationRuleId;
113 }
114
115 public void setTkClockLocationRuleId(String tkClockLocationRuleId) {
116 this.tkClockLocationRuleId = tkClockLocationRuleId;
117 }
118
119 public String getDept() {
120 return dept;
121 }
122
123 public void setDept(String dept) {
124 this.dept = dept;
125 }
126
127 public void setHistory(Boolean history) {
128 this.history = history;
129 }
130
131 public Boolean getHistory() {
132 return history;
133 }
134
135 public Person getPrincipal() {
136 return principal;
137 }
138
139 public void setPrincipal(Person principal) {
140 this.principal = principal;
141 }
142
143 public String getHrDeptId() {
144 return hrDeptId;
145 }
146
147 public void setHrDeptId(String hrDeptId) {
148 this.hrDeptId = hrDeptId;
149 }
150
151 public String getTkWorkAreaId() {
152 return tkWorkAreaId;
153 }
154
155 public void setTkWorkAreaId(String tkWorkAreaId) {
156 this.tkWorkAreaId = tkWorkAreaId;
157 }
158
159 public String getHrJobId() {
160 return hrJobId;
161 }
162
163 public void setHrJobId(String hrJobId) {
164 this.hrJobId = hrJobId;
165 }
166
167 @Override
168 public String getUniqueKey() {
169 String clockLocKey = getDept()+"_"+getPrincipalId()+"_"+
170 (getJobNumber()!=null ? getJobNumber().toString(): "") +"_" +
171 (getWorkArea() !=null ? getWorkArea().toString() : "");
172
173 return clockLocKey;
174 }
175
176 @Override
177 public String getId() {
178 return getTkClockLocationRuleId();
179 }
180
181 @Override
182 public void setId(String id) {
183 setTkClockLocationRuleId(id);
184 }
185
186 public List<ClockLocationRuleIpAddress> getIpAddresses() {
187 if(ipAddresses.isEmpty()) {
188 TkServiceLocator.getClockLocationRuleService().populateIPAddressesForCLR(this);
189 }
190 return ipAddresses;
191 }
192
193 public void setIpAddresses(List<ClockLocationRuleIpAddress> ipAddresses) {
194 this.ipAddresses = ipAddresses;
195 }
196 // for lookup and inquiry display only
197 public String getIpAddressesString() {
198 String aString = "";
199 for(ClockLocationRuleIpAddress ip : this.getIpAddresses()) {
200 aString += ip.getIpAddress() + ", ";
201 }
202 return aString;
203 }
204
205
206 }