1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.courseoffering.dto;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.util.KeyValue;
21 import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
22 import org.kuali.student.enrollment.courseoffering.dto.CreditOptionInfo;
23 import org.kuali.student.enrollment.courseoffering.dto.OfferingInstructorInfo;
24 import org.kuali.student.enrollment.courseofferingset.dto.SocInfo;
25 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
26
27 import java.io.Serializable;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37
38
39
40
41 public class CourseOfferingEditWrapper extends CourseOfferingWrapper {
42
43 private List<FormatOfferingWrapper> formatOfferingList;
44 private List<String> studentRegOptions;
45 private List<String> crsGradingOptions;
46 private List<OrganizationInfoWrapper> organizationNames;
47 private List<OfferingInstructorWrapper> instructors;
48 private String stateName;
49
50 private String selectedGradingOptionName;
51 private String selectedStudentRegOpts;
52
53 private boolean passFailStudentRegOpts;
54 private boolean auditStudentRegOpts;
55
56 private CreditOptionInfo creditOption;
57 private boolean creditOptionFixed;
58 private boolean isChecked;
59 private boolean editCrossListedCoAlias;
60
61 private String gradingOption;
62
63
64 private String termStartEnd;
65 private String termName;
66
67 private SocInfo socInfo;
68
69 private List<String> alternateCourseCodesSuffixStripped;
70
71 private boolean createCO;
72
73 private RenderHelper renderHelper;
74
75
76 private List<ActivityOfferingWrapper> aoWrapperList;
77
78 public CourseOfferingEditWrapper(){
79 formatOfferingList = new ArrayList<FormatOfferingWrapper>();
80 studentRegOptions = new ArrayList<String>();
81 alternateCourseCodesSuffixStripped = new ArrayList<String>();
82 instructors = new ArrayList<OfferingInstructorWrapper>();
83 OfferingInstructorWrapper instructorWrapper = new OfferingInstructorWrapper();
84 instructors.add(instructorWrapper);
85 renderHelper = new RenderHelper();
86 FormatOfferingWrapper defaultFO = new FormatOfferingWrapper();
87 formatOfferingList.add(defaultFO);
88 aoWrapperList = new ArrayList<ActivityOfferingWrapper>();
89 }
90
91 public CourseOfferingEditWrapper(CourseOfferingInfo info){
92 super(info);
93 alternateCourseCodesSuffixStripped = new ArrayList<String>();
94 instructors = new ArrayList<OfferingInstructorWrapper>();
95 if(info.getInstructors() == null || info.getInstructors().isEmpty()) {
96 OfferingInstructorWrapper instructorWrapper = new OfferingInstructorWrapper();
97 instructors.add(instructorWrapper);
98 } else if(info.getInstructors().size() > 0) {
99 for(OfferingInstructorInfo instructorInfo : info.getInstructors()) {
100 OfferingInstructorWrapper instructorWrapper = new OfferingInstructorWrapper(instructorInfo);
101 instructors.add(instructorWrapper);
102 }
103 }
104 renderHelper = new RenderHelper();
105 }
106
107 public List<FormatOfferingWrapper> getFormatOfferingList() {
108 return formatOfferingList;
109 }
110
111 public void setFormatOfferingList(List<FormatOfferingWrapper> formatOfferingList) {
112 if (formatOfferingList == null) {
113 formatOfferingList = new ArrayList<FormatOfferingWrapper>();
114 }
115 this.formatOfferingList = formatOfferingList;
116 }
117
118 public List<String> getStudentRegOptions() {
119 return studentRegOptions;
120 }
121
122 public void setStudentRegOptions(List<String> studentRegOptions) {
123 if (studentRegOptions == null) {
124 studentRegOptions = new ArrayList<String>();
125 }
126 this.studentRegOptions = studentRegOptions;
127 }
128
129 public List<String> getCrsGradingOptions() {
130 if (crsGradingOptions == null) {
131 crsGradingOptions = new ArrayList<String>();
132 }
133 return crsGradingOptions;
134 }
135
136 public void setCrsGradingOptions(List<String> crsGradingOptions) {
137 this.crsGradingOptions = crsGradingOptions;
138 }
139
140 public List<OrganizationInfoWrapper> getOrganizationNames() {
141 return organizationNames;
142 }
143
144 public void setOrganizationNames(List<OrganizationInfoWrapper> organizationNames) {
145 this.organizationNames = organizationNames;
146 }
147
148
149 public String getSelectedGradingOptionName() {
150 return selectedGradingOptionName;
151 }
152
153 public void setSelectedGradingOptionName(String selectedGradingOptionName) {
154 this.selectedGradingOptionName = selectedGradingOptionName;
155 }
156
157 public String getSelectedStudentRegOpts() {
158 return selectedStudentRegOpts;
159 }
160
161 public void setSelectedStudentRegOpts(String selectedStudentRegOpts) {
162 this.selectedStudentRegOpts = selectedStudentRegOpts;
163 }
164
165 public CreditOptionInfo getCreditOption() {
166 return creditOption;
167 }
168
169 public void setCreditOption(CreditOptionInfo creditOption) {
170 this.creditOption = creditOption;
171 }
172
173 public boolean getCreditOptionFixed() {
174 return creditOptionFixed;
175 }
176
177 public void setCreditOptionFixed(boolean creditOptionFixed) {
178 this.creditOptionFixed = creditOptionFixed;
179 }
180
181 public List<OfferingInstructorWrapper> getInstructors() {
182 return instructors;
183 }
184
185 public void setInstructors(List<OfferingInstructorWrapper> instructors) {
186 this.instructors = instructors;
187 }
188
189 public boolean getIsChecked() {
190 return isChecked;
191 }
192
193 public void setIsChecked(boolean checked) {
194 this.isChecked = checked;
195 }
196
197 public boolean isEditCrossListedCoAlias() {
198 return editCrossListedCoAlias;
199 }
200
201 public void setEditCrossListedCoAlias(boolean editCrossListedCoAlias) {
202 this.editCrossListedCoAlias = editCrossListedCoAlias;
203 }
204
205 public String getGradingOption() {
206 return gradingOption;
207 }
208
209 public void setGradingOption(String gradingOption) {
210 this.gradingOption = gradingOption;
211 }
212
213 public String getStateName() {
214 return stateName;
215 }
216
217 public void setStateName(String stateName) {
218 this.stateName = stateName;
219 }
220
221 public boolean isLegalToDelete() {
222
223 if (getCourseOfferingInfo() != null &&
224 StringUtils.equals(getCourseOfferingInfo().getStateKey(), LuiServiceConstants.LUI_DRAFT_STATE_KEY) ||
225 StringUtils.equals(getCourseOfferingInfo().getStateKey(), LuiServiceConstants.LUI_CO_STATE_DRAFT_KEY) ||
226 StringUtils.equals(getCourseOfferingInfo().getStateKey(), LuiServiceConstants.LUI_CO_STATE_PLANNED_KEY)||
227 StringUtils.equals(getCourseOfferingInfo().getStateKey(), LuiServiceConstants.LUI_AO_STATE_OFFERED_KEY) ||
228 StringUtils.equals(getCourseOfferingInfo().getStateKey(), LuiServiceConstants.LUI_CO_STATE_OFFERED_KEY) ) {
229 return true;
230 }
231
232 return false;
233 }
234
235 public String getCreditOptionCreditsUI(){
236 if(creditOption!=null && !creditOption.getAllowedCredits().isEmpty() && !creditOption.getCredits().isEmpty() ){
237 return StringUtils.join(creditOption.getCredits(),",");
238 }
239 return "No Credits Selected";
240 }
241
242 public String getSelectedStudentRegOptsUI(){
243 return selectedStudentRegOpts;
244 }
245
246 public boolean getAuditStudentRegOpts() {
247 return auditStudentRegOpts;
248 }
249
250 public void setAuditStudentRegOpts(boolean auditStudentRegOpts) {
251 this.auditStudentRegOpts = auditStudentRegOpts;
252 }
253
254 public boolean getPassFailStudentRegOpts() {
255 return passFailStudentRegOpts;
256 }
257
258 public void setPassFailStudentRegOpts(boolean passFailStudentRegOpts) {
259 this.passFailStudentRegOpts = passFailStudentRegOpts;
260 }
261
262 public String getTermStartEnd() {
263 return termStartEnd;
264 }
265
266 public void setTermStartEnd(String termStartEnd) {
267 this.termStartEnd = termStartEnd;
268 }
269
270 public void setTermName(String name){
271 this.termName=name;
272 }
273
274 public String getTermName(){
275 return termName;
276 }
277
278 public Map<String,String> getAdminOrg(){
279 Map<String,String> adminOrgMap = new HashMap<String,String>();
280 if (organizationNames != null && !organizationNames.isEmpty()){
281 String orgIDs = "";
282 for (OrganizationInfoWrapper organizationName : organizationNames) {
283 orgIDs = orgIDs + organizationName.getId() + ",";
284 }
285 if (orgIDs.length() > 0) {
286 adminOrgMap.put("offeringAdminOrgId", orgIDs.substring(0, orgIDs.length()-1));
287 }
288 }
289 return adminOrgMap;
290 }
291
292 public SocInfo getSocInfo() {
293 return socInfo;
294 }
295
296 public void setSocInfo(SocInfo socInfo) {
297 this.socInfo = socInfo;
298 }
299
300 public List<String> getAlternateCourseCodesSuffixStripped() {
301 return alternateCourseCodesSuffixStripped;
302 }
303
304 public boolean getCreateCO() {
305 return createCO;
306 }
307
308 public void setCreateCO(boolean createCO) {
309 this.createCO = createCO;
310 }
311
312
313
314
315
316
317
318
319
320
321
322
323 @SuppressWarnings("unused")
324 public void setAlternateCourseCodesSuffixStripped(List<String> alternateCourseCodesSuffixStripped) {
325 this.alternateCourseCodesSuffixStripped = alternateCourseCodesSuffixStripped;
326 }
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342 @SuppressWarnings("unused")
343 public String getAlternateCOCodesUIList(){
344 StringBuffer buffer = new StringBuffer();
345 for (String crosslistingCode : alternateCourseCodesSuffixStripped){
346 buffer.append(crosslistingCode + ", ");
347 }
348
349 return StringUtils.removeEnd(buffer.toString(), ", ");
350 }
351
352 public RenderHelper getRenderHelper() {
353 return renderHelper;
354 }
355
356 public void setRenderHelper(RenderHelper renderHelper) {
357 this.renderHelper = renderHelper;
358 }
359
360 public class RenderHelper implements Serializable {
361
362 private String selectedCoCode;
363 private CourseOfferingInfo nextCO;
364 private CourseOfferingInfo prevCO;
365 private List<KeyValue> relatedCOs;
366
367 protected RenderHelper(){
368 relatedCOs = new ArrayList<KeyValue>();
369 }
370
371
372 public boolean isShowFormatAddButton() {
373 return getFormatOfferingList().size() < getCourse().getFormats().size();
374 }
375
376 public void setSelectedCoCode( String selectedCoCode ) {
377 this.selectedCoCode = selectedCoCode;
378 }
379
380 public String getSelectedCoCode() {
381 return this.selectedCoCode;
382 }
383
384 public void setPrevCO( CourseOfferingInfo prevCO ) {
385 this.prevCO = prevCO;
386 }
387
388 public CourseOfferingInfo getPrevCO() {
389 return this.prevCO;
390 }
391
392 public void setNextCO( CourseOfferingInfo nextCO ) {
393 this.nextCO = nextCO;
394 }
395
396 public CourseOfferingInfo getNextCO() {
397 return this.nextCO;
398 }
399
400 public void setRelatedCOs( List<KeyValue> relatedCOs ) {
401 this.relatedCOs = relatedCOs;
402 }
403
404 public List<KeyValue> getRelatedCOs() {
405 return this.relatedCOs;
406 }
407
408 }
409
410 public List<ActivityOfferingWrapper> getAoWrapperList() {
411 return aoWrapperList;
412 }
413
414 public void setAoWrapperList(List<ActivityOfferingWrapper> aoWrapperList) {
415 this.aoWrapperList = aoWrapperList;
416 }
417 }
418