1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.core.krms.tree;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.util.tree.Node;
20 import org.kuali.rice.core.api.util.tree.Tree;
21 import org.kuali.rice.krms.api.repository.proposition.PropositionType;
22 import org.kuali.rice.krms.dto.PropositionEditor;
23 import org.kuali.rice.krms.dto.RuleEditor;
24 import org.kuali.rice.krms.tree.AbstractTreeBuilder;
25 import org.kuali.rice.krms.tree.RuleViewTreeBuilder;
26 import org.kuali.rice.krms.tree.node.TreeNode;
27 import org.kuali.rice.krms.util.NaturalLanguageHelper;
28 import org.kuali.rice.krms.util.PropositionTreeUtil;
29 import org.kuali.student.r1.common.rice.StudentIdentityConstants;
30 import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
31
32 import java.util.List;
33 import java.util.Map;
34
35
36
37
38
39
40
41 public class KSRuleViewTreeBuilder extends RuleViewTreeBuilder {
42
43 private static final long serialVersionUID = 1L;
44
45 private NaturalLanguageHelper nlHelper;
46
47 protected String getDescription(PropositionEditor proposition) {
48 if (proposition == null) {
49 return StringUtils.EMPTY;
50 }
51
52
53 Map<String, String> nlMap = proposition.getNaturalLanguage();
54 if(!nlMap.containsKey(this.getNaturalLanguageUsageKey())){
55 this.getNlHelper().setNaturalLanguageForUsage(proposition, this.getNaturalLanguageUsageKey(), StudentIdentityConstants.KS_NAMESPACE_CD);
56 }
57
58
59 String description = nlMap.get(this.getNaturalLanguageUsageKey());
60 if (description==null){
61 return StringUtils.EMPTY;
62 }
63
64 return description;
65 }
66
67 @Override
68 public String getNaturalLanguageUsageKey() {
69 return KSKRMSServiceConstants.KRMS_NL_PREVIEW;
70 }
71
72 public NaturalLanguageHelper getNlHelper() {
73 return nlHelper;
74 }
75
76 public void setNlHelper(NaturalLanguageHelper nlHelper) {
77 this.nlHelper = nlHelper;
78 }
79 }