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