| 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 | |
public class RegistrationForm extends UifFormBase { |
| 37 | |
|
| 38 | |
private static final long serialVersionUID = 2554632701931313545L; |
| 39 | |
|
| 40 | |
private String termKey; |
| 41 | |
private String subjectArea; |
| 42 | |
private String courseOfferingCode; |
| 43 | |
private List<CourseOfferingWrapper> courseOfferingWrappers; |
| 44 | |
|
| 45 | |
private List<CourseRegistrationInfo> courseRegistrations; |
| 46 | |
private Map<String,RegistrationGroupWrapper> registrationGroupWrappersById; |
| 47 | |
|
| 48 | |
private RegistrationRequestInfo regRequest; |
| 49 | |
|
| 50 | |
public RegistrationForm(){ |
| 51 | 0 | super(); |
| 52 | 0 | this.courseRegistrations = new ArrayList<CourseRegistrationInfo>(); |
| 53 | 0 | this.registrationGroupWrappersById = new HashMap<String,RegistrationGroupWrapper>(); |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
public String getTermId() { |
| 57 | 0 | return termKey; |
| 58 | |
} |
| 59 | |
|
| 60 | |
public void setTermId(String termKey) { |
| 61 | 0 | this.termKey = termKey; |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
public String getSubjectArea() { |
| 65 | 0 | return subjectArea; |
| 66 | |
} |
| 67 | |
|
| 68 | |
public void setSubjectArea(String subjectArea) { |
| 69 | 0 | this.subjectArea = subjectArea; |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
public String getCourseOfferingCode() { |
| 73 | 0 | return courseOfferingCode; |
| 74 | |
} |
| 75 | |
|
| 76 | |
public void setCourseOfferingCode(String courseOfferingCode) { |
| 77 | 0 | this.courseOfferingCode = courseOfferingCode; |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
public List<CourseOfferingWrapper> getCourseOfferingWrappers() { |
| 81 | 0 | return courseOfferingWrappers; |
| 82 | |
} |
| 83 | |
|
| 84 | |
public void setCourseOfferingWrappers(List<CourseOfferingWrapper> courseOfferingWrappers) { |
| 85 | 0 | this.courseOfferingWrappers = courseOfferingWrappers; |
| 86 | 0 | } |
| 87 | |
|
| 88 | |
public List<CourseRegistrationInfo> getCourseRegistrations() { |
| 89 | 0 | return courseRegistrations; |
| 90 | |
} |
| 91 | |
|
| 92 | |
public void setCourseRegistrations(List<CourseRegistrationInfo> courseRegistrations) { |
| 93 | 0 | this.courseRegistrations = courseRegistrations; |
| 94 | 0 | } |
| 95 | |
|
| 96 | |
public Map<String, RegistrationGroupWrapper> getRegistrationGroupWrappersById() { |
| 97 | 0 | return registrationGroupWrappersById; |
| 98 | |
} |
| 99 | |
|
| 100 | |
public void setRegistrationGroupWrappersById(Map<String, RegistrationGroupWrapper> registrationGroupWrappersById) { |
| 101 | 0 | this.registrationGroupWrappersById = registrationGroupWrappersById; |
| 102 | 0 | } |
| 103 | |
|
| 104 | |
public RegistrationRequestInfo getRegRequest() { |
| 105 | 0 | return regRequest; |
| 106 | |
} |
| 107 | |
|
| 108 | |
public void setRegRequest(RegistrationRequestInfo regRequest) { |
| 109 | 0 | this.regRequest = regRequest; |
| 110 | 0 | } |
| 111 | |
|
| 112 | |
|
| 113 | |
protected List<MeetingScheduleWrapper> getRegisteredCourses() { |
| 114 | 0 | List<MeetingScheduleWrapper> meetingScheduleWrappers = new ArrayList<MeetingScheduleWrapper>(); |
| 115 | |
|
| 116 | |
|
| 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 | 0 | return meetingScheduleWrappers; |
| 144 | |
} |
| 145 | |
|
| 146 | |
protected List<MeetingScheduleWrapper> getCartCourses() { |
| 147 | 0 | List<MeetingScheduleWrapper> meetingScheduleWrappers = new ArrayList<MeetingScheduleWrapper>(); |
| 148 | 0 | if(getRegRequest() != null){ |
| 149 | |
|
| 150 | 0 | for (RegistrationRequestItemInfo regRequestItemInfo : getRegRequest().getRegistrationRequestItems()) { |
| 151 | |
|
| 152 | 0 | String regGroupId = (StringUtils.isNotBlank(regRequestItemInfo.getNewRegistrationGroupId())) ? regRequestItemInfo.getNewRegistrationGroupId() : regRequestItemInfo.getExistingRegistrationGroupId(); |
| 153 | |
|
| 154 | 0 | RegistrationGroupWrapper regGroupWrapper = getRegistrationGroupWrappersById().get(regGroupId); |
| 155 | |
|
| 156 | 0 | if (regGroupWrapper == null) { |
| 157 | 0 | throw new RuntimeException("Cannot find RegistrationGroup in RegistrationForm for registrationGroupId: " + regGroupId); |
| 158 | |
} |
| 159 | |
|
| 160 | 0 | for (ActivityOfferingWrapper activityOfferingWrapper : regGroupWrapper.getActivityOfferingWrappers()) { |
| 161 | 0 | for(MeetingScheduleWrapper meetingScheduleWrapper: activityOfferingWrapper.getMeetingScheduleWrappers()){ |
| 162 | 0 | meetingScheduleWrapper.setItemId(regRequestItemInfo.getId()); |
| 163 | 0 | meetingScheduleWrapper.setTimeTypeName(activityOfferingWrapper.getTypeName()); |
| 164 | 0 | meetingScheduleWrappers.add(meetingScheduleWrapper); |
| 165 | |
} |
| 166 | |
} |
| 167 | 0 | } |
| 168 | |
} |
| 169 | 0 | return meetingScheduleWrappers; |
| 170 | |
} |
| 171 | |
|
| 172 | |
protected String getJsArray(List<MeetingScheduleWrapper> meetingScheduleInfos) { |
| 173 | 0 | StringBuilder builder = new StringBuilder(); |
| 174 | 0 | for(MeetingScheduleWrapper course: meetingScheduleInfos){ |
| 175 | 0 | if (StringUtils.isNotBlank(builder.toString())) { |
| 176 | 0 | builder.append(","); |
| 177 | |
} |
| 178 | 0 | builder.append(course.getJsScheduleObject()); |
| 179 | |
} |
| 180 | 0 | return "[" + builder.toString() + "]"; |
| 181 | |
} |
| 182 | |
|
| 183 | 0 | public void setRegisteredCoursesJsArray(String temp){} |
| 184 | |
public String getRegisteredCoursesJsArray(){ |
| 185 | 0 | return getJsArray(getRegisteredCourses()); |
| 186 | |
} |
| 187 | |
|
| 188 | |
public String getCartCoursesJsArray() { |
| 189 | 0 | return getJsArray(getCartCourses()); |
| 190 | |
} |
| 191 | |
|
| 192 | |
} |