1 package org.kuali.student.enrollment.class2.registration.form;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.krad.web.form.UifFormBase;
21 import org.kuali.student.enrollment.class2.registration.dto.ActivityOfferingWrapper;
22 import org.kuali.student.enrollment.class2.registration.dto.CourseOfferingWrapper;
23 import org.kuali.student.enrollment.class2.registration.dto.MeetingScheduleWrapper;
24 import org.kuali.student.enrollment.class2.registration.dto.RegistrationGroupWrapper;
25 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
26 import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
27 import org.kuali.student.enrollment.courseregistration.dto.*;
28 import org.kuali.student.r2.common.dto.MeetingScheduleInfo;
29 import org.kuali.student.r2.common.util.constants.LprServiceConstants;
30
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35
36
37 @Deprecated
38 public class RegistrationForm extends UifFormBase {
39
40 private static final long serialVersionUID = 2554632701931313545L;
41
42 private String termKey;
43 private String subjectArea;
44 private String courseOfferingCode;
45 private List<CourseOfferingWrapper> courseOfferingWrappers;
46
47 private List<CourseRegistrationInfo> courseRegistrations;
48 private Map<String,RegistrationGroupWrapper> registrationGroupWrappersById;
49
50 private RegistrationRequestInfo regRequest;
51
52 public RegistrationForm(){
53 super();
54 this.courseRegistrations = new ArrayList<CourseRegistrationInfo>();
55 this.registrationGroupWrappersById = new HashMap<String,RegistrationGroupWrapper>();
56 }
57
58 public String getTermId() {
59 return termKey;
60 }
61
62 public void setTermId(String termKey) {
63 this.termKey = termKey;
64 }
65
66 public String getSubjectArea() {
67 return subjectArea;
68 }
69
70 public void setSubjectArea(String subjectArea) {
71 this.subjectArea = subjectArea;
72 }
73
74 public String getCourseOfferingCode() {
75 return courseOfferingCode;
76 }
77
78 public void setCourseOfferingCode(String courseOfferingCode) {
79 this.courseOfferingCode = courseOfferingCode;
80 }
81
82 public List<CourseOfferingWrapper> getCourseOfferingWrappers() {
83 return courseOfferingWrappers;
84 }
85
86 public void setCourseOfferingWrappers(List<CourseOfferingWrapper> courseOfferingWrappers) {
87 this.courseOfferingWrappers = courseOfferingWrappers;
88 }
89
90 public List<CourseRegistrationInfo> getCourseRegistrations() {
91 return courseRegistrations;
92 }
93
94 public void setCourseRegistrations(List<CourseRegistrationInfo> courseRegistrations) {
95 this.courseRegistrations = courseRegistrations;
96 }
97
98 public Map<String, RegistrationGroupWrapper> getRegistrationGroupWrappersById() {
99 return registrationGroupWrappersById;
100 }
101
102 public void setRegistrationGroupWrappersById(Map<String, RegistrationGroupWrapper> registrationGroupWrappersById) {
103 this.registrationGroupWrappersById = registrationGroupWrappersById;
104 }
105
106 public RegistrationRequestInfo getRegRequest() {
107 return regRequest;
108 }
109
110 public void setRegRequest(RegistrationRequestInfo regRequest) {
111 this.regRequest = regRequest;
112 }
113
114
115 protected List<MeetingScheduleWrapper> getRegisteredCourses() {
116 List<MeetingScheduleWrapper> meetingScheduleWrappers = new ArrayList<MeetingScheduleWrapper>();
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 return meetingScheduleWrappers;
146 }
147
148 protected List<MeetingScheduleWrapper> getCartCourses() {
149 List<MeetingScheduleWrapper> meetingScheduleWrappers = new ArrayList<MeetingScheduleWrapper>();
150 if(getRegRequest() != null){
151
152 for (RegistrationRequestItemInfo regRequestItemInfo : getRegRequest().getRegistrationRequestItems()) {
153
154 String regGroupId = (StringUtils.isNotBlank(regRequestItemInfo.getNewRegistrationGroupId())) ? regRequestItemInfo.getNewRegistrationGroupId() : regRequestItemInfo.getExistingRegistrationGroupId();
155
156 RegistrationGroupWrapper regGroupWrapper = getRegistrationGroupWrappersById().get(regGroupId);
157
158 if (regGroupWrapper == null) {
159 throw new RuntimeException("Cannot find RegistrationGroup in RegistrationForm for registrationGroupId: " + regGroupId);
160 }
161
162 for (ActivityOfferingWrapper activityOfferingWrapper : regGroupWrapper.getActivityOfferingWrappers()) {
163 for(MeetingScheduleWrapper meetingScheduleWrapper: activityOfferingWrapper.getMeetingScheduleWrappers()){
164 meetingScheduleWrapper.setItemId(regRequestItemInfo.getId());
165 meetingScheduleWrapper.setTimeTypeName(activityOfferingWrapper.getTypeName());
166 meetingScheduleWrappers.add(meetingScheduleWrapper);
167 }
168 }
169 }
170 }
171 return meetingScheduleWrappers;
172 }
173
174 protected String getJsArray(List<MeetingScheduleWrapper> meetingScheduleInfos) {
175 StringBuilder builder = new StringBuilder();
176 for(MeetingScheduleWrapper course: meetingScheduleInfos){
177 if (StringUtils.isNotBlank(builder.toString())) {
178 builder.append(",");
179 }
180 builder.append(course.getJsScheduleObject());
181 }
182 return "[" + builder.toString() + "]";
183 }
184
185 public void setRegisteredCoursesJsArray(String temp){}
186 public String getRegisteredCoursesJsArray(){
187 return getJsArray(getRegisteredCourses());
188 }
189
190 public String getCartCoursesJsArray() {
191 return getJsArray(getCartCourses());
192 }
193
194 }