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.leavecalendar; 017 018 import java.io.Serializable; 019 import java.util.ArrayList; 020 import java.util.LinkedList; 021 import java.util.List; 022 023 import org.kuali.hr.core.document.calendar.CalendarDocumentContract; 024 import org.kuali.hr.lm.leaveblock.LeaveBlock; 025 import org.kuali.hr.lm.workflow.LeaveCalendarDocumentHeader; 026 import org.kuali.hr.time.assignment.Assignment; 027 import org.kuali.hr.time.calendar.CalendarEntries; 028 029 public class LeaveCalendarDocument implements CalendarDocumentContract, Serializable { 030 031 public static final String LEAVE_CALENDAR_DOCUMENT_TYPE = "LeaveCalendarDocument"; 032 033 LeaveCalendarDocumentHeader documentHeader; 034 List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>(); 035 private List<Assignment> assignments = new LinkedList<Assignment>(); 036 private CalendarEntries calendarEntry; 037 038 public LeaveCalendarDocument(CalendarEntries calendarEntry) { 039 this.calendarEntry = calendarEntry; 040 } 041 042 public LeaveCalendarDocument( 043 LeaveCalendarDocumentHeader documentHeader) { 044 this.documentHeader = documentHeader; 045 } 046 047 @Override 048 public LeaveCalendarDocumentHeader getDocumentHeader() { 049 return documentHeader; 050 } 051 052 public void setDocumentHeader( 053 LeaveCalendarDocumentHeader documentHeader) { 054 this.documentHeader = documentHeader; 055 } 056 057 public List<LeaveBlock> getLeaveBlocks() { 058 return leaveBlocks; 059 } 060 061 public void setLeaveBlocks(List<LeaveBlock> leaveBlocks) { 062 this.leaveBlocks = leaveBlocks; 063 } 064 065 @Override 066 public CalendarEntries getCalendarEntry() { 067 return calendarEntry; 068 } 069 070 public void setCalendarEntry(CalendarEntries calendarEntry) { 071 this.calendarEntry = calendarEntry; 072 } 073 074 public String getPrincipalId() { 075 return getDocumentHeader().getPrincipalId(); 076 } 077 078 public String getDocumentId() { 079 if (getDocumentHeader() != null) { 080 return getDocumentHeader().getDocumentId(); 081 } else { 082 return null; 083 } 084 } 085 086 @Override 087 public List<Assignment> getAssignments() { 088 return assignments; 089 } 090 091 public void setAssignments(List<Assignment> assignments) { 092 this.assignments = assignments; 093 } 094 095 @Override 096 public java.sql.Date getAsOfDate(){ 097 return new java.sql.Date(getCalendarEntry().getBeginPeriodDateTime().getTime()); 098 } 099 100 101 }