| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.lum.statement.config.context; |
| 17 | |
|
| 18 | |
import java.util.Map; |
| 19 | |
|
| 20 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
| 21 | |
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
| 22 | |
import org.kuali.student.core.atp.dto.AtpDurationTypeInfo; |
| 23 | |
import org.kuali.student.core.atp.service.AtpService; |
| 24 | |
import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | 0 | public class AtpContextImpl extends BasicContextImpl { |
| 30 | |
|
| 31 | |
private AtpService atpService; |
| 32 | |
|
| 33 | |
public final static String DURATION_TYPE_TOKEN = "durationType"; |
| 34 | |
public final static String DURATION_TOKEN = "duration"; |
| 35 | |
|
| 36 | |
public void setAtpService(AtpService atpService) { |
| 37 | 0 | this.atpService = atpService; |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
private AtpDurationTypeInfo getAtpDurationType(String atpDurationTypeKey) throws OperationFailedException { |
| 41 | 0 | if (atpDurationTypeKey == null) { |
| 42 | 0 | return null; |
| 43 | |
} |
| 44 | |
try { |
| 45 | 0 | AtpDurationTypeInfo atpDurationType = this.atpService.getAtpDurationType(atpDurationTypeKey); |
| 46 | 0 | return atpDurationType; |
| 47 | 0 | } catch (Exception e) { |
| 48 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 49 | |
} |
| 50 | |
} |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
public Map<String, Object> createContextMap(ReqComponentInfo reqComponent) throws OperationFailedException { |
| 59 | 0 | String durationTypeKey = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.DURATION_TYPE_KEY.getId()); |
| 60 | 0 | String duration = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.DURATION_KEY.getId()); |
| 61 | 0 | AtpDurationTypeInfo atpDurationType = getAtpDurationType(durationTypeKey); |
| 62 | |
|
| 63 | 0 | Map<String, Object> contextMap = super.createContextMap(reqComponent); |
| 64 | 0 | contextMap.put(DURATION_TYPE_TOKEN, atpDurationType); |
| 65 | 0 | contextMap.put(DURATION_TOKEN, duration); |
| 66 | 0 | return contextMap; |
| 67 | |
} |
| 68 | |
} |