001/** 002 * Copyright 2004-2014 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 */ 016package org.kuali.kpme.tklm.common; 017 018import org.apache.commons.lang.StringUtils; 019import org.joda.time.DateTime; 020import org.joda.time.format.DateTimeFormat; 021import org.joda.time.format.DateTimeFormatter; 022import org.kuali.kpme.core.api.calendar.entry.CalendarEntry; 023import org.kuali.kpme.core.web.KPMEForm; 024 025import java.util.*; 026 027public abstract class CalendarForm extends KPMEForm { 028 029 private static final long serialVersionUID = 7437602046032470340L; 030 031 private static final DateTimeFormatter SDF_NO_TZ = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss yyyy"); 032 033 private String prevDocumentId; 034 private String nextDocumentId; 035 036 private String hrCalendarEntryId; 037 038 private String prevHrCalendarEntryId; 039 private String nextHrCalendarEntryId; 040 041 private Date beginCalendarEntryDate; 042 private Date endCalendarEntryDate; 043 044 private CalendarEntry calendarEntry; 045 046 private List<String> calendarYears = new ArrayList<String>(); 047 private Map<String,String> payPeriodsMap = new HashMap<String,String>(); 048 049 private String selectedCalendarYear; 050 private String selectedPayPeriod; 051 052 private List<String> errorMessages = new ArrayList<String>(); 053 // Messages like: "you might lose leave if you don't act." or "you're over the limit - use / transfer / payout leave or risk forfeiting." i.e. just warns of an upcoming consequence 054 private List<String> warningMessages = new ArrayList<String>(); 055 // Messages like: "leave was forfeted on this calendar" i.e. reports what happened or presents additional info to user. 056 private List<String> infoMessages = new ArrayList<String>(); 057 // Messages like: "must approve transfer / payout doc ( or take other action ) before this calendar can be approved / submitted." i.e.: messages that informs about a required action. 058 private List<String> actionMessages = new ArrayList<String>(); 059 060 public String getNextDocumentId() { 061 return nextDocumentId; 062 } 063 064 public void setNextDocumentId(String nextDocumentId) { 065 this.nextDocumentId = nextDocumentId; 066 } 067 068 public String getPrevDocumentId() { 069 return prevDocumentId; 070 } 071 072 public void setPrevDocumentId(String prevDocumentId) { 073 this.prevDocumentId = prevDocumentId; 074 } 075 076 public String getHrCalendarEntryId() { 077 return hrCalendarEntryId; 078 } 079 080 public void setHrCalendarEntryId(String hrCalendarEntryId) { 081 this.hrCalendarEntryId = hrCalendarEntryId; 082 } 083 084 public String getPrevHrCalendarEntryId() { 085 return prevHrCalendarEntryId; 086 } 087 088 public void setPrevHrCalendarEntryId(String prevHrCalendarEntryId) { 089 this.prevHrCalendarEntryId = prevHrCalendarEntryId; 090 } 091 092 public String getNextHrCalendarEntryId() { 093 return nextHrCalendarEntryId; 094 } 095 096 public void setNextHrCalendarEntryId(String nextHrCalendarEntryId) { 097 this.nextHrCalendarEntryId = nextHrCalendarEntryId; 098 } 099 100 public Date getBeginCalendarEntryDate() { 101 return beginCalendarEntryDate; 102 } 103 104 public void setBeginCalendarEntryDate(Date beginCalendarEntryDate) { 105 this.beginCalendarEntryDate = beginCalendarEntryDate; 106 } 107 108 public Date getEndCalendarEntryDate() { 109 return endCalendarEntryDate; 110 } 111 112 public void setEndCalendarEntryDate(Date endCalendarEntryDate) { 113 this.endCalendarEntryDate = endCalendarEntryDate; 114 } 115 116 public List<String> getCalendarYears() { 117 return calendarYears; 118 } 119 120 public void setCalendarYears(List<String> calendarYears) { 121 this.calendarYears = calendarYears; 122 } 123 124 public Map<String, String> getPayPeriodsMap() { 125 return payPeriodsMap; 126 } 127 128 public void setPayPeriodsMap(Map<String, String> payPeriodsMap) { 129 this.payPeriodsMap = payPeriodsMap; 130 } 131 132 public CalendarEntry getCalendarEntry() { 133 return calendarEntry; 134 } 135 136 public void setCalendarEntry(CalendarEntry calendarEntry) { 137 this.calendarEntry = calendarEntry; 138 } 139 140 public String getSelectedCalendarYear() { 141 return selectedCalendarYear; 142 } 143 144 public void setSelectedCalendarYear(String selectedCalendarYear) { 145 this.selectedCalendarYear = selectedCalendarYear; 146 } 147 148 public String getSelectedPayPeriod() { 149 return selectedPayPeriod; 150 } 151 152 public void setSelectedPayPeriod(String selectedPayPeriod) { 153 this.selectedPayPeriod = selectedPayPeriod; 154 } 155 156 public String getBeginPeriodDateTime() { 157 String beginPeriodDateTime = StringUtils.EMPTY; 158 159 if (getCalendarEntry() != null) { 160 beginPeriodDateTime = getCalendarEntry().getBeginPeriodFullDateTime().toString(SDF_NO_TZ); 161 } 162 163 return beginPeriodDateTime; 164 } 165 166 public String getEndPeriodDateTime() { 167 String endPeriodDateTime = StringUtils.EMPTY; 168 169 if (getCalendarEntry() != null) { 170 endPeriodDateTime = getCalendarEntry().getEndPeriodFullDateTime().toString(SDF_NO_TZ); 171 } 172 173 return endPeriodDateTime; 174 } 175 176 public boolean isOnCurrentPeriod() { 177 boolean isOnCurrentPeriod = false; 178 179 if (getCalendarEntry() != null) { 180 DateTime beginPeriodDateTime = getCalendarEntry().getBeginPeriodFullDateTime(); 181 DateTime endPeriodDateTime = getCalendarEntry().getEndPeriodFullDateTime(); 182 isOnCurrentPeriod = (beginPeriodDateTime.isEqualNow() || beginPeriodDateTime.isBeforeNow()) && endPeriodDateTime.isAfterNow(); 183 } 184 185 return isOnCurrentPeriod; 186 } 187 188 public List<String> getErrorMessages() { 189 return errorMessages; 190 } 191 192 public void setErrorMessages(List<String> errorMessages) { 193 this.errorMessages = errorMessages; 194 } 195 196 public List<String> getWarningMessages() { 197 return warningMessages; 198 } 199 200 public void setWarningMessages(List<String> warningMessages) { 201 this.warningMessages = warningMessages; 202 } 203 204 public List<String> getInfoMessages() { 205 return infoMessages; 206 } 207 208 public void setInfoMessages(List<String> infoMessages) { 209 this.infoMessages = infoMessages; 210 } 211 212 public List<String> getActionMessages() { 213 return actionMessages; 214 } 215 216 public void setActionMessages(List<String> actionMessages) { 217 this.actionMessages = actionMessages; 218 } 219 220}