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.service;
017
018 import java.util.List;
019 import java.util.Map;
020 import java.util.Set;
021
022 import javax.servlet.jsp.PageContext;
023
024 import org.kuali.kfs.sys.businessobject.AccountingLine;
025 import org.kuali.kfs.sys.document.AccountingDocument;
026 import org.kuali.kfs.sys.document.datadictionary.AccountingLineGroupDefinition;
027 import org.kuali.kfs.sys.document.datadictionary.AccountingLineViewFieldDefinition;
028 import org.kuali.kfs.sys.document.web.AccountingLineTableRow;
029 import org.kuali.kfs.sys.document.web.TableJoining;
030 import org.kuali.kfs.sys.document.web.renderers.FieldRenderer;
031 import org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase;
032 import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition;
033 import org.kuali.rice.kns.web.ui.Field;
034
035 /**
036 * Service that helps render accounting lines
037 */
038 public interface AccountingLineRenderingService {
039
040 /**
041 * Given a list of renderable elements, determines how to split that into rows, cells, and fields
042 * @param elements renderable elements to find table form for
043 * @return a list of table rows that can be rendered
044 */
045 public abstract List<AccountingLineTableRow> tablify(List<TableJoining> elements);
046
047 /**
048 * Performs any known transformations against the List of AccountingLineViewRenderableElements
049 * @param elements the List of elements to transform
050 * @param definition the accounting line group definition that gives instructions to the particular rendering we're attempting
051 * @param document the Accounting Document we're rendering lines from
052 * @param accountingLine the line we're rendering
053 * @param newLine true if what is being rendered is the new line in the form; false otherwise
054 * @param unconvertedValues any unconverted values stored in the form
055 * @param accountingLinePropertyName the property path to this accounting line
056 */
057 public abstract void performPreTablificationTransformations(List<TableJoining> elements, AccountingLineGroupDefinition groupDefinition, AccountingDocument document, AccountingLine accountingLine, boolean newLine, Map unconvertedValues, String accountingLinePropertyName);
058
059 /**
060 * Performs any transformations that should happen after tablification
061 * @param rows the tablified rows
062 * @param groupDefinition the data dictionary definition of the group to render
063 * @param document the Accounting Document we're rendering lines from
064 * @param accountingLine the line we're rendering the line which is being rendered
065 * @param newLine true if what is being rendered is the new line in the form; false otherwise
066 */
067 public abstract void performPostTablificationTransformations(List<AccountingLineTableRow> rows, AccountingLineGroupDefinition groupDefinition, AccountingDocument document, AccountingLine accountingLine, boolean newLine);
068
069 /**
070 * Looks in likely places to find the form that is used by the page context for rendering an accounting document
071 * @param pageContext the pageContext to find the form in
072 * @return the form for the page being rendered
073 */
074 public abstract KualiAccountingDocumentFormBase findForm(PageContext pageContext);
075
076 /**
077 * Based on the control type of the field, returns a proper field renderer
078 * @return the field renderer which will properly display this field
079 */
080 public abstract FieldRenderer getFieldRendererForField(Field field, AccountingLine accountingLineToRender);
081
082 /**
083 * Begins to create an AccountingLineViewFieldDefinition, based on the information held within the given MaintainableFieldDefinition
084 * @param fieldDefinition the field definition to create a generic accounting line view field version of
085 * @return a basic AccountingLineViewFieldDefinition
086 */
087 public abstract AccountingLineViewFieldDefinition createGenericAccountingLineViewFieldDefinition(MaintainableFieldDefinition fieldDefinition);
088 }