1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.sys.document.datadictionary;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.ole.sys.businessobject.AccountingLine;
22  import org.kuali.ole.sys.document.web.TableJoining;
23  import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
24  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
25  
26  
27  
28  
29  public class AccountingLineViewDefinition extends DataDictionaryDefinitionBase {
30      private List<AccountingLineViewRenderableElementDefinition> elements;
31  
32      
33  
34  
35  
36  
37      public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
38          if (elements == null || elements.size() == 0) {
39              
40              throw new AttributeValidationException("Please specify at least one element to be rendered for an accounting line view.");
41          }
42          for (AccountingLineViewRenderableElementDefinition elementDefinition : elements) {
43              if (elementDefinition instanceof AccountingLineViewLineDefinition) {
44                  throw new AttributeValidationException("AccountingViewLine definitions must always be wrapped by AccountingLineViewLines definitions");
45              }
46          }
47      }
48  
49      
50  
51  
52  
53      public List<AccountingLineViewRenderableElementDefinition> getElements() {
54          return elements;
55      }
56  
57      
58  
59  
60  
61      public void setElements(List<AccountingLineViewRenderableElementDefinition> elements) {
62          this.elements = elements;
63      }
64      
65      
66  
67  
68  
69  
70      public List<TableJoining> getAccountingLineLayoutElements(Class<? extends AccountingLine> accountingLineClass) {
71          List<TableJoining> layoutElements = new ArrayList<TableJoining>();
72          for (AccountingLineViewRenderableElementDefinition layoutElementDefinition : elements) {
73              final TableJoining layoutElement = layoutElementDefinition.createLayoutElement(accountingLineClass);
74              if (layoutElement != null) {
75                  layoutElements.add(layoutElement);
76              }
77          }
78          return layoutElements;
79      }
80  }