View Javadoc

1   package org.kuali.student.enrollment.class2.acal.dto;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.student.r2.common.util.constants.AcademicCalendarServiceConstants;
5   import org.kuali.student.enrollment.acal.dto.TermInfo;
6   import org.kuali.student.r2.common.dto.RichTextInfo;
7   import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
8   import org.kuali.student.r2.core.constants.AtpServiceConstants;
9   
10  import java.util.ArrayList;
11  import java.util.Date;
12  import java.util.List;
13  
14  public class AcademicTermWrapper {
15  
16      private static final long serialVersionUID = 4898118410378641665L;
17  
18      private TermInfo termInfo;
19  
20      private String name;
21      private int instructionalDays;
22      private String termType;
23      private Date startDate;
24      private Date endDate;
25  
26      private String termNameForUI;
27      private List<KeyDatesGroupWrapper> keyDatesGroupWrappers;
28  
29      private TypeInfo typeInfo;
30  
31      private List<KeyDateWrapper> keyDatesToDeleteOnSave;
32  
33      private boolean isOfficial;
34      private boolean isAlreadySaved;
35  
36  
37      public AcademicTermWrapper(){
38          keyDatesGroupWrappers = new ArrayList();
39          keyDatesToDeleteOnSave = new ArrayList<KeyDateWrapper>();
40          termInfo = new TermInfo();
41          termInfo.setStateKey(AtpServiceConstants.ATP_DRAFT_STATE_KEY);
42          RichTextInfo desc = new RichTextInfo();
43          desc.setPlain("Test");
44          termInfo.setDescr(desc);
45  
46      }
47  
48      public AcademicTermWrapper(TermInfo termInfo,boolean isCopy){
49          this.startDate = termInfo.getStartDate();
50          this.endDate = termInfo.getEndDate();
51          this.termType = termInfo.getTypeKey();
52          this.keyDatesGroupWrappers = new ArrayList();
53          this.keyDatesToDeleteOnSave = new ArrayList<KeyDateWrapper>();
54  
55          if (isCopy){
56              setTermInfo(new TermInfo());
57              RichTextInfo desc = new RichTextInfo();
58              desc.setPlain(termInfo.getTypeKey());
59              getTermInfo().setDescr(desc);
60              getTermInfo().setStateKey(AtpServiceConstants.ATP_DRAFT_STATE_KEY);
61          } else{
62             setTermInfo(termInfo);
63             this.name = termInfo.getName();
64          }
65  
66      }
67  
68      public String getName() {
69          return name;
70      }
71  
72      public void setName(String name) {
73          this.name = name;
74      }
75  
76      public String getTermType() {
77          return termType;
78      }
79  
80      public void setTermType(String termType) {
81          this.termType = termType;
82      }
83  
84      public Date getStartDate() {
85          return startDate;
86      }
87  
88      public void setStartDate(Date startDate) {
89          this.startDate = startDate;
90      }
91  
92      public Date getEndDate() {
93          return endDate;
94      }
95  
96      public void setEndDate(Date endDate) {
97          this.endDate = endDate;
98      }
99  
100     public TermInfo getTermInfo() {
101         return termInfo;
102     }
103 
104     public void setTermInfo(TermInfo termInfo) {
105         this.termInfo = termInfo;
106     }
107 
108     public int getInstructionalDays() {
109         return instructionalDays;
110     }
111 
112     public void setInstructionalDays(int instructionalDays) {
113         this.instructionalDays = instructionalDays;
114     }
115 
116     public String getTermNameForUI() {
117         return termNameForUI;
118     }
119 
120     public void setTermNameForUI(String termNameForUI) {
121         this.termNameForUI = termNameForUI;
122     }
123 
124     public List<KeyDatesGroupWrapper> getKeyDatesGroupWrappers() {
125         return keyDatesGroupWrappers;
126     }
127 
128     public void setKeyDatesGroupWrappers(List<KeyDatesGroupWrapper> keyDatesGroupWrappers) {
129         this.keyDatesGroupWrappers = keyDatesGroupWrappers;
130     }
131 
132     public List<KeyDateWrapper> getKeyDatesToDeleteOnSave() {
133         return keyDatesToDeleteOnSave;
134     }
135 
136     public void setKeyDatesToDeleteOnSave(List<KeyDateWrapper> keyDatesToDeleteOnSave) {
137         this.keyDatesToDeleteOnSave = keyDatesToDeleteOnSave;
138     }
139 
140     public void clear(){
141         setEndDate(null);
142         setStartDate(null);
143         setTermType(null);
144         setName(null);
145         setTypeInfo(null);
146         keyDatesToDeleteOnSave.clear();
147     }
148 
149     public TypeInfo getTypeInfo() {
150         return typeInfo;
151     }
152 
153     public void setTypeInfo(TypeInfo typeInfo) {
154         this.typeInfo = typeInfo;
155     }
156 
157     public boolean isOfficial() {
158         return StringUtils.equals(termInfo.getStateKey(), AcademicCalendarServiceConstants.TERM_OFFICIAL_STATE_KEY);
159     }
160 
161     public boolean isNew() {
162         return StringUtils.isBlank(termInfo.getId());
163     }
164 
165     public boolean isKeyDateGroupExists(String keydateGroupTypeKey){
166         for(KeyDatesGroupWrapper wrapper : keyDatesGroupWrappers){
167             if (StringUtils.equalsIgnoreCase(wrapper.getKeyDateGroupType(),keydateGroupTypeKey)){
168                 return true;
169             }
170         }
171         return false;
172     }
173 
174 }