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