View Javadoc
1   /*
2    * Copyright 2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.document.service;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import javax.servlet.jsp.PageContext;
22  
23  import org.kuali.ole.sys.businessobject.AccountingLine;
24  import org.kuali.ole.sys.document.AccountingDocument;
25  import org.kuali.ole.sys.document.datadictionary.AccountingLineGroupDefinition;
26  import org.kuali.ole.sys.document.datadictionary.AccountingLineViewFieldDefinition;
27  import org.kuali.ole.sys.document.web.AccountingLineTableRow;
28  import org.kuali.ole.sys.document.web.TableJoining;
29  import org.kuali.ole.sys.document.web.renderers.FieldRenderer;
30  import org.kuali.ole.sys.web.struts.KualiAccountingDocumentFormBase;
31  import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition;
32  import org.kuali.rice.kns.web.ui.Field;
33  
34  /**
35   * Service that helps render accounting lines
36   */
37  public interface AccountingLineRenderingService {
38      
39      /**
40       * Given a list of renderable elements, determines how to split that into rows, cells, and fields 
41       * @param elements renderable elements to find table form for 
42       * @return a list of table rows that can be rendered
43       */
44      public abstract List<AccountingLineTableRow> tablify(List<TableJoining> elements);
45      
46      /**
47       * Performs any known transformations against the List of AccountingLineViewRenderableElements
48       * @param elements the List of elements to transform
49       * @param definition the accounting line group definition that gives instructions to the particular rendering we're attempting
50       * @param document the Accounting Document we're rendering lines from
51       * @param accountingLine the line we're rendering
52       * @param newLine true if what is being rendered is the new line in the form; false otherwise
53       * @param unconvertedValues any unconverted values stored in the form
54       * @param accountingLinePropertyName the property path to this accounting line
55       */
56      public abstract void performPreTablificationTransformations(List<TableJoining> elements, AccountingLineGroupDefinition groupDefinition, AccountingDocument document, AccountingLine accountingLine, boolean newLine, Map unconvertedValues, String accountingLinePropertyName);
57      
58      /**
59       * Performs any transformations that should happen after tablification
60       * @param rows the tablified rows
61       * @param groupDefinition the data dictionary definition of the group to render
62       * @param document the Accounting Document we're rendering lines from
63       * @param accountingLine the line we're rendering the line which is being rendered
64       * @param newLine true if what is being rendered is the new line in the form; false otherwise
65       */
66      public abstract void performPostTablificationTransformations(List<AccountingLineTableRow> rows, AccountingLineGroupDefinition groupDefinition, AccountingDocument document, AccountingLine accountingLine, boolean newLine);
67      
68      /**
69       * Looks in likely places to find the form that is used by the page context for rendering an accounting document
70       * @param pageContext the pageContext to find the form in
71       * @return the form for the page being rendered
72       */
73      public abstract KualiAccountingDocumentFormBase findForm(PageContext pageContext);
74      
75      /**
76       * Based on the control type of the field, returns a proper field renderer
77       * @return the field renderer which will properly display this field
78       */
79      public abstract FieldRenderer getFieldRendererForField(Field field, AccountingLine accountingLineToRender);
80      
81      /**
82       * Begins to create an AccountingLineViewFieldDefinition, based on the information held within the given MaintainableFieldDefinition
83       * @param fieldDefinition the field definition to create a generic accounting line view field version of
84       * @return a basic AccountingLineViewFieldDefinition
85       */
86      public abstract AccountingLineViewFieldDefinition createGenericAccountingLineViewFieldDefinition(MaintainableFieldDefinition fieldDefinition);
87  }