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.job;
017    
018    import java.math.BigDecimal;
019    import java.math.RoundingMode;
020    import java.util.Arrays;
021    import java.util.Collections;
022    import java.util.List;
023    
024    import org.kuali.hr.core.KPMEConstants;
025    import org.kuali.hr.lm.earncodesec.EarnCodeSecurity;
026    import org.kuali.hr.location.Location;
027    import org.kuali.hr.paygrade.PayGrade;
028    import org.kuali.hr.time.HrBusinessObject;
029    import org.kuali.hr.time.assignment.Assignment;
030    import org.kuali.hr.time.department.Department;
031    import org.kuali.hr.time.paytype.PayType;
032    import org.kuali.hr.time.position.Position;
033    import org.kuali.hr.time.salgroup.SalGroup;
034    import org.kuali.hr.time.util.TkConstants;
035    import org.kuali.rice.kim.api.identity.Person;
036    import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName;
037    import org.kuali.rice.kim.api.services.KimApiServiceLocator;
038    
039    public class Job extends HrBusinessObject {
040    
041            private static final long serialVersionUID = 1369595897637935064L;
042    
043            public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "Job";
044        private static final String[] PRIVATE_CACHES_FOR_FLUSH = {Job.CACHE_NAME, Assignment.CACHE_NAME};
045        public static final List<String> CACHE_FLUSH = Collections.unmodifiableList(Arrays.asList(PRIVATE_CACHES_FOR_FLUSH));
046            
047            private String location;
048            private String hrPayType;
049            private String payGrade;
050            private BigDecimal standardHours;
051            private String hrJobId;
052            private String principalId;
053            private String firstName;
054            private String lastName;
055            private String principalName;
056            private Long jobNumber;
057            private String dept;
058            private String hrSalGroup;
059            private Boolean primaryIndicator;
060            private Boolean history;
061            private BigDecimal compRate = new BigDecimal(0);
062            private String positionNumber;
063            
064            private String hrDeptId;
065            private String hrPayTypeId;
066            private boolean eligibleForLeave;
067            
068            private transient Person principal;
069            private transient Department deptObj;
070            private PayType payTypeObj;
071            private transient Location locationObj;
072        private transient PayGrade payGradeObj;
073        private transient SalGroup salGroupObj;
074        private transient Position positionObj;
075        
076        private BigDecimal fte = new BigDecimal(0); //kpme1465, chen
077        private String flsaStatus;
078        
079            public String getFlsaStatus() {
080                    return flsaStatus;
081            }
082    
083            public void setFlsaStatus(String flsaStatus) {
084                    this.flsaStatus = flsaStatus;
085            }
086    
087            public BigDecimal getFte() {
088                    if ( this.standardHours != null ) {
089                            return this.standardHours.divide(new BigDecimal(40)).setScale(2, RoundingMode.HALF_EVEN);
090                    } else {
091                            return fte;
092                    }
093            }
094    
095            public void setFte() {
096                    if ( this.standardHours != null ) {
097                            this.fte = this.standardHours.divide(new BigDecimal(40)).setScale(2, RoundingMode.HALF_EVEN);
098                    } else {
099                            this.fte = new BigDecimal(0).setScale(2);
100                    }
101            }
102            
103            public String getPayGrade() {
104                    return payGrade;
105            }
106    
107            public void setPayGrade(String payGrade) {
108                    this.payGrade = payGrade;
109            }
110    
111            public BigDecimal getStandardHours() {
112                    return standardHours;
113            }
114    
115            public void setStandardHours(BigDecimal standardHours) {
116                    this.standardHours = standardHours;
117            }
118    
119            public String getPrincipalId() {
120                    return principalId;
121            }
122    
123            public void setPrincipalId(String principalId) {
124                    this.principalId = principalId;
125            }
126            
127            public String getFirstName() {
128                    return firstName;
129            }
130    
131            public void setFirstName(String firstName) {
132                    this.firstName = firstName;
133            }
134    
135            public String getLastName() {
136                    return lastName;
137            }
138    
139            public void setLastName(String lastName) {
140                    this.lastName = lastName;
141            }
142    
143            public String getName() {
144                    if (principal == null) {
145                principal = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
146                }
147                return (principal != null) ? principal.getName() : "";
148            }
149    
150            public String getPrincipalName() {
151                    if(principalName == null && !this.getPrincipalId().isEmpty()) {
152                            EntityNamePrincipalName aPerson = KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(getPrincipalId());
153                            if (aPerson != null && aPerson.getDefaultName() != null) {
154                    setPrincipalName(aPerson.getDefaultName().getCompositeName());
155                }
156                    }
157                    return principalName;
158            }
159    
160            public void setPrincipalName(String principalName) {
161                    this.principalName = principalName;
162            }
163    
164            public Long getJobNumber() {
165                    return jobNumber;
166            }
167    
168            public void setJobNumber(Long jobNumber) {
169                    this.jobNumber = jobNumber;
170            }
171    
172            public Boolean getHistory() {
173                    return history;
174            }
175    
176            public void setHistory(Boolean history) {
177                    this.history = history;
178            }
179            
180            public void setLocation(String location) {
181                    this.location = location;
182            }
183    
184            public String getLocation() {
185                    return location;
186            }
187            
188            public String getHrPayType() {
189                    return hrPayType;
190            }
191    
192            public void setHrPayType(String hrPayType) {
193                    this.hrPayType = hrPayType;
194            }
195    
196            public String getHrJobId() {
197                    return hrJobId;
198            }
199    
200            public void setHrJobId(String hrJobId) {
201                    this.hrJobId = hrJobId;
202            }
203    
204            public String getDept() {
205                    return dept;
206            }
207    
208            public void setDept(String dept) {
209                    this.dept = dept;
210            }
211    
212            public String getHrSalGroup() {
213                    return hrSalGroup;
214            }
215    
216            public void setHrSalGroup(String hrSalGroup) {
217                    this.hrSalGroup = hrSalGroup;
218            }
219    
220    
221            public BigDecimal getCompRate() {
222                    return compRate;
223            }
224    
225    
226            public void setCompRate(BigDecimal compRate) {
227                    if(compRate != null){
228                            this.compRate = compRate.setScale(TkConstants.BIG_DECIMAL_SCALE);
229                    } else {
230                            this.compRate = compRate;
231                    }
232            }
233    
234            public Department getDeptObj() {
235                    return deptObj;
236            }
237    
238    
239            public void setDeptObj(Department deptObj) {
240                    this.deptObj = deptObj;
241            }
242    
243    
244            public PayType getPayTypeObj() {
245                    return payTypeObj;
246            }
247    
248    
249            public void setPayTypeObj(PayType payTypeObj) {
250                    this.payTypeObj = payTypeObj;
251            }
252    
253    
254            public Person getPrincipal() {
255                    return principal;
256            }
257    
258    
259            public void setPrincipal(Person principal) {
260                    this.principal = principal;
261            }
262    
263    
264            public void setPrimaryIndicator(Boolean primaryIndicator) {
265                    this.primaryIndicator = primaryIndicator;
266            }
267    
268    
269            public Boolean getPrimaryIndicator() {
270                    return primaryIndicator;
271            }
272    
273            public Location getLocationObj() {
274                    return locationObj;
275            }
276    
277            public void setLocationObj(Location locationObj) {
278                    this.locationObj = locationObj;
279            }
280    
281            public PayGrade getPayGradeObj() {
282                    return payGradeObj;
283            }
284    
285            public void setPayGradeObj(PayGrade payGradeObj) {
286                    this.payGradeObj = payGradeObj;
287            }
288    
289            public SalGroup getSalGroupObj() {
290                    return salGroupObj;
291            }
292    
293            public void setSalGroupObj(SalGroup salGroupObj) {
294                    this.salGroupObj = salGroupObj;
295            }
296    
297            public void setPositionNumber(String positionNumber) {
298                    this.positionNumber = positionNumber;
299            }
300    
301            public String getPositionNumber() {
302                    return positionNumber;
303            }
304    
305            public void setPositionObj(Position positionObj) {
306                    this.positionObj = positionObj;
307            }
308    
309            public Position getPositionObj() {
310                    return positionObj;
311            }
312    
313            public String getHrDeptId() {
314                    return hrDeptId;
315            }
316    
317            public void setHrDeptId(String hrDeptId) {
318                    this.hrDeptId = hrDeptId;
319            }
320    
321            public String getHrPayTypeId() {
322                    return hrPayTypeId;
323            }
324    
325            public void setHrPayTypeId(String hrPayTypeId) {
326                    this.hrPayTypeId = hrPayTypeId;
327            }
328    
329            @Override
330            public String getUniqueKey() {
331                    return getPrincipalId() + "_" + getJobNumber();
332            }
333    
334            @Override
335            public String getId() {
336                    return getHrJobId();
337            }
338    
339            @Override
340            public void setId(String id) {
341                    setHrJobId(id);
342            }
343            public boolean isEligibleForLeave() {
344                    return eligibleForLeave;
345            }
346    
347            public void setEligibleForLeave(boolean eligibleForLeave) {
348                    this.eligibleForLeave = eligibleForLeave;
349            }
350            
351    }