001/** 002 * Copyright 2005-2015 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.rice.kns.datadictionary; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase; 020import org.kuali.rice.krad.datadictionary.DataDictionaryException; 021 022import java.util.ArrayList; 023import java.util.List; 024 025/** 026 * The maintainableSection element defines one section of the maintenance document. 027 * 028 * JSTL: maintainableSection is a Map which is accessed by an integer representing the sequential occurrence of the 029 * section. 030 * e.g. "0", "1", etc. This map contains entries with the following keys: 031 * * index (String) - e.g. "0" for first section, etc. 032 * * title (String) 033 * * maintainableItems (Map) 034 * 035 * @deprecated Use sections inside of {@link org.kuali.rice.krad.uif.view.MaintenanceDocumentView}. 036 */ 037@Deprecated 038public class MaintainableSectionDefinition extends DataDictionaryDefinitionBase { 039 private static final long serialVersionUID = -8615694293159113523L; 040 041 protected String title; 042 043 protected List<MaintainableItemDefinition> maintainableItems = new ArrayList<MaintainableItemDefinition>(); 044 045 protected boolean hidden = false; 046 047 protected boolean defaultOpen = true; 048 049 protected String helpUrl; 050 051 public MaintainableSectionDefinition() {} 052 053 /** 054 * @return title 055 */ 056 public String getTitle() { 057 return title; 058 } 059 060 /** 061 * Default the ID to the title for now. 062 * 063 * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase#getId() 064 */ 065 @Override 066 public String getId() { 067 if (StringUtils.isBlank(id)) { 068 return title; 069 } 070 return id; 071 } 072 073 074 /** 075 * Sets title of the Section. 076 * 077 * @throws IllegalArgumentException if the given title is blank 078 */ 079 public void setTitle(String title) { 080 if (StringUtils.isBlank(title)) { 081 throw new IllegalArgumentException("invalid (blank) title"); 082 } 083 084 this.title = title; 085 } 086 087 /** 088 * @return Collection of all MaintainableFieldDefinitions associated with this MaintainableSection, in the order in which they 089 * were added 090 */ 091 public List<MaintainableItemDefinition> getMaintainableItems() { 092 return maintainableItems; 093 } 094 095 096 /** 097 * Directly validate simple fields, call completeValidation on Definition fields. 098 * 099 * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(Class, Class) 100 */ 101 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) { 102 if (StringUtils.contains(title, ",") && StringUtils.isBlank(id)) { 103 throw new DataDictionaryException("The title for maintainable section \"" + title + "\" for class " + rootBusinessObjectClass.getName() + 104 " contains a comma. In this case, the id property must be defined and it may not contain a comma"); 105 } 106 if (StringUtils.contains(id, ",")) { 107 throw new DataDictionaryException("The id for maintainable section \"" + id + "\" for class " + rootBusinessObjectClass.getName() + 108 " contains a comma, which is not allowed."); 109 } 110 for ( MaintainableItemDefinition maintainableItem : maintainableItems ) { 111 maintainableItem.completeValidation(rootBusinessObjectClass, null); 112 } 113 } 114 115 public String toString() { 116 return "MaintainableSectionDefinition '" + getTitle() + "'"; 117 } 118 119 120 public boolean isHidden() { 121 return this.hidden; 122 } 123 124 125 /** Whether to hide the entire section, tab and all. */ 126 public void setHidden(boolean hidden) { 127 this.hidden = hidden; 128 } 129 130 131 /** 132 The maintainableItems element defines the components of a 133 section. These may include fields, sub-section headers, 134 and fields. 135 136 JSTL: maintainableItems is a Map which is accessed by a 137 key of "maintainableItems". This map contains entries with 138 the following keys: 139 * name of first item in the section 140 * name of second item in the section 141 * etc. 142 The corresponding value is an ExportMap which is dependent 143 upon the type of the item as follows: 144 145 subSectionHeader ExportMap 146 In this case, the ExportMap contains the following 147 keys and values: 148 **Key** **Value** 149 name name of subSectionHeader 150 151 maintainableField ExportMap 152 In this case, the ExportMap contains the following 153 keys and values: 154 **Key** **Value** 155 field true 156 name name of maintainableField 157 required true or false 158 159 maintainableCollection ExportMap 160 In this case, the ExportMap contains the following 161 keys and values: 162 **Key** **Value** 163 collection true 164 name name of collection 165 dataObjectClass name of collection class 166 */ 167 public void setMaintainableItems(List<MaintainableItemDefinition> maintainableItems) { 168 for ( MaintainableItemDefinition maintainableItem : maintainableItems ) { 169 if (maintainableItem == null) { 170 throw new IllegalArgumentException("invalid (null) maintainableItem"); 171 } 172 } 173 174 this.maintainableItems = maintainableItems; 175 } 176 177 /** 178 * @return the defaultOpen 179 */ 180 public boolean isDefaultOpen() { 181 return this.defaultOpen; 182 } 183 184 /** 185 * @param defaultOpen the defaultOpen to set 186 */ 187 public void setDefaultOpen(boolean defaultOpen) { 188 this.defaultOpen = defaultOpen; 189 } 190 191 public String getHelpUrl() { 192 return helpUrl; 193 } 194 195 public void setHelpUrl(String helpUrl) { 196 this.helpUrl = helpUrl; 197 } 198 199}