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.leave.calendar;
17  
18  import org.joda.time.LocalDate;
19  import org.kuali.kpme.core.api.assignment.Assignable;
20  import org.kuali.kpme.core.api.assignment.Assignment;
21  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
22  import org.kuali.kpme.core.document.calendar.CalendarDocument;
23  import org.kuali.kpme.tklm.api.leave.block.LeaveBlock;
24  import org.kuali.kpme.tklm.api.leave.calendar.LeaveCalendarDocumentContract;
25  import org.kuali.kpme.tklm.leave.workflow.LeaveCalendarDocumentHeader;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  import java.util.Map;
30  
31  public class LeaveCalendarDocument extends CalendarDocument implements Assignable, LeaveCalendarDocumentContract {
32  	private static final long serialVersionUID = -5029062030186479210L;
33  
34      private LeaveCalendarDocumentHeader documentHeader;
35  	/**
36  	 * This static member is needed by document search, to trigger the correct calendar document
37  	 * opening when clicking on a doc id link in the search results.
38  	 * It is distinguished from "HrConstants.LEAVE_CALENDAR_TYPE".
39  	 */
40  	public static final String LEAVE_CALENDAR_DOCUMENT_TYPE = "LeaveCalendarDocument";
41  
42  	List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>();
43  
44  	public LeaveCalendarDocument(CalendarEntry calendarEntry) {
45  		setCalendarEntry(calendarEntry);
46  	}
47  
48  	public LeaveCalendarDocument(LeaveCalendarDocumentHeader documentHeader) {
49          this.documentHeader = documentHeader;
50  		setCalendarType(LEAVE_CALENDAR_DOCUMENT_TYPE);
51  	}
52  
53      @Override
54  	public LeaveCalendarDocumentHeader getDocumentHeader() {
55  		return documentHeader;
56  	}
57  
58  	public void setDocumentHeader(
59              LeaveCalendarDocumentHeader documentHeader) {
60  		this.documentHeader = documentHeader;
61  	}
62  
63  	public List<LeaveBlock> getLeaveBlocks() {
64  		return leaveBlocks;
65  	}
66  
67  	public void setLeaveBlocks(List<LeaveBlock> leaveBlocks) {
68  		this.leaveBlocks = leaveBlocks;
69  	}
70  
71  
72  
73      @Override
74  	public String getPrincipalId() {
75          return  getDocumentHeader() == null ? null : getDocumentHeader().getPrincipalId();
76  	}
77  
78      @Override
79  	public String getDocumentId() {
80          return getDocumentHeader() == null ? null : getDocumentHeader().getDocumentId();
81  	}
82  
83      @Override
84      public List<Assignment> getAssignments() {
85          return getAllAssignments();
86      }
87  	
88  }