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.gl.web.struts;
017    
018    import javax.servlet.http.HttpServletRequest;
019    
020    import org.kuali.kfs.gl.GeneralLedgerConstants;
021    import org.kuali.kfs.gl.businessobject.Entry;
022    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
023    import org.kuali.kfs.sys.businessobject.lookup.LookupableSpringContext;
024    import org.kuali.rice.kns.lookup.Lookupable;
025    import org.kuali.rice.kns.web.struts.form.MultipleValueLookupForm;
026    
027    /**
028     * Balance inquiries are pretty much just lookups already, but are not used in the traditional sense. In most cases, balance
029     * inquiries only show the end-user data, and allow the end-user to drill-down into inquiries. A traditional lookup allows the user
030     * to return data to a form. This class is for balance inquiries implemented in the sense of a traditional lookup for forms that
031     * pull data out of inquiries.<br/> <br/> One example of this is the
032     * <code>{@link org.kuali.kfs.module.ld.document.SalaryExpenseTransferDocument}</code> which creates source lines from a labor
033     * ledger balance inquiry screen.<br/> <br/> This is a <code>{@link KualiMultipleValueLookupAction}</code> which required some
034     * customization because requirements were not possible with displaytag. There are a number of properties/attributes that are used
035     * for pagination, formatting, etc...
036     * 
037     * @see org.kuali.kfs.module.ld.document.SalaryExpenseTransferDocument
038     * @see org.kuali.kfs.module.ld.document.web.struts.SalaryExpenseTransferAction;
039     * @see org.kuali.kfs.module.ld.document.web.struts.SalaryExpenseTransferForm;
040     */
041    public class BalanceInquiryLookupForm extends MultipleValueLookupForm {
042        private static final long serialVersionUID = 1L;
043    
044        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BalanceInquiryForm.class);
045    
046        private Lookupable pendingEntryLookupable;
047        private LookupResultsSelectable selectable;
048        private boolean segmented;
049    
050        public BalanceInquiryLookupForm() {
051        }
052    
053        /**
054         * Picks out business object name from the request to get retrieve a lookupable and set properties.
055         * 
056         * @param request <code>{@link javax.servlet.http.HttpServletRequest}</code> instance for Struts
057         */
058        @Override
059        public void populate(HttpServletRequest request) {
060            Lookupable localPendingEntryLookupable = null;
061    
062            super.populate(request);
063    
064            if (Entry.class.getName().equals(getBusinessObjectClassName())) {
065                localPendingEntryLookupable = LookupableSpringContext.getLookupable(GeneralLedgerConstants.LookupableBeanKeys.PENDING_ENTRY);
066            }
067    
068            if (localPendingEntryLookupable != null) {
069                localPendingEntryLookupable.setBusinessObjectClass(GeneralLedgerPendingEntry.class);
070                localPendingEntryLookupable.setFieldConversions(getFieldConversions());
071            }
072            setPendingEntryLookupable(localPendingEntryLookupable);
073        }
074    
075    
076        /**
077         * @param pendingEntryLookupable
078         */
079        public void setPendingEntryLookupable(Lookupable pendingEntryLookupable) {
080            this.pendingEntryLookupable = pendingEntryLookupable;
081        }
082    
083    
084        /**
085         * @return Returns the pendingEntryLookupable.
086         */
087        public Lookupable getPendingEntryLookupable() {
088            return this.pendingEntryLookupable;
089        }
090    
091        /**
092         * Determines if the balance inquiry lookup should be segmented or not
093         * 
094         * @return boolean
095         */
096        public boolean isSegmented() {
097            return segmented;
098        }
099    
100        /**
101         * Tells the balance inquiry lookup whether to be segmented or not
102         * 
103         * @param seg
104         */
105        public void setSegmented(boolean seg) {
106            segmented = seg;
107        }
108    }