View Javadoc

1   /* Copyright 2011 The Kuali Foundation
2    *
3    * Licensed under the Educational Community License, Version 1.0 (the
4    * "License"); you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    * http://www.opensource.org/licenses/ecl1.php
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12   * License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package org.kuali.student.enrollment.class2.acal.dto;
16  
17  import org.kuali.student.r2.core.acal.dto.AcalEventInfo;
18  import org.kuali.student.r2.common.dto.RichTextInfo;
19  import org.kuali.student.r2.core.constants.AtpServiceConstants;
20  
21  /**
22   * This is the wrapper class for the <code>AcalEventInfo</code> DTO.
23   *
24   * @author Kuali Student Team
25   */
26  public class AcalEventWrapper extends TimeSetWrapper{
27  
28      private AcalEventInfo acalEventInfo;
29      private String eventTypeKey;
30      private String eventTypeName;
31  
32      public AcalEventWrapper() {
33          acalEventInfo = new AcalEventInfo();
34          setAllDay(false);
35          setDateRange(true);
36          acalEventInfo.setStateKey(AtpServiceConstants.MILESTONE_DRAFT_STATE_KEY);
37      }
38  
39      /**
40       * Populate all the properties from the passed in dto.
41       *
42       * @param acalEventInfo source dto to copy
43       * @param isCopy whether to copy the dto or not
44       */
45      public AcalEventWrapper(AcalEventInfo acalEventInfo,boolean isCopy){
46          this.setStartDate(acalEventInfo.getStartDate());
47          this.setEndDate(acalEventInfo.getEndDate());
48          this.setAllDay(acalEventInfo.getIsAllDay());
49          this.setDateRange(acalEventInfo.getIsDateRange());
50          this.setEventTypeKey(acalEventInfo.getTypeKey());
51  
52          buildDateAndTime();
53  
54          if (isCopy){
55              setAcalEventInfo(new AcalEventInfo());
56              RichTextInfo rti = new RichTextInfo();
57              rti.setPlain(getAcalEventInfo().getTypeKey());
58              getAcalEventInfo().setDescr(rti);
59              getAcalEventInfo().setStateKey(AtpServiceConstants.MILESTONE_DRAFT_STATE_KEY);
60          }else{
61             setAcalEventInfo(acalEventInfo);
62          }
63  
64      }
65  
66      public AcalEventInfo getAcalEventInfo(){
67          return acalEventInfo;
68      }
69  
70      /**
71       * <code>AcalEventInfo</code> associated with this wrapper
72       *
73       * @param acalEventInfo event info dto
74       */
75      public void setAcalEventInfo(AcalEventInfo acalEventInfo) {
76          this.acalEventInfo =  acalEventInfo;
77      }
78  
79      /**
80       * See <code>setEventTypeKey()</code>
81       *
82       * @return event type key
83       */
84      public String getEventTypeKey() {
85          return eventTypeKey;
86      }
87  
88      /**
89       * Event Type key
90       *
91       * @param eventTypeKey type key
92       */
93      public void setEventTypeKey(String eventTypeKey) {
94          this.eventTypeKey = eventTypeKey;        
95      }
96  
97      /**
98       * See <code>setEventTypeName()</code>
99       *
100      * @return event name
101      */
102     public String getEventTypeName() {
103         return eventTypeName;
104     }
105 
106     /**
107      * Sets the event name for the ui display purpose.
108      *
109      * @param eventTypeName event name
110      */
111     public void setEventTypeName(String eventTypeName) {
112         this.eventTypeName = eventTypeName;
113     }
114 
115     /**
116      * Formatted start date for the ui display
117      *
118      * @return formatted start date
119      */
120     @SuppressWarnings("unused")
121     public String getStartDateUI(){
122         return formatStartDateUI(acalEventInfo.getStartDate());
123     }
124 
125     /**
126      * Formatted end date for the ui display
127      *
128      * @return formatted end date
129      */
130     @SuppressWarnings("unused")
131     public String getEndDateUI(){
132         return formatEndDateUI(acalEventInfo.getEndDate());
133     }
134 
135 
136 }