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  package org.kuali.student.enrollment.class2.acal.dto;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.student.r2.core.acal.dto.KeyDateInfo;
20  import org.kuali.student.r2.common.dto.RichTextInfo;
21  import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
22  import org.kuali.student.r2.core.constants.AtpServiceConstants;
23  
24  /**
25   * Wrapper class for <code>KeyDateInfo</code> dto.
26   *
27   * @author Kuali Student Team
28   */
29  public class KeyDateWrapper extends TimeSetWrapper{
30  
31      private String keyDateType;
32      private String keyDateNameUI;
33  
34      private KeyDateInfo keyDateInfo;
35      private TypeInfo typeInfo;
36  
37      public KeyDateWrapper(){
38          setAllDay(true);
39          setDateRange(false);
40          keyDateInfo = new KeyDateInfo();
41          keyDateInfo.setStateKey(AtpServiceConstants.MILESTONE_DRAFT_STATE_KEY);
42          RichTextInfo desc = new RichTextInfo();
43          desc.setPlain("test");
44          keyDateInfo.setDescr(desc);
45      }
46  
47      public KeyDateWrapper(KeyDateInfo keydate,boolean isCopy){
48  
49          this.setKeyDateType(keydate.getTypeKey());
50  
51          if (isCopy){
52              this.setKeyDateInfo(new KeyDateInfo());
53              RichTextInfo desc = new RichTextInfo();
54              desc.setPlain(keydate.getTypeKey());
55              getKeyDateInfo().setDescr(desc);
56              getKeyDateInfo().setStateKey(AtpServiceConstants.MILESTONE_DRAFT_STATE_KEY);
57          }else{
58              this.setStartDate(keydate.getStartDate());
59              this.setEndDate(keydate.getEndDate());
60              this.setAllDay(keydate.getIsAllDay());
61              this.setDateRange(keydate.getIsDateRange());
62              this.setKeyDateInfo(keydate);
63              buildDateAndTime();        // don't do this when copying
64          }
65  
66      }
67  
68      public String getKeyDateType() {
69          return keyDateType;
70      }
71  
72      public void setKeyDateType(String keyDateType) {
73          this.keyDateType = keyDateType;
74      }
75  
76      public KeyDateInfo getKeyDateInfo() {
77          return keyDateInfo;
78      }
79  
80      public void setKeyDateInfo(KeyDateInfo keyDateInfo) {
81          this.keyDateInfo = keyDateInfo;
82      }
83  
84      public String getKeyDateNameUI() {
85          return keyDateNameUI;
86      }
87  
88      public void setKeyDateNameUI(String keyDateNameUI) {
89          this.keyDateNameUI = keyDateNameUI;
90      }
91  
92      public TypeInfo getTypeInfo() {
93          return typeInfo;
94      }
95  
96      public void setTypeInfo(TypeInfo typeInfo) {
97          this.typeInfo = typeInfo;
98      }
99  
100     public boolean isNew() {
101         return StringUtils.isBlank(keyDateInfo.getId());
102     }
103 
104     //This is for UI display purpose
105     public String getStartDateUI(){
106         return formatStartDateUI(keyDateInfo.getStartDate());
107     }
108 
109     //This is for UI display purpose
110     public String getEndDateUI(){
111         return formatEndDateUI(keyDateInfo.getEndDate());
112     }
113 }