View Javadoc
1   /**
2    * Copyright 2005-2015 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.krad.datadictionary;
17  
18  import java.io.Serializable;
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
24  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
25  import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBean;
26  
27  /**
28   * The help element provides the keys to obtain a
29   * help description from the database.
30   *
31   * On document JSP pages, a help icon may be rendered.  If this tag is specified, then
32   * the filename of this page will be located in the value of the parameter specified by the namespace, detail type, and
33   * name.
34   *
35   * The value of the parameter is relative to the value of the "externalizable.help.url" property in
36   * ConfigurationService
37   * (see KualiHelpAction).
38   * parameterNamespace: namespace of the parameter that has the path to the help page
39   * parameterName: name of the parameter that has the path to the help page
40   * parameterDetailType: detail type of the parameter that has the path to the help page
41   */
42  @BeanTag(name = "helpDefinition")
43  public class HelpDefinition extends DataDictionaryDefinitionBase implements UifDictionaryBean, Serializable {
44      private static final long serialVersionUID = -6869646654597012863L;
45  
46      protected String parameterNamespace;
47      protected String parameterDetailType;
48      protected String parameterName;
49  
50      private Map<String, String> expressionGraph;
51      private Map<String, String> refreshExpressionGraph;
52      private Map<String, String> propertyExpressions;
53  
54      /**
55       * Constructs a HelpDefinition.
56       */
57      public HelpDefinition() {
58          expressionGraph = new HashMap<String, String>();
59          refreshExpressionGraph = new HashMap<String, String>();
60          propertyExpressions = new HashMap<String, String>();
61  
62      }
63  
64      /**
65       * @return parameter name
66       */
67      @BeanTagAttribute(name = "parameterName")
68      public String getParameterName() {
69          return parameterName;
70      }
71  
72      /**
73       * @param parameterName name of the parameter that has the path to the help page
74       */
75      public void setParameterName(String parameterName) {
76          if (StringUtils.isBlank(parameterName)) {
77              throw new IllegalArgumentException("invalid (blank) parameterName");
78          }
79          this.parameterName = parameterName;
80      }
81  
82      /**
83       * @return parameter namespace
84       */
85      @BeanTagAttribute(name = "parameterNamespace")
86      public String getParameterNamespace() {
87          return parameterNamespace;
88      }
89  
90      /**
91       * parameterNamespace: namespace of the parameter that has the path to the help page
92       */
93      public void setParameterNamespace(String parameterNamespace) {
94          this.parameterNamespace = parameterNamespace;
95      }
96  
97      @BeanTagAttribute(name = "parameterDetailType")
98      public String getParameterDetailType() {
99          return this.parameterDetailType;
100     }
101 
102     /**
103      * parameterDetailType: detail type of the parameter that has the path to the help page
104      */
105     public void setParameterDetailType(String parameterDetailType) {
106         if (StringUtils.isBlank(parameterDetailType)) {
107             throw new IllegalArgumentException("invalid (blank) parameterDetailType");
108         }
109         this.parameterDetailType = parameterDetailType;
110     }
111 
112     /**
113      * {@inheritDoc}
114      */
115     @Override
116     public Map<String, String> getExpressionGraph() {
117         return expressionGraph;
118     }
119 
120     /**
121      * {@inheritDoc}
122      */
123     @Override
124     public void setExpressionGraph(Map<String, String> expressionGraph) {
125         this.expressionGraph = expressionGraph;
126     }
127 
128     /**
129      * @see org.kuali.rice.krad.datadictionary.uif.UifDictionaryBean#getPropertyExpressions
130      */
131     public Map<String, String> getPropertyExpressions() {
132         return propertyExpressions;
133     }
134 
135     /**
136      * {@inheritDoc}
137      */
138     public void setPropertyExpressions(Map<String, String> propertyExpressions) {
139         this.propertyExpressions = propertyExpressions;
140     }
141 
142     /**
143      * {@inheritDoc}
144      */
145     public String getPropertyExpression(String propertyName) {
146         if (this.propertyExpressions.containsKey(propertyName)) {
147             return this.propertyExpressions.get(propertyName);
148         }
149 
150         return null;
151     }
152 
153 }