001/* 002 * Copyright 2008 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 */ 016package org.kuali.ole.sys.document.datadictionary; 017 018import java.util.List; 019 020import org.apache.commons.lang.StringUtils; 021import org.kuali.ole.sys.businessobject.AccountingLine; 022import org.kuali.ole.sys.document.web.AccountingLineViewLineFillingElement; 023import org.kuali.ole.sys.document.web.HideShowLayoutElement; 024import org.kuali.ole.sys.document.web.TableJoining; 025import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase; 026import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException; 027 028/** 029 * Defines a set of lines of are displayed within a hide/show block 030 */ 031public class AccountingLineViewHideShowLinesDefinition extends DataDictionaryDefinitionBase implements AccountingLineViewLineFillingDefinition { 032 private String label; 033 private String name; 034 private List<AccountingLineViewLineFillingDefinition> lines; 035 036 /** 037 * Validates that name has been set and that at least one line element has been specified 038 * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Class) 039 */ 040 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) { 041 if (StringUtils.isBlank(name)) { 042 throw new AttributeValidationException("Please specify a name for the Hide/Show lines element"); 043 } 044 if (lines == null || lines.size() == 0) { 045 throw new AttributeValidationException("Please specify at least one child line for the Hide/Show lines element"); 046 } 047 } 048 049 /** 050 * @see org.kuali.ole.sys.document.datadictionary.AccountingLineViewRenderableElementDefinition#createLayoutElement(java.lang.Class) 051 */ 052 public TableJoining createLayoutElement(Class<? extends AccountingLine> accountingLineClass) { 053 HideShowLayoutElement hideShowElement = new HideShowLayoutElement(); 054 hideShowElement.setDefinition(this); 055 for (AccountingLineViewLineFillingDefinition line : lines) { 056 hideShowElement.addLine(line.createLineFillingLayoutElement(accountingLineClass)); 057 } 058 return hideShowElement; 059 } 060 061 /** 062 * @see org.kuali.ole.sys.document.datadictionary.AccountingLineViewLineFillingDefinition#createLineFillingLayoutElement(java.lang.Class) 063 */ 064 public AccountingLineViewLineFillingElement createLineFillingLayoutElement(Class<? extends AccountingLine> accountingLineClass) { 065 return (AccountingLineViewLineFillingElement)createLayoutElement(accountingLineClass); 066 } 067 068 /** 069 * Gets the label attribute. 070 * @return Returns the label. 071 */ 072 public String getLabel() { 073 return label; 074 } 075 076 /** 077 * Sets the label attribute value. 078 * @param label The label to set. 079 */ 080 public void setLabel(String label) { 081 this.label = label; 082 } 083 084 /** 085 * Gets the lines attribute. 086 * @return Returns the lines. 087 */ 088 public List<AccountingLineViewLineFillingDefinition> getLines() { 089 return lines; 090 } 091 092 /** 093 * Sets the lines attribute value. 094 * @param lines The lines to set. 095 */ 096 public void setLines(List<AccountingLineViewLineFillingDefinition> lines) { 097 this.lines = lines; 098 } 099 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}