View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.tklm.time.rules.clocklocation;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.kpme.core.authorization.DepartmentalRule;
22  import org.kuali.kpme.core.department.Department;
23  import org.kuali.kpme.core.job.Job;
24  import org.kuali.kpme.core.workarea.WorkArea;
25  import org.kuali.kpme.tklm.api.time.rules.clocklocation.ClockLocationRuleContract;
26  import org.kuali.kpme.tklm.common.TkConstants;
27  import org.kuali.kpme.tklm.time.rules.TkRule;
28  import org.kuali.kpme.tklm.time.service.TkServiceLocator;
29  import org.kuali.rice.kim.api.identity.Person;
30  
31  import com.google.common.collect.ImmutableList;
32  
33  public class ClockLocationRule extends TkRule implements DepartmentalRule, ClockLocationRuleContract {
34  
35  	private static final long serialVersionUID = 959554402289679184L;
36  
37  	public static final String CACHE_NAME = TkConstants.CacheNamespace.NAMESPACE_PREFIX + "ClockLocationRule";
38  	//KPME-2273/1965 Primary Business Keys List. 
39  	public static final ImmutableList<String> EQUAL_TO_FIELDS = new ImmutableList.Builder<String>()
40              .add("dept")
41              .add("workArea")
42              .add("jobNumber")
43              .add("principalId")
44              .build();
45  
46  
47  	private String tkClockLocationRuleId;
48  
49  	private Department department;
50  	private String dept;
51  	private String hrDeptId;
52  	
53  	private Long workArea;
54  	private String tkWorkAreaId;
55  	private String principalId;
56  	private Long jobNumber;
57  	private String hrJobId;
58  
59  	private List<ClockLocationRuleIpAddress> ipAddresses = new ArrayList<ClockLocationRuleIpAddress>();
60  	private String userPrincipalId;
61  	private Boolean history;
62  
63  	private WorkArea workAreaObj;
64  	private Job job;
65  	private transient Person principal;
66  
67  	public Long getWorkArea() {
68  		return workArea;
69  	}
70  
71  	public void setWorkArea(Long workArea) {
72  		this.workArea = workArea;
73  	}
74  
75  	public String getPrincipalId() {
76  		return principalId;
77  	}
78  
79  	public void setPrincipalId(String principalId) {
80  		this.principalId = principalId;
81  	}
82  
83  	public String getUserPrincipalId() {
84  		return userPrincipalId;
85  	}
86  
87  	public void setUserPrincipalId(String userPrincipalId) {
88  		this.userPrincipalId = userPrincipalId;
89  	}
90  
91  	public Long getJobNumber() {
92  		return jobNumber;
93  	}
94  
95  	public void setJobNumber(Long jobNumber) {
96  		this.jobNumber = jobNumber;
97  	}
98  	public Department getDepartment() {
99  	    return department;
100 	}
101 
102 	public void setDepartment(Department department) {
103 	    this.department = department;
104 	}
105 
106 	public WorkArea getWorkAreaObj() {
107 	    return workAreaObj;
108 	}
109 
110 	public void setWorkAreaObj(WorkArea workAreaObj) {
111 	    this.workAreaObj = workAreaObj;
112 	}
113 
114 	public Job getJob() {
115 	    return job;
116 	}
117 
118 	public void setJob(Job job) {
119 	    this.job = job;
120 	}
121 
122 	public String getTkClockLocationRuleId() {
123 		return tkClockLocationRuleId;
124 	}
125 
126 	public void setTkClockLocationRuleId(String tkClockLocationRuleId) {
127 		this.tkClockLocationRuleId = tkClockLocationRuleId;
128 	}
129 
130 	public String getDept() {
131 		return dept;
132 	}
133 
134 	public void setDept(String dept) {
135 		this.dept = dept;
136 	}
137 
138 	public void setHistory(Boolean history) {
139 		this.history = history;
140 	}
141 
142 	public Boolean getHistory() {
143 		return history;
144 	}
145 
146 	public Person getPrincipal() {
147 		return principal;
148 	}
149 
150 	public void setPrincipal(Person principal) {
151 		this.principal = principal;
152 	}
153 
154 	public String getHrDeptId() {
155 		return hrDeptId;
156 	}
157 
158 	public void setHrDeptId(String hrDeptId) {
159 		this.hrDeptId = hrDeptId;
160 	}
161 
162 	public String getTkWorkAreaId() {
163 		return tkWorkAreaId;
164 	}
165 
166 	public void setTkWorkAreaId(String tkWorkAreaId) {
167 		this.tkWorkAreaId = tkWorkAreaId;
168 	}
169 
170 	public String getHrJobId() {
171 		return hrJobId;
172 	}
173 
174 	public void setHrJobId(String hrJobId) {
175 		this.hrJobId = hrJobId;
176 	}
177 
178 	@Override
179 	public String getUniqueKey() {
180 		String clockLocKey = getDept()+"_"+getPrincipalId()+"_"+
181 		(getJobNumber()!=null ? getJobNumber().toString(): "") +"_" + 
182 		(getWorkArea() !=null ? getWorkArea().toString() : "");
183 		
184 		return clockLocKey;
185 	}
186 
187 	@Override
188 	public String getId() {
189 		return getTkClockLocationRuleId();
190 	}
191 
192 	@Override
193 	public void setId(String id) {
194 		setTkClockLocationRuleId(id);
195 	}
196 
197 	public List<ClockLocationRuleIpAddress> getIpAddresses() {
198 		if(ipAddresses.isEmpty()) {
199 			TkServiceLocator.getClockLocationRuleService().populateIPAddressesForCLR(this);
200 		}
201 		return ipAddresses;
202 	}
203 
204 	public void setIpAddresses(List<ClockLocationRuleIpAddress> ipAddresses) {
205 		this.ipAddresses = ipAddresses;
206 	}
207 	// for lookup and inquiry display only
208 	public String getIpAddressesString() {
209 		String aString = "";
210 		for(ClockLocationRuleIpAddress ip : this.getIpAddresses()) {
211 			aString += ip.getIpAddress() + ", ";
212 		}
213 		return aString;
214 	}
215 
216 
217 }