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.common;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.joda.time.DateTime;
20  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
21  import org.kuali.kpme.core.document.calendar.CalendarDocument;
22  import org.kuali.rice.core.api.config.property.ConfigContext;
23  
24  import java.util.*;
25  
26  public abstract class CalendarApprovalForm extends ApprovalForm {
27  	
28  	private static final long serialVersionUID = -173408280988754540L;
29  	
30  	public static final String ORDER_BY_PRINCIPAL = "principalName";
31      public static final String ORDER_BY_DOCID = "documentId";
32      public static final String ORDER_BY_STATUS = "Status";
33      public static final String ORDER_BY_WORKAREA = "WorkArea";
34      
35      private String hrCalendarEntryId;
36      
37      private String prevHrCalendarEntryId;
38      private String nextHrCalendarEntryId;
39      
40  	private Date beginCalendarEntryDate;
41  	private Date endCalendarEntryDate;
42  	
43      private CalendarEntry calendarEntry;
44  	
45  	private List<String> calendarYears = new ArrayList<String>();
46      private Map<String,String> payPeriodsMap = new HashMap<String,String>();
47      
48      private String selectedCalendarYear;
49      private String selectedPayPeriod;
50      
51      private CalendarDocument calendarDocument;
52  
53      private String outputString;
54  
55      private String searchField;
56      private String searchTerm;
57  
58      private Integer resultSize = 0;
59      
60  	public String getHrCalendarEntryId() {
61  		return hrCalendarEntryId;
62  	}
63  
64  	public void setHrCalendarEntryId(String hrCalendarEntryId) {
65  		this.hrCalendarEntryId = hrCalendarEntryId;
66  	}
67  	
68  	public String getPrevHrCalendarEntryId() {
69  		return prevHrCalendarEntryId;
70  	}
71  
72  	public void setPrevHrCalendarEntryId(String prevHrCalendarEntryId) {
73  		this.prevHrCalendarEntryId = prevHrCalendarEntryId;
74  	}
75  
76  	public String getNextHrCalendarEntryId() {
77  		return nextHrCalendarEntryId;
78  	}
79  
80  	public void setNextHrCalendarEntryId(String nextHrCalendarEntryId) {
81  		this.nextHrCalendarEntryId = nextHrCalendarEntryId;
82  	}
83  
84  	public Date getBeginCalendarEntryDate() {
85  		return beginCalendarEntryDate;
86  	}
87  
88  	public void setBeginCalendarEntryDate(Date beginCalendarEntryDate) {
89  		this.beginCalendarEntryDate = beginCalendarEntryDate;
90  	}
91  
92  	public Date getEndCalendarEntryDate() {
93  		return endCalendarEntryDate;
94  	}
95  
96  	public void setEndCalendarEntryDate(Date endCalendarEntryDate) {
97  		this.endCalendarEntryDate = endCalendarEntryDate;
98  	}
99  
100 	public List<String> getCalendarYears() {
101 		return calendarYears;
102 	}
103 	
104 	public void setCalendarYears(List<String> calendarYears) {
105 		this.calendarYears = calendarYears;
106 	}
107 	
108 	public Map<String, String> getPayPeriodsMap() {
109 		return payPeriodsMap;
110 	}
111 	
112 	public void setPayPeriodsMap(Map<String, String> payPeriodsMap) {
113 		this.payPeriodsMap = payPeriodsMap;
114 	}
115 	
116     public CalendarEntry getCalendarEntry() {
117         return calendarEntry;
118     }
119 
120     public void setCalendarEntry(CalendarEntry calendarEntry) {
121         this.calendarEntry = calendarEntry;
122     }
123 	
124 	public String getSelectedCalendarYear() {
125 		return selectedCalendarYear;
126 	}
127 	
128 	public void setSelectedCalendarYear(String selectedCalendarYear) {
129 		this.selectedCalendarYear = selectedCalendarYear;
130 	}
131 	
132 	public String getSelectedPayPeriod() {
133 		return selectedPayPeriod;
134 	}
135 	
136 	public void setSelectedPayPeriod(String selectedPayPeriod) {
137 		this.selectedPayPeriod = selectedPayPeriod;
138 	}
139 
140 	public CalendarDocument getCalendarDocument() {
141 		return calendarDocument;
142 	}
143 
144 	public void setCalendarDocument(CalendarDocument calendarDocument) {
145 		this.calendarDocument = calendarDocument;
146 	}
147 
148 	public boolean isOnCurrentPeriod() {
149 		boolean isOnCurrentPeriod = false;
150 		
151 		if (getCalendarEntry() != null) {
152 			DateTime beginPeriodDateTime = getCalendarEntry().getBeginPeriodFullDateTime();
153 			DateTime endPeriodDateTime = getCalendarEntry().getEndPeriodFullDateTime();
154 			isOnCurrentPeriod = (beginPeriodDateTime.isEqualNow() || beginPeriodDateTime.isBeforeNow()) && endPeriodDateTime.isAfterNow();
155 		}
156 		
157 		return isOnCurrentPeriod;
158 	}
159 
160     public String getOutputString() {
161         return outputString;
162     }
163 
164     public void setOutputString(String outputString) {
165         this.outputString = outputString;
166     }
167 
168     public String getSearchField() {
169         return searchField;
170     }
171 
172     public void setSearchField(String searchField) {
173         this.searchField = searchField;
174     }
175 
176     public String getSearchTerm() {
177         return searchTerm;
178     }
179 
180     public void setSearchTerm(String searchTerm) {
181         this.searchTerm = searchTerm;
182     }
183 
184     public int getResultSize() {
185         return resultSize;
186     }
187 
188     public void setResultSize(Integer resultSize) {
189         this.resultSize = resultSize;
190     }
191     
192     public int getPageSize() {
193     	String parameterValue = ConfigContext.getCurrentContextConfig().getProperty("kpme.tklm.approval.page.size");
194     	Integer limit = 10;
195     	if(StringUtils.isNotBlank(parameterValue)) {
196     		limit = Integer.parseInt(ConfigContext.getCurrentContextConfig().getProperty("kpme.tklm.approval.page.size"));
197     	}
198     	return limit;
199     }
200 
201 }