1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository.language;
17
18 import java.util.Map;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplate;
22 import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplaterContract;
23
24
25
26
27
28 public class SimpleNaturalLanguageTemplater implements NaturalLanguageTemplaterContract {
29
30 @Override
31 public String translate(NaturalLanguageTemplate naturalLanguageTemplate, Map<String, Object> contextMap) {
32 String template = naturalLanguageTemplate != null ? naturalLanguageTemplate.getTemplate() : "Empty Template";
33
34 StringBuilder sb = new StringBuilder(template);
35 sb.append(" applied with the following ");
36 sb.append (contextMap.size());
37 sb.append(" variables: ");
38 String comma = "";
39 for (String key : contextMap.keySet()) {
40 sb.append (comma);
41 comma = ",";
42 sb.append ("[");
43 sb.append (key);
44 sb.append ("=");
45 sb.append (contextMap.get(key));
46 sb.append ("]");
47 }
48 return sb.toString();
49 }
50
51 }