001    /*
002     * Copyright 2011 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     */
016    package org.kuali.kfs.sys.document.datadictionary;
017    
018    import org.apache.commons.beanutils.PropertyUtils;
019    import org.apache.commons.lang.StringUtils;
020    import org.kuali.kfs.sys.document.web.NestedFieldTotaling;
021    import org.kuali.kfs.sys.document.web.renderers.Renderer;
022    import org.kuali.rice.kns.datadictionary.DataDictionaryDefinitionBase;
023    
024    /**
025     * Metadata about something that will be responsible for rendering some total of some accounting line group sometime, or something
026     */
027    public abstract class TotalDefinition extends DataDictionaryDefinitionBase implements NestedFieldTotaling {
028    
029        /**
030         * Returns a renderer which will render the total for this total definition
031         * 
032         * @return a Renderer which will render a total
033         */
034        public abstract Renderer getTotalRenderer();
035    
036        /**
037         * get the actual property name if the property is nested; otherwise, return the given property name
038         * 
039         * @param containingPropertyName the given containing property name
040         * @param propertyName the given peropety name
041         * @return the actual property name if the property is nested; otherwise, return the given property name
042         */
043        public String getActualPropertyName(String containingPropertyName, String propertyName) {
044            if (this.isNestedProperty() && StringUtils.isNotBlank(containingPropertyName)) {
045                return containingPropertyName + PropertyUtils.NESTED_DELIM + propertyName;
046            }
047    
048            return propertyName;
049        }
050    }