1 /* 2 * Copyright 2006-2007 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 17 package org.kuali.rice.kns.datadictionary; 18 19 import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase; 20 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException; 21 22 import java.util.ArrayList; 23 import java.util.LinkedHashMap; 24 import java.util.List; 25 import java.util.Map; 26 27 /** 28 * inquirySection defines the format and content of 29 one section of the inquiry. 30 DD: See InquirySectionDefinition.java 31 32 numberOfColumns = the number of fields to be displayed in each row of the inquiry section. 33 For example, numberOfColumns = 2 indicates that the label and values for two fields will be 34 displayed in each row as follows: 35 field1label field1value | field2label field2value 36 field3label field3value | field4label field4value 37 etc. 38 39 * Contains section-related information for inquiry sections 40 * Note: the setters do copious amounts of validation, to facilitate generating errors during the parsing process. 41 */ 42 @Deprecated 43 public class InquirySectionDefinition extends DataDictionaryDefinitionBase { 44 private static final long serialVersionUID = 1565114894539391362L; 45 46 protected String title; 47 protected List<FieldDefinition> inquiryFields = new ArrayList<FieldDefinition>(); 48 protected Map<String, FieldDefinition> inquiryFieldMap = new LinkedHashMap<String, FieldDefinition>(); 49 protected Map inquiryCollections; 50 51 protected Integer numberOfColumns = 1; 52 protected boolean defaultOpen = true; 53 54 public InquirySectionDefinition() {} 55 56 57 /** 58 * @return title 59 */ 60 public String getTitle() { 61 return title; 62 } 63 64 /** 65 * Sets title to the given value. 66 * 67 * @param title 68 * @throws IllegalArgumentException if the given title is blank 69 */ 70 public void setTitle(String title) { 71 this.title = title; 72 } 73 74 /** 75 * @return List of attributeNames of all FieldDefinitions associated with this InquirySection, in the order in 76 * which they were added 77 */ 78 public List<String> getInquiryFieldNames() { 79 List<String> itemNames = new ArrayList<String>(); 80 itemNames.addAll(this.inquiryFieldMap.keySet()); 81 82 return itemNames; 83 } 84 85 /** 86 * @return Collection of all FieldDefinitions associated with this InquirySection, in the order in which they 87 * were added 88 */ 89 public List<FieldDefinition> getInquiryFields() { 90 return inquiryFields; 91 } 92 93 /** 94 * Directly validate simple fields, call completeValidation on Definition fields. 95 * 96 * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object) 97 */ 98 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) { 99 for (FieldDefinition inquiryField : inquiryFields ) { 100 inquiryField.completeValidation(rootBusinessObjectClass, null); 101 } 102 } 103 104 public String toString() { 105 return "InquirySectionDefinition '" + getTitle() + "'"; 106 } 107 108 public Map getInquiryCollections() { 109 return inquiryCollections; 110 } 111 112 /** 113 The inquiryCollection defines a collection within the Business Object which contains 114 data that should be displayed with the BO when the inquiry is performed. 115 116 Each inquiryCollection defines a set of data fields, nested inquiryCollections 117 and summaryFields. The summaryFields will be reported in the header of 118 this inquiryCollection, . 119 120 DD: See InquiryCollectionDefinition.java 121 JSTL: The inquiryCollection element is a Map with the following keys: 122 * name (String) 123 * dataObjectClass (String) 124 * numberOfColumns (String) 125 * inquiryFields (Map) 126 * inquiryCollections (Map, optional) 127 * summaryTitle (String) 128 * summaryFields (Map, optional) 129 */ 130 public void setInquiryCollections(Map inquiryCollections) { 131 this.inquiryCollections = inquiryCollections; 132 } 133 134 public Integer getNumberOfColumns() { 135 return numberOfColumns; 136 } 137 138 /** 139 numberOfColumns = the number of fields to be displayed in each row of the inquiry section. 140 For example, numberOfColumns = 2 indicates that the label and values for two fields will be 141 displayed in each row as follows: 142 field1label field1value | field2label field2value 143 field3label field3value | field4label field4value 144 etc. 145 */ 146 public void setNumberOfColumns(Integer numberOfColumns) { 147 this.numberOfColumns = numberOfColumns; 148 } 149 150 151 /** 152 JSTL: inquiryFields is a Map which is accessed using a 153 key of "inquiryFields". This map contains the following types 154 of elements: 155 * inquirySubSectionHeader 156 * field 157 * inquiryCollection 158 Each of these entries are keyed by "attributeName". 159 The associated value is the attributeName of the 160 mapped element. 161 162 The inquirySubSectionHeader allows a separator containing text to 163 separate groups of fields. The name attribute is the displayed text. 164 165 JSTL: inquirySubSectionHeader appears in the inquiryFields map as: 166 * key = "attributeName" 167 * value = name of inquirySubSectionHeader 168 169 170 The field element defines the attributes of a single data field. 171 172 DD: See FieldDefinition.java 173 JSTL: The field element is a Map which is accessed using 174 a key of the attributeName. This map contains the following keys: 175 * attributeName (String) 176 * forceInquiry (boolean String) 177 * noInquiry (boolean String) 178 * maxLength (String) 179 180 forceInquiry = true means that the displayed field value will 181 always be made inquirable (this attribute is not used within the code). 182 183 noInquiry = true means that the displayed field will never be made inquirable. 184 185 maxLength = the maximum allowable length of the field in the lookup result fields. In other contexts, 186 like inquiries, this field has no effect. 187 */ 188 public void setInquiryFields(List<FieldDefinition> inquiryFields) { 189 inquiryFieldMap.clear(); 190 for (FieldDefinition inquiryField : inquiryFields ) { 191 if (inquiryField == null) { 192 throw new IllegalArgumentException("invalid (null) inquiryField"); 193 } 194 195 String itemName = inquiryField.getAttributeName(); 196 if (inquiryFieldMap.containsKey(itemName)) { 197 throw new DuplicateEntryException("duplicate itemName entry for item '" + itemName + "'"); 198 } 199 200 inquiryFieldMap.put(itemName, inquiryField); 201 } 202 this.inquiryFields = inquiryFields; 203 } 204 205 206 /** 207 * @return the defaultOpen 208 */ 209 public boolean isDefaultOpen() { 210 return this.defaultOpen; 211 } 212 213 214 /** 215 * @param defaultOpen the defaultOpen to set 216 */ 217 public void setDefaultOpen(boolean defaultOpen) { 218 this.defaultOpen = defaultOpen; 219 } 220 221 }