1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.tree;
17
18 import org.apache.commons.lang.StringEscapeUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.util.tree.Node;
21 import org.kuali.rice.core.api.util.tree.Tree;
22 import org.kuali.rice.krms.api.repository.proposition.PropositionDefinitionContract;
23 import org.kuali.rice.krms.dto.PropositionEditor;
24 import org.kuali.rice.krms.dto.RuleEditor;
25 import org.kuali.rice.krms.tree.node.CompareTreeNode;
26 import org.kuali.rice.krms.util.NaturalLanguageHelper;
27
28 import java.util.Map;
29
30
31
32
33 public abstract class AbstractTreeBuilder implements TreeBuilder {
34
35 protected String buildNodeLabel(PropositionEditor prop){
36 return StringEscapeUtils.escapeHtml(this.getDescription(prop));
37 }
38
39 protected String getDescription(PropositionEditor proposition) {
40 if (proposition == null) {
41 return StringUtils.EMPTY;
42 }
43
44
45 Map<String, String> nlMap = proposition.getNaturalLanguage();
46 String description = nlMap.get(this.getNaturalLanguageUsageKey());
47 if (description==null){
48 return StringUtils.EMPTY;
49 }
50
51 return description;
52 }
53
54 protected String getPropositionPrefix(PropositionEditor prop){
55 return "<b>" + prop.getKey() + ".</b> ";
56 }
57
58 public abstract String getNaturalLanguageUsageKey();
59
60 protected void addNodeType(Node node, String type){
61 if ((node.getNodeType()==null)||(node.getNodeType().length()==0)){
62 node.setNodeType(type);
63 } else {
64 node.setNodeType(node.getNodeType() + " " + type);
65 }
66 }
67
68 }