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.principal;
017    
018    import java.sql.Date;
019    
020    import org.kuali.hr.core.KPMEConstants;
021    import org.kuali.hr.lm.leaveplan.LeavePlan;
022    import org.kuali.hr.time.HrBusinessObject;
023    import org.kuali.hr.time.calendar.Calendar;
024    import org.kuali.rice.kim.api.identity.Person;
025    import org.kuali.rice.kim.api.services.KimApiServiceLocator;
026    
027    public class PrincipalHRAttributes extends HrBusinessObject {
028    
029            private static final long serialVersionUID = 6843318899816055301L;
030    
031            public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "PrincipalHRAttributes";
032    
033            private String hrPrincipalAttributeId;
034            private String principalId;
035            private String leaveCalendar;
036            private String payCalendar;
037            private String leavePlan;
038            private Date serviceDate;
039            private boolean fmlaEligible;
040            private boolean workersCompEligible;
041            private String timezone;
042            private Boolean history;
043            // KPME-1268 Kagata added recordTime and recordLeave variables
044            // KPME-1676 
045    //      private String recordTime;
046    //      private String recordLeave;
047            
048            private transient Calendar calendar;
049            private transient Calendar leaveCalObj;
050            private transient Person person;
051            private transient LeavePlan leavePlanObj;
052    
053    
054            public String getPrincipalId() {
055                    return principalId;
056            }
057    
058            public void setPrincipalId(String principalId) {
059                    this.principalId = principalId;
060                    person = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
061            }
062    
063            public String getName() {
064                     if (person == null) {
065                        person = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
066                }
067                return (person != null) ? person.getName() : "";
068            }
069    
070            public String getPayCalendar() {
071                    return payCalendar;
072            }
073    
074            public void setPayCalendar(String payCalendar) {
075                    this.payCalendar = payCalendar;
076            }
077    
078            public String getLeavePlan() {
079                    return leavePlan;
080            }
081    
082            public void setLeavePlan(String leavePlan) {
083                    this.leavePlan = leavePlan;
084            }
085    
086            public Date getServiceDate() {
087                    return serviceDate;
088            }
089    
090            public void setServiceDate(Date serviceDate) {
091                    this.serviceDate = serviceDate;
092            }
093    
094            public boolean isFmlaEligible() {
095                    return fmlaEligible;
096            }
097    
098            public void setFmlaEligible(boolean fmlaEligible) {
099                    this.fmlaEligible = fmlaEligible;
100            }
101    
102            public boolean isWorkersCompEligible() {
103                    return workersCompEligible;
104            }
105    
106            public void setWorkersCompEligible(boolean workersCompEligible) {
107                    this.workersCompEligible = workersCompEligible;
108            }
109    
110            public String getTimezone() {
111                    return timezone;
112            }
113    
114            public void setTimezone(String timezone) {
115                    this.timezone = timezone;
116            }
117    
118            public Calendar getCalendar() {
119                    return calendar;
120            }
121    
122            public void setCalendar(Calendar calendar) {
123                    this.calendar = calendar;
124            }
125    
126            public Person getPerson() {
127                    return person;
128            }
129    
130            public void setPerson(Person person) {
131                    this.person = person;
132            }
133    
134            public LeavePlan getLeavePlanObj() {
135                    return leavePlanObj;
136            }
137    
138            public void setLeavePlanObj(LeavePlan leavePlanObj) {
139                    this.leavePlanObj = leavePlanObj;
140            }
141    
142            @Override
143            protected String getUniqueKey() {
144                    return principalId + "_" + payCalendar == null ? "" : payCalendar + "_"
145                                    + leaveCalendar == null ? "" : leaveCalendar;
146            }
147    
148            public String getLeaveCalendar() {
149                    return leaveCalendar;
150            }
151    
152            public void setLeaveCalendar(String leaveCalendar) {
153                    this.leaveCalendar = leaveCalendar;
154            }
155    
156            @Override
157            public String getId() {
158                    return this.getHrPrincipalAttributeId();
159            }
160            @Override
161            public void setId(String id) {
162                    setHrPrincipalAttributeId(id);
163            }
164    
165            public Calendar getLeaveCalObj() {
166                    return leaveCalObj;
167            }
168    
169            public void setLeaveCalObj(Calendar leaveCalObj) {
170                    this.leaveCalObj = leaveCalObj;
171            }
172    
173            public String getHrPrincipalAttributeId() {
174                    return hrPrincipalAttributeId;
175            }
176    
177            public void setHrPrincipalAttributeId(String hrPrincipalAttributeId) {
178                    this.hrPrincipalAttributeId = hrPrincipalAttributeId;
179            }
180    
181            public Boolean getHistory() {
182                    return history;
183            }
184    
185            public void setHistory(Boolean history) {
186                    this.history = history;
187            }
188    }