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