View Javadoc

1   package org.kuali.student.core.krms.tree;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.rice.krms.dto.PropositionEditor;
5   import org.kuali.rice.krms.tree.RuleEditTreeBuilder;
6   import org.kuali.rice.krms.util.NaturalLanguageHelper;
7   import org.kuali.student.r1.common.rice.StudentIdentityConstants;
8   import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
9   
10  import java.util.Map;
11  
12  /**
13   * Created with IntelliJ IDEA.
14   * User: SW Genis
15   * Date: 2013/07/18
16   * Time: 5:21 PM
17   * To change this template use File | Settings | File Templates.
18   */
19  public class KSRuleEditTreeBuilder extends RuleEditTreeBuilder{
20  
21      private NaturalLanguageHelper nlHelper;
22  
23      protected String getDescription(PropositionEditor proposition) {
24          if (proposition == null) {
25              return StringUtils.EMPTY;
26          }
27  
28          //Get the natural language for the usage key.
29          Map<String, String> nlMap = proposition.getNaturalLanguage();
30          if(!nlMap.containsKey(this.getNaturalLanguageUsageKey())){
31              this.getNlHelper().setNaturalLanguageForUsage(proposition, this.getNaturalLanguageUsageKey(), StudentIdentityConstants.KS_NAMESPACE_CD);
32          }
33  
34          //Return empty string if nl does is null.
35          String description = nlMap.get(this.getNaturalLanguageUsageKey());
36          if (description==null){
37              return StringUtils.EMPTY;
38          }
39  
40          return description;
41      }
42  
43      public String getNaturalLanguageUsageKey(){
44          return KSKRMSServiceConstants.KRMS_NL_RULE_EDIT;
45      }
46  
47      public NaturalLanguageHelper getNlHelper() {
48          return nlHelper;
49      }
50  
51      public void setNlHelper(NaturalLanguageHelper nlHelper) {
52          this.nlHelper = nlHelper;
53      }
54  
55  }