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   */
16  
17  package org.kuali.student.enrollment.class2.courseoffering.form;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.kuali.rice.krad.web.form.UifFormBase;
21  import org.kuali.student.enrollment.acal.dto.TermInfo;
22  import org.kuali.student.enrollment.class2.courseoffering.dto.ManageSOCStatusHistory;
23  import org.kuali.student.enrollment.class2.courseoffering.util.ManageSocConstants;
24  import org.kuali.student.enrollment.courseofferingset.dto.SocInfo;
25  import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  /**
31   * Model for manage soc view.
32   *
33   * @author Kuali Student Team
34   */
35  public class ManageSOCForm extends UifFormBase {
36  
37      private String scheduleInitiatedDate;
38      private String scheduleCompleteDate;
39      private String scheduleDuration;
40  
41      private String publishInitiatedDate;
42      private String publishCompleteDate;
43      private String publishDuration;
44  
45      private String socStatus;
46      private String socSchedulingStatus;
47      private String socPublishingStatus;
48  
49      private String termCode;
50      private List<ManageSOCStatusHistory> statusHistory;
51  
52      private TermInfo termInfo;
53      private SocInfo socInfo;
54  
55      public ManageSOCForm()  {
56          statusHistory = new ArrayList<ManageSOCStatusHistory> ();
57      }
58  
59      public String getScheduleInitiatedDate() {
60          return scheduleInitiatedDate;
61      }
62  
63      public void setScheduleInitiatedDate(String scheduleInitiatedDate) {
64          this.scheduleInitiatedDate = scheduleInitiatedDate;
65      }
66  
67      public String getScheduleCompleteDate() {
68          return scheduleCompleteDate;
69      }
70  
71      public void setScheduleCompleteDate(String scheduleCompleteDate) {
72          this.scheduleCompleteDate = scheduleCompleteDate;
73      }
74  
75      public String getScheduleDuration() {
76          return scheduleDuration;
77      }
78  
79      public void setScheduleDuration(String scheduleDuration) {
80          this.scheduleDuration = scheduleDuration;
81      }
82  
83      public String getPublishInitiatedDate() {
84          return publishInitiatedDate;
85      }
86  
87      public void setPublishInitiatedDate(String publishInitiatedDate) {
88          this.publishInitiatedDate = publishInitiatedDate;
89      }
90  
91      public String getPublishCompleteDate() {
92          return publishCompleteDate;
93      }
94  
95      public void setPublishCompleteDate(String publishCompleteDate) {
96          this.publishCompleteDate = publishCompleteDate;
97      }
98  
99      public String getPublishDuration() {
100         return publishDuration;
101     }
102 
103     public void setPublishDuration(String publishDuration) {
104         this.publishDuration = publishDuration;
105     }
106 
107     public String getSocStatus() {
108         return socStatus;
109     }
110 
111     public void setSocStatus(String socStatus) {
112         this.socStatus = socStatus;
113     }
114 
115     public List<ManageSOCStatusHistory> getStatusHistory() {
116         return statusHistory;
117     }
118 
119     public void setStatusHistory(List<ManageSOCStatusHistory> statusHistory) {
120         this.statusHistory = statusHistory;
121     }
122 
123     public String getTermCode() {
124         return termCode;
125     }
126 
127     public void setTermCode(String termCode) {
128         this.termCode = termCode;
129     }
130 
131     public String getSocSchedulingStatus() {
132         return socSchedulingStatus;
133     }
134 
135     public void setSocSchedulingStatus(String socSchedulingStatus) {
136         this.socSchedulingStatus = socSchedulingStatus;
137     }
138 
139     public String getSocPublishingStatus() {
140         return socPublishingStatus;
141     }
142 
143     public void setSocPublishingStatus(String socPublishingStatus) {
144         this.socPublishingStatus = socPublishingStatus;
145     }
146 
147     public TermInfo getTermInfo() {
148         return termInfo;
149     }
150 
151     public void setTermInfo(TermInfo termInfo) {
152         this.termInfo = termInfo;
153     }
154 
155     public SocInfo getSocInfo() {
156         return socInfo;
157     }
158 
159     public void setSocInfo(SocInfo socInfo) {
160         this.socInfo = socInfo;
161     }
162 
163     /**
164      * This enables the lock button when the doc is in OPEN STATE.
165      *
166      * @return
167      */
168     public boolean isEnableLockButton(){
169         if (socInfo != null){
170             if (StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.OPEN_SOC_STATE_KEY)){
171                 return true;
172             }
173         }
174         return false;
175     }
176 
177     public boolean isEnablePublishButton() {
178 
179         if (socInfo != null){
180             if (!StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.PUBLISHING_SOC_STATE_KEY)){
181                 return true;
182             }
183         }
184 
185         return false;
186     }
187 
188     /**
189      * The lock button will be shown only when the SOC state is Draft or Open. Enabling the button is handled at
190      * <code>isEnableLockButton()</code> which will return true only when the SOC is in OPEN state.
191      *
192      * @return
193      */
194     public boolean isShowLockButton(){
195 
196         if (socInfo != null){
197             if (StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.DRAFT_SOC_STATE_KEY) ||
198                 StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.OPEN_SOC_STATE_KEY)){
199                 return true;
200             }
201         }
202 
203         return false;
204     }
205 
206     /**
207      * When the SOC is in LOCKED state, we can render the final edits button but not enabled.
208      * Enabling the final edit button is only when the schedule is complete
209      *
210      * @return boolean
211      */
212     public boolean isShowFinalEditButton(){
213 
214         if (socInfo != null){
215             if (StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.LOCKED_SOC_STATE_KEY)){
216                 return true;
217             }
218         }
219 
220         return false;
221     }
222 
223     /**
224      * Final Edits button will be enabled when the Scheduling state is completed and the soc state is locked.
225      *
226      * @return boolean
227      */
228     public boolean isEnableFinalEditButton(){
229 
230         if (socInfo != null){
231             if (StringUtils.equals(socInfo.getSchedulingStateKey(), CourseOfferingSetServiceConstants.SOC_SCHEDULING_STATE_COMPLETED) &&
232                 StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.LOCKED_SOC_STATE_KEY)){
233                 return true;
234             }
235         }
236 
237         return false;
238     }
239 
240     /**
241      * If the SOC is in FINAL EDITS, then the SOC is allowed to publish. This method handles the rendering logic for
242      * the publish button
243      *
244      * @return boolean
245      */
246     public boolean isShowPublishSetButton(){
247         boolean retVal = false;
248         if (socInfo != null){
249             if (StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.FINALEDITS_SOC_STATE_KEY)){
250                 retVal = true;
251             }
252         }
253         if(StringUtils.equals(getSocPublishingStatus(), ManageSocConstants.SOC_IN_PROGRESS_PUBLISHING_STATUS_UI) ||
254            StringUtils.equals(getSocPublishingStatus(), ManageSocConstants.SOC_COMPLETED_PUBLISHING_STATUS_UI))   {
255             retVal  = false;
256         }
257         return retVal;
258     }
259 
260     /**
261      * To Close a SOC, SOC must be either PUBLISHED OR PUBLISHING State.
262      *
263      * @return boolean
264      */
265     public boolean isShowCloseSetButton(){
266         if (socInfo != null){
267             if (StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.PUBLISHED_SOC_STATE_KEY) ||
268                 StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.PUBLISHING_SOC_STATE_KEY)){
269                 return true;
270             }
271             if(StringUtils.equals(getSocPublishingStatus(), ManageSocConstants.SOC_IN_PROGRESS_PUBLISHING_STATUS_UI) ||
272                     StringUtils.equals(getSocPublishingStatus(), ManageSocConstants.SOC_COMPLETED_PUBLISHING_STATUS_UI))   {
273                 return true;
274             }
275 
276         }
277         return false;
278     }
279 
280     /**
281      * This will decide whether to display the section below the termcode section. If we have a valid term and SOC exists, the detailed section
282      * will be displayed
283      *
284      * @return boolean
285      */
286     public boolean isRenderDetailsSection(){
287         return getTermInfo() != null;
288     }
289 
290     /**
291      * This method decides whether to display the mass scheduling button. The SOC should be in LOCKED state to render this
292      * button
293      *
294      * @return boolean
295      */
296     public boolean isEnableMSEButton(){
297 
298         boolean retVal = false;
299 
300         if (socInfo != null){
301             if (StringUtils.equals(socInfo.getStateKey(), CourseOfferingSetServiceConstants.LOCKED_SOC_STATE_KEY)){
302                 if(socInfo.getSchedulingStateKey() == null || socInfo.getSchedulingStateKey().isEmpty() || StringUtils.equals(socInfo.getSchedulingStateKey(), CourseOfferingSetServiceConstants.SOC_SCHEDULING_STATE_NOT_STARTED) ) {
303                     retVal =  true;
304                 }
305             }
306         }
307 
308         if(StringUtils.equals(getSocSchedulingStatus(), ManageSocConstants.SOC_IN_PROGRESS_PUBLISHING_STATUS_UI) ||
309            StringUtils.equals(getSocSchedulingStatus(), ManageSocConstants.SOC_COMPLETED_PUBLISHING_STATUS_UI))   {
310             retVal  = false;
311         }
312 
313         return retVal;
314     }
315 
316     /**
317      * This method will clear all the form fields so that different term search will not show previous values.
318      * This is called from viewHelper.buildModel() which will populate all the fields.
319      */
320     public void clear(){
321         setTermInfo(null);
322         setSocInfo(null);
323         statusHistory.clear();
324         setScheduleDuration(StringUtils.EMPTY);
325         setPublishDuration(StringUtils.EMPTY);
326         setSocStatus(StringUtils.EMPTY);
327         setSocPublishingStatus(StringUtils.EMPTY);
328         setSocSchedulingStatus(StringUtils.EMPTY);
329     }
330 
331 
332 }