001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.datadictionary;
017
018import java.io.Serializable;
019import java.util.HashMap;
020import java.util.Map;
021
022import org.apache.commons.lang.StringUtils;
023import org.kuali.rice.krad.datadictionary.parse.BeanTag;
024import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
025import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBean;
026
027/**
028 * The help element provides the keys to obtain a
029 * help description from the database.
030 *
031 * On document JSP pages, a help icon may be rendered.  If this tag is specified, then
032 * the filename of this page will be located in the value of the parameter specified by the namespace, detail type, and
033 * name.
034 *
035 * The value of the parameter is relative to the value of the "externalizable.help.url" property in
036 * ConfigurationService
037 * (see KualiHelpAction).
038 * parameterNamespace: namespace of the parameter that has the path to the help page
039 * parameterName: name of the parameter that has the path to the help page
040 * parameterDetailType: detail type of the parameter that has the path to the help page
041 */
042@BeanTag(name = "helpDefinition")
043public class HelpDefinition extends DataDictionaryDefinitionBase implements UifDictionaryBean, Serializable {
044    private static final long serialVersionUID = -6869646654597012863L;
045
046    protected String parameterNamespace;
047    protected String parameterDetailType;
048    protected String parameterName;
049
050    private Map<String, String> expressionGraph;
051    private Map<String, String> refreshExpressionGraph;
052    private Map<String, String> propertyExpressions;
053
054    /**
055     * Constructs a HelpDefinition.
056     */
057    public HelpDefinition() {
058        expressionGraph = new HashMap<String, String>();
059        refreshExpressionGraph = new HashMap<String, String>();
060        propertyExpressions = new HashMap<String, String>();
061
062    }
063
064    /**
065     * @return parameter name
066     */
067    @BeanTagAttribute(name = "parameterName")
068    public String getParameterName() {
069        return parameterName;
070    }
071
072    /**
073     * @param parameterName name of the parameter that has the path to the help page
074     */
075    public void setParameterName(String parameterName) {
076        if (StringUtils.isBlank(parameterName)) {
077            throw new IllegalArgumentException("invalid (blank) parameterName");
078        }
079        this.parameterName = parameterName;
080    }
081
082    /**
083     * @return parameter namespace
084     */
085    @BeanTagAttribute(name = "parameterNamespace")
086    public String getParameterNamespace() {
087        return parameterNamespace;
088    }
089
090    /**
091     * parameterNamespace: namespace of the parameter that has the path to the help page
092     */
093    public void setParameterNamespace(String parameterNamespace) {
094        this.parameterNamespace = parameterNamespace;
095    }
096
097    @BeanTagAttribute(name = "parameterDetailType")
098    public String getParameterDetailType() {
099        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}