View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  package org.kuali.student.enrollment.class2.acal.form;
16  
17  import org.apache.commons.lang.StringUtils;
18  import org.kuali.rice.krad.web.form.UifFormBase;
19  import org.kuali.student.r2.common.util.constants.AcademicCalendarServiceConstants;
20  import org.kuali.student.enrollment.acal.dto.HolidayCalendarInfo;
21  import org.kuali.student.enrollment.class2.acal.dto.HolidayWrapper;
22  
23  import java.text.SimpleDateFormat;
24  import java.util.ArrayList;
25  import java.util.Date;
26  import java.util.List;
27  
28  /**
29   * This class is the formClass for  HolidayCalendar views
30   *
31   * @author Kuali Student Team
32   */
33  
34  public class HolidayCalendarForm  extends UifFormBase {
35      private static final long serialVersionUID = 7526472595622776147L;
36  
37      private HolidayCalendarInfo holidayCalendarInfo;
38      private List<HolidayWrapper> holidays;
39      private String stateName;
40      private String adminOrgName;
41      private String newCalendarName;
42      private Date newCalendarStartDate;
43      private Date newCalendarEndDate;
44      private String hcId;
45      private String orgHcId;
46      private boolean newCalendar;
47      private boolean officialCalendar;
48  
49      //Just to display buttons (delete) based on this flag
50      private boolean officialUI;
51  
52      public HolidayCalendarForm() {
53          super();
54          holidayCalendarInfo = new HolidayCalendarInfo();
55          holidays = new ArrayList<HolidayWrapper>();
56          newCalendar = true;
57          officialCalendar = false;
58      }
59  
60      public HolidayCalendarInfo getHolidayCalendarInfo() {
61          return holidayCalendarInfo;
62      }
63      public void setHolidayCalendarInfo(HolidayCalendarInfo holidayCalendarInfo) {
64          this.holidayCalendarInfo = holidayCalendarInfo;
65      }
66  
67      public List<HolidayWrapper> getHolidays() {
68          // Putting sort here causes list to be sorted when addLine "add" clicked, instead of having
69          // the new row added to the top of the collection as desired.  Just so you know.
70          //Collections.sort(holidays);
71          return holidays;
72      }
73  
74      public void setHolidays(List<HolidayWrapper> holidays) {
75          this.holidays = holidays;
76      }
77  
78      public String getStateName() {
79          return stateName;
80      }
81  
82      public void setStateName(String stateName) {
83          this.stateName = stateName;
84      }
85  
86      public String getAdminOrgName() {
87          return adminOrgName;
88      }
89      public void setAdminOrgName(String adminOrgName) {
90          this.adminOrgName = adminOrgName;
91      }
92  
93      public String getNewCalendarName() {
94          return newCalendarName;
95      }
96      public void setNewCalendarName(String newCalendarName) {
97          this.newCalendarName = newCalendarName;
98      }
99  
100     public Date getNewCalendarStartDate() {
101         return newCalendarStartDate;
102     }
103     public void setNewCalendarStartDate(Date newCalendarStartDate) {
104         this.newCalendarStartDate = newCalendarStartDate;
105     }
106 
107     public Date getNewCalendarEndDate() {
108         return newCalendarEndDate;
109     }
110     public void setNewCalendarEndDate(Date newCalendarEndDate) {
111         this.newCalendarEndDate = newCalendarEndDate;
112     }
113 
114     public String getHcId() {
115         return hcId;
116     }
117 
118     public void setHcId(String hcId) {
119         this.hcId = hcId;
120     }
121 
122     public String getOrgHcId() {
123         return orgHcId;
124     }
125 
126     public void setOrgHcId(String orgHcId) {
127         this.orgHcId = orgHcId;
128     }
129 
130     public boolean isNewCalendar() {
131         return newCalendar;
132     }
133 
134     public void setNewCalendar(boolean newCalendar) {
135         this.newCalendar = newCalendar;
136     }
137 
138     public boolean isOfficialCalendar() {
139         return officialCalendar;
140     }
141 
142     public void setOfficialCalendar(boolean officialCalendar) {
143         this.officialCalendar = officialCalendar;
144     }
145 
146     public String getUpdateTimeString(){
147         if (getHolidayCalendarInfo() != null &&
148             getHolidayCalendarInfo().getMeta() != null &&
149             getHolidayCalendarInfo().getMeta().getUpdateTime() != null){
150             Date updateTime = getHolidayCalendarInfo().getMeta().getUpdateTime();
151             return "Last saved at "+new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(updateTime);
152         } else {
153             return StringUtils.EMPTY;
154         }
155     }
156 
157     public boolean isOfficialUI(){
158         if (holidayCalendarInfo != null){
159             return StringUtils.equals(AcademicCalendarServiceConstants.ACADEMIC_CALENDAR_OFFICIAL_STATE_KEY, holidayCalendarInfo.getStateKey());
160         }
161         return false;
162     }
163 }