1 /**
2 * Copyright 2005-2014 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krms.impl.repository.language;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 /**
22 * This is an abstract class for creating a map (containing token/data) used
23 * in template translations.
24 */
25 public abstract class AbstractTranslationContext implements TranslationContext {
26 /**
27 * <p>These common shared tokens are needed since velocity doesn't
28 * allow periods in tokens.</p>
29 * <p>E.g. kuali.reqComponent.field.type.totalCredits must either be convert to
30 * totalCredits or reqCompFieldType_totalCredits so a template would look
31 * like:</p>
32 * <p>'Student must take $totalCredits of MATH 100'</p>
33 * or
34 * <p>'Student must take $reqCompFieldType_totalCredits of MATH 100'</p>
35 */
36 protected final static String FIELDS_TOKEN = "fields";
37
38 /**
39 * Creates the context map (template data) for the requirement component.
40 * Also, adds the field token map to the context map.
41 *
42 * @param parameters
43 * @throws org.kuali.student.r2.common.exceptions.DoesNotExistException If CLU, CluSet or relation does not exist
44 */
45 @Override
46 public Map<String, Object> createContextMap(Map<String, Object> parameters) {
47 Map<String, Object> contextMap = new HashMap<String, Object>();
48 contextMap.put(FIELDS_TOKEN, parameters);
49 return contextMap;
50 }
51 }