View Javadoc

1   /**
2    * Copyright 2004-2014 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.clocklog;
17  
18  import java.sql.Timestamp;
19  import java.util.Date;
20  
21  import org.joda.time.DateTime;
22  import org.kuali.kpme.core.job.Job;
23  import org.kuali.kpme.core.task.Task;
24  import org.kuali.kpme.core.workarea.WorkArea;
25  import org.kuali.kpme.tklm.api.time.clocklog.ClockLogContract;
26  import org.kuali.kpme.tklm.common.TkConstants;
27  import org.kuali.rice.kim.api.identity.Person;
28  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
29  
30  import com.google.common.collect.ImmutableList;
31  
32  public class ClockLog extends PersistableBusinessObjectBase implements ClockLogContract {
33  
34  	private static final long serialVersionUID = -6928657854016622568L;
35  	//KPME-2273/1965 Primary Business Keys List.	
36  	public static final ImmutableList<String> EQUAL_TO_FIELDS = new ImmutableList.Builder<String>()
37  		            .add("task")
38  		            .add("principalId")
39  		            .add("workArea")
40  		            .add("jobNumber")
41  		            .build();
42  	
43  	private String tkClockLogId;
44  	private String documentId;
45      private String principalId;
46      private Long jobNumber;
47      private Long workArea;
48      private Long task;
49      private Timestamp clockTimestamp;
50      private String clockTimestampTimezone;
51      private String clockAction;
52      private String ipAddress;
53      private String userPrincipalId;
54      private Timestamp timestamp;
55      private boolean unapprovedIP = false;
56  
57      private boolean clockedByMissedPunch;
58  
59      private transient Job job;
60      private transient WorkArea workAreaObj;
61      private transient Task taskObj;
62  
63      private transient Person principal;
64      
65  	public String getTkClockLogId() {
66  		return tkClockLogId;
67  	}
68  
69  	public void setTkClockLogId(String tkClockLogId) {
70  		this.tkClockLogId = tkClockLogId;
71  	}
72  	
73  	public String getDocumentId() {
74  		return documentId;
75  	}
76  
77  	public void setDocumentId(String documentId) {
78  		this.documentId = documentId;
79  	}
80  
81  	public String getPrincipalId() {
82          return principalId;
83      }
84  
85      public void setPrincipalId(String principalId) {
86          this.principalId = principalId;
87      }
88  
89      public Long getJobNumber() {
90          return jobNumber;
91      }
92  
93      public void setJobNumber(Long jobNumber) {
94          this.jobNumber = jobNumber;
95      }
96  
97      public Timestamp getClockTimestamp() {
98          return clockTimestamp;
99      }
100 
101     public void setClockTimestamp(Timestamp clockTimestamp) {
102         this.clockTimestamp = clockTimestamp;
103     }
104     
105     public DateTime getClockDateTime() {
106     	return clockTimestamp != null? new DateTime(clockTimestamp.getTime()) : null;
107     }
108     
109     public void setClockDateTime(DateTime clockDateTime) {
110     	clockTimestamp = clockDateTime != null ? new Timestamp(clockDateTime.getMillis()) : null;
111     }
112 
113     public String getClockAction() {
114         return clockAction;
115     }
116 
117     public void setClockAction(String clockAction) {
118         this.clockAction = clockAction;
119     }
120 
121     public String getIpAddress() {
122         return ipAddress;
123     }
124 
125     public void setIpAddress(String ipAddress) {
126         this.ipAddress = ipAddress;
127     }
128 
129     public String getUserPrincipalId() {
130         return userPrincipalId;
131     }
132 
133     public void setUserPrincipalId(String userPrincipalId) {
134         this.userPrincipalId = userPrincipalId;
135     }
136 
137     public Timestamp getTimestamp() {
138         return timestamp;
139     }
140 
141     public void setTimestamp(Timestamp timestamp) {
142         this.timestamp = timestamp;
143     }
144 
145     public String getClockTimestampTimezone() {
146         return clockTimestampTimezone;
147     }
148 
149     public void setClockTimestampTimezone(String clockTimestampTimezone) {
150         this.clockTimestampTimezone = clockTimestampTimezone;
151     }
152 
153     /**
154      * TODO: Fix this - may need to return multiple actions, depending on how we want the system to work.
155      * @return
156      */
157     public String getNextValidClockAction() {
158 	String ret;
159 
160 	if (this.getClockAction().equals(TkConstants.CLOCK_IN)) {
161 	    ret = TkConstants.CLOCK_OUT;
162 	} else if (this.getClockAction().equals(TkConstants.CLOCK_OUT)) {
163 	    ret = TkConstants.CLOCK_IN;
164 	} else if (this.getClockAction().equals(TkConstants.LUNCH_IN)) {
165 	    ret = TkConstants.LUNCH_OUT;
166 	} else if (this.getClockAction().equals(TkConstants.LUNCH_OUT)) {
167 	    ret = TkConstants.LUNCH_IN;
168 	} else {
169 	    ret = TkConstants.CLOCK_IN;
170 	}
171 
172 	return ret;
173     }
174 	
175 	public Job getJob() {
176 		return job;
177 	}
178 
179 	public void setJob(Job job) {
180 		this.job = job;
181 	}
182 
183 	public WorkArea getWorkAreaObj() {
184 		return workAreaObj;
185 	}
186 
187 	public void setWorkAreaObj(WorkArea workAreaObj) {
188 		this.workAreaObj = workAreaObj;
189 	}
190 
191 	public Task getTaskObj() {
192 		return taskObj;
193 	}
194 
195 	public void setTaskObj(Task taskObj) {
196 		this.taskObj = taskObj;
197 	}
198 
199 	public void setWorkArea(Long workArea) {
200 		this.workArea = workArea;
201 	}
202 
203 	public void setTask(Long task) {
204 		this.task = task;
205 	}
206 	public Long getWorkArea() {
207 		return workArea;
208 	}
209 	public Long getTask() {
210 		return task;
211 	}
212 
213 	public Person getPrincipal() {
214 		return principal;
215 	}
216 
217 	public void setPrincipal(Person principal) {
218 		this.principal = principal;
219 	}
220 
221 	public boolean isClockedByMissedPunch() {
222 		return clockedByMissedPunch;
223 	}
224 
225 	public void setClockedByMissedPunch(boolean clockedByMissedPunch) {
226 		this.clockedByMissedPunch = clockedByMissedPunch;
227 	}
228 
229 	public boolean isUnapprovedIP() {
230 		return unapprovedIP;
231 	}
232 
233 	public void setUnapprovedIP(boolean unapprovedIP) {
234 		this.unapprovedIP = unapprovedIP;
235 	}
236 	
237 }