| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BasicContextImpl |
|
| 2.0;2 |
| 1 | /** | |
| 2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 | * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 | * not use this file except in compliance with the License. You may | |
| 5 | * obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, | |
| 10 | * software distributed under the License is distributed on an "AS IS" | |
| 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 | * or implied. See the License for the specific language governing | |
| 13 | * permissions and limitations under the License. | |
| 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.statement.naturallanguage.AbstractContext; | |
| 23 | import org.kuali.student.lum.statement.config.context.util.NLHelper; | |
| 24 | import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; | |
| 25 | ||
| 26 | 0 | public class BasicContextImpl extends AbstractContext<ReqComponentInfo> { |
| 27 | /** | |
| 28 | * <code>NLHelper</code> token (key) references a static natural language | |
| 29 | * helper class for use in templates. | |
| 30 | * e.g. '$NLHelper.getProperGrammer($intValue, "course", "courses")' | |
| 31 | */ | |
| 32 | public final static String NL_HELPER_TOKEN = "NLHelper"; | |
| 33 | /** | |
| 34 | * Relational operator token. | |
| 35 | */ | |
| 36 | public final static String OPERATOR_TOKEN = "relationalOperator"; | |
| 37 | /** | |
| 38 | * An integer value token. | |
| 39 | */ | |
| 40 | public final static String INTEGER_VALUE_TOKEN = "intValue"; | |
| 41 | ||
| 42 | /** | |
| 43 | * Constructor. | |
| 44 | */ | |
| 45 | 0 | public BasicContextImpl() { |
| 46 | 0 | } |
| 47 | ||
| 48 | /** | |
| 49 | * Creates the context map (template data) for the requirement component. | |
| 50 | * Also, adds the field token map to the context map. | |
| 51 | * | |
| 52 | * @param reqComponent Requirement component | |
| 53 | * @throws OperationFailedException Creating context map fails | |
| 54 | */ | |
| 55 | public Map<String, Object> createContextMap(ReqComponentInfo reqComponent) throws OperationFailedException { | |
| 56 | 0 | String value = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.INTEGER_VALUE1_KEY.getId()); |
| 57 | 0 | String operator = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.OPERATOR_KEY.getId()); |
| 58 | ||
| 59 | 0 | Map<String, Object> contextMap = super.createContextMap(reqComponent); |
| 60 | 0 | contextMap.put(NL_HELPER_TOKEN, NLHelper.class); |
| 61 | 0 | if(operator != null) { |
| 62 | 0 | contextMap.put(OPERATOR_TOKEN, operator); |
| 63 | } | |
| 64 | 0 | if(value != null) { |
| 65 | 0 | contextMap.put(INTEGER_VALUE_TOKEN, Integer.valueOf(value)); |
| 66 | } | |
| 67 | ||
| 68 | 0 | return contextMap; |
| 69 | } | |
| 70 | } |