| 1 | |
package org.kuali.student.enrollment.class2.courseoffering.service.transformer; |
| 2 | |
|
| 3 | |
import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo; |
| 4 | |
import org.kuali.student.enrollment.courseoffering.dto.OfferingInstructorInfo; |
| 5 | |
import org.kuali.student.enrollment.courseoffering.service.R1ToR2CopyHelper; |
| 6 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo; |
| 7 | |
import org.kuali.student.enrollment.lui.dto.LuiIdentifierInfo; |
| 8 | |
import org.kuali.student.enrollment.lui.dto.LuiInfo; |
| 9 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 10 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 11 | |
import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants; |
| 12 | |
import org.kuali.student.r2.common.util.constants.LuiServiceConstants; |
| 13 | |
import org.kuali.student.r2.lum.clu.dto.LuCodeInfo; |
| 14 | |
|
| 15 | |
import java.util.List; |
| 16 | |
|
| 17 | 0 | public class ActivityOfferingTransformer { |
| 18 | |
|
| 19 | |
public static void lui2Activity(ActivityOfferingInfo ao, LuiInfo lui) { |
| 20 | 0 | ao.setId(lui.getId()); |
| 21 | 0 | ao.setMeta(lui.getMeta()); |
| 22 | 0 | ao.setStateKey(lui.getStateKey()); |
| 23 | 0 | ao.setTypeKey(lui.getTypeKey()); |
| 24 | 0 | ao.setDescr(lui.getDescr()); |
| 25 | 0 | ao.setActivityId(lui.getCluId()); |
| 26 | 0 | ao.setTermId(lui.getAtpId()); |
| 27 | 0 | ao.setMinimumEnrollment(lui.getMinimumEnrollment()); |
| 28 | 0 | ao.setMaximumEnrollment(lui.getMaximumEnrollment()); |
| 29 | 0 | ao.setScheduleId(lui.getScheduleId()); |
| 30 | 0 | ao.setActivityOfferingURL(lui.getReferenceURL()); |
| 31 | |
|
| 32 | 0 | if (lui.getOfficialIdentifier() != null){ |
| 33 | 0 | ao.setActivityCode(lui.getOfficialIdentifier().getCode()); |
| 34 | |
} |
| 35 | |
|
| 36 | |
|
| 37 | 0 | List<AttributeInfo> attributes = ao.getAttributes(); |
| 38 | 0 | for (Attribute attr : lui.getAttributes()) { |
| 39 | 0 | if (CourseOfferingServiceConstants.COURSE_EVALUATION_INDICATOR_ATTR.equals(attr.getKey())){ |
| 40 | 0 | ao.setIsEvaluated(Boolean.valueOf(attr.getValue())); |
| 41 | 0 | } else if (CourseOfferingServiceConstants.MAX_ENROLLMENT_IS_ESTIMATED_ATTR.equals(attr.getKey())){ |
| 42 | 0 | ao.setIsMaxEnrollmentEstimate(Boolean.valueOf(attr.getValue())); |
| 43 | |
} else { |
| 44 | 0 | attributes.add(new AttributeInfo(attr)); |
| 45 | |
} |
| 46 | |
} |
| 47 | 0 | ao.setAttributes(attributes); |
| 48 | |
|
| 49 | |
|
| 50 | 0 | LuCodeInfo luCode = findLuCode(lui, LuiServiceConstants.HONORS_LU_CODE); |
| 51 | 0 | if (luCode == null) { |
| 52 | 0 | ao.setIsHonorsOffering(false); |
| 53 | |
} else { |
| 54 | 0 | ao.setIsHonorsOffering(Boolean.valueOf(luCode.getValue())); |
| 55 | |
} |
| 56 | |
|
| 57 | 0 | } |
| 58 | |
|
| 59 | |
public static void activity2Lui (ActivityOfferingInfo ao, LuiInfo lui) { |
| 60 | 0 | lui.setId(ao.getId()); |
| 61 | 0 | lui.setTypeKey(ao.getTypeKey()); |
| 62 | 0 | lui.setStateKey(ao.getStateKey()); |
| 63 | 0 | lui.setDescr(ao.getDescr()); |
| 64 | 0 | lui.setMeta(ao.getMeta()); |
| 65 | 0 | lui.setCluId(ao.getActivityId()); |
| 66 | 0 | lui.setAtpId(ao.getTermId()); |
| 67 | 0 | lui.setMinimumEnrollment(ao.getMinimumEnrollment()); |
| 68 | 0 | lui.setMaximumEnrollment(ao.getMaximumEnrollment()); |
| 69 | 0 | lui.setScheduleId(ao.getScheduleId()); |
| 70 | 0 | lui.setReferenceURL(ao.getActivityOfferingURL()); |
| 71 | |
|
| 72 | |
|
| 73 | 0 | LuiIdentifierInfo officialIdentifier = new LuiIdentifierInfo(); |
| 74 | 0 | officialIdentifier.setTypeKey(LuiServiceConstants.LUI_IDENTIFIER_OFFICIAL_TYPE_KEY); |
| 75 | 0 | officialIdentifier.setStateKey(LuiServiceConstants.LUI_IDENTIFIER_ACTIVE_STATE_KEY); |
| 76 | 0 | officialIdentifier.setCode(ao.getActivityCode()); |
| 77 | 0 | lui.setOfficialIdentifier(officialIdentifier); |
| 78 | |
|
| 79 | |
|
| 80 | 0 | List<AttributeInfo> attributes = lui.getAttributes(); |
| 81 | 0 | for (Attribute attr : ao.getAttributes()) { |
| 82 | 0 | attributes.add(new AttributeInfo(attr)); |
| 83 | |
} |
| 84 | |
|
| 85 | 0 | AttributeInfo isEvaluated = new AttributeInfo(); |
| 86 | 0 | isEvaluated.setKey(CourseOfferingServiceConstants.COURSE_EVALUATION_INDICATOR_ATTR); |
| 87 | 0 | isEvaluated.setValue(String.valueOf(ao.getIsEvaluated())); |
| 88 | 0 | attributes.add(isEvaluated); |
| 89 | |
|
| 90 | 0 | AttributeInfo isMaxEnrollmentEstimate = new AttributeInfo(); |
| 91 | 0 | isMaxEnrollmentEstimate.setKey(CourseOfferingServiceConstants.MAX_ENROLLMENT_IS_ESTIMATED_ATTR); |
| 92 | 0 | isMaxEnrollmentEstimate.setValue(String.valueOf(ao.getIsMaxEnrollmentEstimate())); |
| 93 | 0 | attributes.add(isMaxEnrollmentEstimate); |
| 94 | |
|
| 95 | 0 | lui.setAttributes(attributes); |
| 96 | |
|
| 97 | |
|
| 98 | 0 | LuCodeInfo luCode = findAddLuCode(lui, LuiServiceConstants.HONORS_LU_CODE); |
| 99 | 0 | luCode.setValue(String.valueOf(ao.getIsHonorsOffering())); |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
public static OfferingInstructorInfo transformInstructorForActivityOffering(LuiPersonRelationInfo lpr) { |
| 103 | 0 | OfferingInstructorInfo instructor = new OfferingInstructorInfo(); |
| 104 | 0 | instructor.setPersonId(lpr.getPersonId()); |
| 105 | 0 | instructor.setPercentageEffort(lpr.getCommitmentPercent()); |
| 106 | 0 | instructor.setId(lpr.getId()); |
| 107 | 0 | instructor.setTypeKey(lpr.getTypeKey()); |
| 108 | 0 | instructor.setStateKey(lpr.getStateKey()); |
| 109 | 0 | return instructor; |
| 110 | |
|
| 111 | |
} |
| 112 | |
|
| 113 | |
public static LuCodeInfo findLuCode(LuiInfo lui, String typeKey) { |
| 114 | 0 | for (LuCodeInfo info : lui.getLuiCodes()) { |
| 115 | 0 | if (info.getTypeKey().equals(typeKey)) { |
| 116 | 0 | return info; |
| 117 | |
} |
| 118 | |
} |
| 119 | 0 | return null; |
| 120 | |
} |
| 121 | |
|
| 122 | |
public static LuCodeInfo findAddLuCode(LuiInfo lui, String typeKey) { |
| 123 | 0 | LuCodeInfo info = findLuCode(lui, typeKey); |
| 124 | 0 | if (info != null) { |
| 125 | 0 | return info; |
| 126 | |
} |
| 127 | 0 | info = new LuCodeInfo(); |
| 128 | 0 | info.setTypeKey(typeKey); |
| 129 | 0 | lui.getLuiCodes().add(info); |
| 130 | 0 | return info; |
| 131 | |
} |
| 132 | |
|
| 133 | |
} |