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.lm.leaveblock;
017    
018    import java.sql.Timestamp;
019    
020    import org.kuali.hr.time.service.base.TkServiceLocator;
021    import org.kuali.hr.time.task.Task;
022    import org.kuali.hr.time.util.TKUtils;
023    import org.kuali.hr.time.util.TkConstants;
024    import org.kuali.hr.time.workarea.WorkArea;
025    
026    public class LeaveBlockHistory extends LeaveBlock {
027    
028            /**
029             * 
030             */
031            private static final long serialVersionUID = 1L;
032            private String lmLeaveBlockHistoryId;
033            private String action;
034            private String principalIdDeleted;
035            private Timestamp timestampDeleted;
036            
037            public LeaveBlockHistory() {
038            }
039    
040            public LeaveBlockHistory(LeaveBlock lb) {
041                    this.setLmLeaveBlockId(lb.getLmLeaveBlockId());
042                    this.setDocumentId(lb.getDocumentId());
043                    this.setAccrualCategory(lb.getAccrualCategory());
044                    this.setAccrualGenerated(lb.getAccrualGenerated());
045                    this.setApplyToYtdUsed(lb.getApplyToYtdUsed());
046                    this.setDescription(lb.getDescription());
047                    this.setLeaveAmount(lb.getLeaveAmount());
048                    this.setEarnCode(lb.getEarnCode());
049                    this.setLeaveDate(lb.getLeaveDate());
050                    this.setPrincipalId(lb.getPrincipalId());
051    //              this.setPrincipalIdModified(lb.getPrincipalIdModified());
052                    this.setRequestStatus(lb.getRequestStatus());
053                    this.setTimestamp(lb.getTimestamp());
054                    this.setTkAssignmentId(lb.getTkAssignmentId());
055                    this.setScheduleTimeOffId(lb.getScheduleTimeOffId());
056                    this.setLeaveBlockType(lb.getLeaveBlockType());
057                    this.setBeginTimestamp(lb.getBeginTimestamp());
058                    this.setEndTimestamp(lb.getEndTimestamp());
059            }
060            
061            
062            public String getLmLeaveBlockHistoryId() {
063                    return lmLeaveBlockHistoryId;
064            }
065    
066            public void setLmLeaveBlockHistoryId(String lmLeaveBlockHistoryId) {
067                    this.lmLeaveBlockHistoryId = lmLeaveBlockHistoryId;
068            }
069    
070            public String getAction() {
071                    return action;
072            }
073    
074            public void setAction(String action) {
075                    this.action = action;
076            }
077    
078            public String getPrincipalIdDeleted() {
079                    return principalIdDeleted;
080            }
081    
082            public void setPrincipalIdDeleted(String principalIdDeleted) {
083                    this.principalIdDeleted = principalIdDeleted;
084            }
085    
086            public Timestamp getTimestampDeleted() {
087                    return timestampDeleted;
088            }
089    
090            public void setTimestampDeleted(Timestamp timestampDeleted) {
091                    this.timestampDeleted = timestampDeleted;
092            }
093    
094            public String getAssignmentTitle() {
095                    StringBuilder b = new StringBuilder();
096                    LeaveBlock lb = TkServiceLocator.getLeaveBlockService().getLeaveBlock(super.getLmLeaveBlockId());
097                    if(lb != null){
098                            if (lb.getWorkArea() != null) {
099                                    WorkArea wa = TkServiceLocator.getWorkAreaService().getWorkArea(
100                                            lb.getWorkArea(), TKUtils.getCurrentDate());
101                                    if (wa != null) {
102                                            b.append(wa.getDescription());
103                                    }
104                                    Task task = TkServiceLocator.getTaskService().getTask(
105                                                    this.getTask(), this.getLeaveDate());
106                                    if (task != null) {
107                                            // do not display task description if the task is the default
108                                            // one
109                                            // default task is created in getTask() of TaskService
110                                            if (!task.getDescription()
111                                                    .equals(TkConstants.TASK_DEFAULT_DESP)) {
112                                                    b.append("-" + task.getDescription());
113                                            }
114                                    }
115                            }
116                    }
117                    return b.toString();
118            }
119    
120    }