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.datadictionary;
17  
18  import java.util.List;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.ole.sys.businessobject.AccountingLine;
22  import org.kuali.ole.sys.document.web.AccountingLineViewLineFillingElement;
23  import org.kuali.ole.sys.document.web.HideShowLayoutElement;
24  import org.kuali.ole.sys.document.web.TableJoining;
25  import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
26  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
27  
28  /**
29   * Defines a set of lines of are displayed within a hide/show block
30   */
31  public class AccountingLineViewHideShowLinesDefinition extends DataDictionaryDefinitionBase implements AccountingLineViewLineFillingDefinition {
32      private String label;
33      private String name;
34      private List<AccountingLineViewLineFillingDefinition> lines;
35  
36      /**
37       * Validates that name has been set and that at least one line element has been specified
38       * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Class)
39       */
40      public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
41          if (StringUtils.isBlank(name)) {
42              throw new AttributeValidationException("Please specify a name for the Hide/Show lines element");
43          }
44          if (lines == null || lines.size() == 0) {
45              throw new AttributeValidationException("Please specify at least one child line for the Hide/Show lines element");
46          }
47      }
48  
49      /**
50       * @see org.kuali.ole.sys.document.datadictionary.AccountingLineViewRenderableElementDefinition#createLayoutElement(java.lang.Class)
51       */
52      public TableJoining createLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
53          HideShowLayoutElement hideShowElement = new HideShowLayoutElement();
54          hideShowElement.setDefinition(this);
55          for (AccountingLineViewLineFillingDefinition line : lines) {
56              hideShowElement.addLine(line.createLineFillingLayoutElement(accountingLineClass));
57          }
58          return hideShowElement;
59      }
60  
61      /**
62       * @see org.kuali.ole.sys.document.datadictionary.AccountingLineViewLineFillingDefinition#createLineFillingLayoutElement(java.lang.Class)
63       */
64      public AccountingLineViewLineFillingElement createLineFillingLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
65          return (AccountingLineViewLineFillingElement)createLayoutElement(accountingLineClass);
66      }
67  
68      /**
69       * Gets the label attribute. 
70       * @return Returns the label.
71       */
72      public String getLabel() {
73          return label;
74      }
75  
76      /**
77       * Sets the label attribute value.
78       * @param label The label to set.
79       */
80      public void setLabel(String label) {
81          this.label = label;
82      }
83  
84      /**
85       * Gets the lines attribute. 
86       * @return Returns the lines.
87       */
88      public List<AccountingLineViewLineFillingDefinition> getLines() {
89          return lines;
90      }
91  
92      /**
93       * Sets the lines attribute value.
94       * @param lines The lines to set.
95       */
96      public void setLines(List<AccountingLineViewLineFillingDefinition> lines) {
97          this.lines = lines;
98      }
99  
100     /**
101      * Gets the name attribute. 
102      * @return Returns the name.
103      */
104     public String getName() {
105         return name;
106     }
107 
108     /**
109      * Sets the name attribute value.
110      * @param name The name to set.
111      */
112     public void setName(String name) {
113         this.name = name;
114     }
115     
116 }