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.fp.document.web;
017    
018    import org.apache.commons.lang.StringUtils;
019    import org.kuali.kfs.sys.document.web.renderers.CollectionPropertiesCurious;
020    import org.kuali.kfs.sys.document.web.renderers.GroupTotalRenderer;
021    
022    /**
023     * 
024     */
025    public class ProcurementCardGroupTotalRenderer extends GroupTotalRenderer implements CollectionPropertiesCurious {
026        private String collectionProperty = null;
027        private String simpleTotalProperty = null;
028        
029        /**
030         * @see org.kuali.kfs.sys.document.web.renderers.CollectionPropertiesCurious#setCollectionItemProperty(java.lang.String)
031         */
032        public void setCollectionItemProperty(String collectionItemProperty) {
033            // whoops, dropped it...
034        }
035    
036        /**
037         * @see org.kuali.kfs.sys.document.web.renderers.CollectionPropertiesCurious#setCollectionProperty(java.lang.String)
038         */
039        public void setCollectionProperty(String collectionProperty) {
040            this.collectionProperty = collectionProperty;
041        }
042    
043        /**
044         * @see org.kuali.kfs.sys.document.web.renderers.GroupTotalRenderer#clear()
045         */
046        @Override
047        public void clear() {
048            super.clear();
049            this.collectionProperty = null;
050            this.simpleTotalProperty = null;
051        }
052    
053        /**
054         * @see org.kuali.kfs.sys.document.web.renderers.GroupTotalRenderer#getTotalProperty()
055         */
056        @Override
057        public String getTotalProperty() {
058            if (!StringUtils.isBlank(collectionProperty)) {
059                return collectionProperty.replaceFirst("\\.[a-z]+AccountingLines", "")+"."+simpleTotalProperty;
060            }
061            return simpleTotalProperty;
062        }
063    
064        /**
065         * @see org.kuali.kfs.sys.document.web.renderers.GroupTotalRenderer#setTotalProperty(java.lang.String)
066         */
067        @Override
068        public void setTotalProperty(String totalProperty) {
069            this.simpleTotalProperty = totalProperty;
070        }
071    
072    }