| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.lum.course.service.assembler; |
| 17 | |
|
| 18 | |
import org.kuali.student.common.util.UUIDHelper; |
| 19 | |
import org.kuali.student.core.assembly.BOAssembler; |
| 20 | |
import org.kuali.student.core.assembly.BaseDTOAssemblyNode; |
| 21 | |
import org.kuali.student.core.assembly.BaseDTOAssemblyNode.NodeOperation; |
| 22 | |
import org.kuali.student.core.assembly.data.AssemblyException; |
| 23 | |
import org.kuali.student.lum.course.dto.ActivityInfo; |
| 24 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
| 25 | |
import org.kuali.student.lum.lu.service.LuService; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | 233 | public class ActivityAssembler implements BOAssembler<ActivityInfo, CluInfo> { |
| 34 | |
|
| 35 | |
private LuService luService; |
| 36 | |
|
| 37 | |
@Override |
| 38 | |
public ActivityInfo assemble(CluInfo clu, ActivityInfo activity, boolean shallowBuild) { |
| 39 | 138 | if(clu == null){ |
| 40 | 0 | return null; |
| 41 | |
} |
| 42 | |
|
| 43 | 138 | ActivityInfo activityInfo = (null != activity) ? activity : new ActivityInfo(); |
| 44 | |
|
| 45 | 138 | activityInfo.setId(clu.getId()); |
| 46 | 138 | activityInfo.setActivityType(clu.getType()); |
| 47 | 138 | activityInfo.setState(clu.getState()); |
| 48 | 138 | activityInfo.setDefaultEnrollmentEstimate(clu.getDefaultEnrollmentEstimate()); |
| 49 | 138 | activityInfo.setDuration(clu.getStdDuration()); |
| 50 | 138 | activityInfo.setContactHours(clu.getIntensity()); |
| 51 | 138 | activityInfo.setMetaInfo(clu.getMetaInfo()); |
| 52 | 138 | activityInfo.setAttributes(clu.getAttributes()); |
| 53 | 138 | return activityInfo; |
| 54 | |
} |
| 55 | |
|
| 56 | |
@Override |
| 57 | |
public BaseDTOAssemblyNode<ActivityInfo,CluInfo> disassemble( |
| 58 | |
ActivityInfo activity, NodeOperation operation) throws AssemblyException { |
| 59 | 94 | if (activity==null) { |
| 60 | |
|
| 61 | 0 | throw new AssemblyException("Activity can not be null"); |
| 62 | |
} |
| 63 | 94 | if (NodeOperation.CREATE != operation && null == activity.getId()) { |
| 64 | 0 | throw new AssemblyException("Activity's id can not be null"); |
| 65 | |
} |
| 66 | |
|
| 67 | 94 | BaseDTOAssemblyNode<ActivityInfo,CluInfo> result = new BaseDTOAssemblyNode<ActivityInfo,CluInfo>(this); |
| 68 | |
|
| 69 | |
CluInfo clu; |
| 70 | |
try { |
| 71 | 94 | clu = (NodeOperation.UPDATE == operation) ? luService.getClu(activity.getId()) : new CluInfo(); |
| 72 | 0 | } catch (Exception e) { |
| 73 | 0 | throw new AssemblyException("Error retrieving activity learning unit during update", e); |
| 74 | 94 | } |
| 75 | |
|
| 76 | |
|
| 77 | 94 | clu.setId(UUIDHelper.genStringUUID(activity.getId())); |
| 78 | 94 | clu.setType(activity.getActivityType()); |
| 79 | 94 | clu.setState(activity.getState()); |
| 80 | 94 | clu.setDefaultEnrollmentEstimate(activity.getDefaultEnrollmentEstimate()); |
| 81 | 94 | clu.setStdDuration(activity.getDuration()); |
| 82 | 94 | clu.setIntensity(activity.getContactHours()); |
| 83 | 94 | clu.setMetaInfo(activity.getMetaInfo()); |
| 84 | 94 | clu.setAttributes(activity.getAttributes()); |
| 85 | |
|
| 86 | |
|
| 87 | 94 | result.setNodeData(clu); |
| 88 | |
|
| 89 | |
|
| 90 | 94 | result.setBusinessDTORef(activity); |
| 91 | |
|
| 92 | 94 | result.setOperation(operation); |
| 93 | |
|
| 94 | 94 | return result; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public void setLuService(LuService luService) { |
| 98 | 1 | this.luService = luService; |
| 99 | 1 | } |
| 100 | |
|
| 101 | |
public LuService getLuService() { |
| 102 | 0 | return luService; |
| 103 | |
} |
| 104 | |
} |