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.web;
017    
018    import java.util.List;
019    import java.util.Map;
020    
021    import org.kuali.kfs.sys.businessobject.AccountingLine;
022    import org.kuali.kfs.sys.document.AccountingDocument;
023    import org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase;
024    
025    /**
026     * A contract for classes which wish to provide information about an accounting line which is being rendered
027     */
028    public interface AccountingLineRenderingContext {
029        
030        /**
031         * @return the accounting line that would be rendered by the rendering of the given accounting line context
032         */
033        public abstract AccountingLine getAccountingLine();
034        
035        /**
036         * @return the property path from the form to the accounting line returned by the getAccountingLine() method
037         */
038        public abstract String getAccountingLinePropertyPath();
039        
040        /**
041         * @return a List of actions which can be performed on the given line
042         */
043        public abstract List<AccountingLineViewAction> getActionsForLine();
044        
045        /**
046         * Tells callers if fields should render help or not
047         * @return true if fields should render help, false otherwise
048         */
049        public abstract boolean fieldsShouldRenderHelp();
050        
051        /**
052         * Tells callers if dynamic field labels should even be rendered
053         * @return true if dynamic field labels can be labeled, false if they should not be labeled.
054         */
055        public abstract boolean fieldsCanRenderDynamicLabels();
056        
057        /**
058         * Reports whether the tag to be rendered by this rendering context is "new" - ie, not added yet to the accounting group, but living on the form somewhere - or not
059         * @return true if the line is new, false otherwise
060         */
061        public abstract boolean isNewLine();
062        
063        /**
064         * If this is a new line, returns null; if it is a line in a collection, returns the line number within that collection
065         * @return the current line count
066         */
067        public abstract Integer getCurrentLineCount();
068        
069        /**
070         * Returns all the field names for the given accounting line, prefixed by the accounting line property path
071         * @return a list of properly prefixed field names
072         */
073        public abstract List<String> getFieldNamesForAccountingLine();
074        
075        /**
076         * Returns a Map of all values from the request which were unconverted to actuall business objects
077         * @return the Map of unconverted values
078         */
079        public abstract Map getUnconvertedValues();
080        
081        /**
082         * Forces the population of values for all fields used to render the accounting line
083         */
084        public abstract void populateValuesForFields();
085        
086        /**
087         * @return the accounting document that this line to render is part of (or will be, once it is successfully added)
088         */
089        public abstract AccountingDocument getAccountingDocument();
090        
091        /**
092         * Returns the tab state for the given tab key on the current form
093         * @param tabKey the tab key to get the state of
094         * @return the state (either "OPEN" or "CLOSED")
095         */
096        public abstract String getTabState(String tabKey);
097        
098        /**
099         * Increments the tab index on the form this rendering is associated with
100         */
101        public abstract void incrementTabIndex();
102        
103        /**
104         * @return the label of the group this accounting line is part of
105         */
106        public abstract String getGroupLabel();
107        
108        /**
109         * @return the list of errors on the form
110         */
111        public abstract List getErrors();
112        
113        /**
114         * @return the form that the rendered accounting line will be associated with
115         */
116        public abstract KualiAccountingDocumentFormBase getForm();
117        
118        /**
119         * @return the property name of the object that contains the accounting lines
120         */
121        public abstract String getAccountingLineContainingObjectPropertyName();
122        
123        /**
124         * Determines whether a field is modifyable or not
125         * @param fieldName the simple name (that is, the name does not include the collection property) of the field
126         * @return true if the field can be modified, false if the field can only be read
127         */
128        public abstract boolean isFieldModifyable(String fieldName);
129        
130        /**
131         * Determines whether the accounting line is - as a whole line - editable or not
132         * @return true if the line - as a whole line - is editable, false if nothing on the line can be edited
133         */
134        public abstract boolean isEditableLine();
135        
136        /**
137         * Determines whether this line should be allowed to be deleted
138         * @return true if it should be allowed to be deleted, false otherwise
139         */
140        public abstract boolean allowDelete();
141        
142        /**
143         * Makes the line within this accounting line context deletable
144         */
145        public void makeDeletable();
146    }