001 /** 002 * Copyright 2005-2013 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 */ 016 package org.kuali.rice.kns.datadictionary; 017 018 import org.kuali.rice.krad.bo.BusinessObject; 019 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException; 020 021 import java.util.ArrayList; 022 import java.util.HashMap; 023 import java.util.List; 024 import java.util.Map; 025 /** 026 The inquiryCollection defines a collection within the Business Object which contains 027 data that should be displayed with the BO when the inquiry is performed. 028 029 Each inquiryCollection defines a set of data fields, nested inquiryCollections 030 and summaryFields. The summaryFields will be reported in the header of 031 this inquiryCollection, . 032 033 DD: See InquiryCollectionDefinition.java 034 JSTL: The inquiryCollection element is a Map with the following keys: 035 * name (String) 036 * dataObjectClass (String) 037 * numberOfColumns (String) 038 * inquiryFields (Map) 039 * inquiryCollections (Map, optional) 040 * summaryTitle (String) 041 * summaryFields (Map, optional) 042 */ 043 @Deprecated 044 public class InquiryCollectionDefinition extends FieldDefinition implements CollectionDefinitionI { 045 private static final long serialVersionUID = 2257743293609536893L; 046 047 protected Class<? extends BusinessObject> businessObjectClass; 048 049 protected Integer numberOfColumns = 1; 050 051 protected Map<String,FieldDefinition> inquiryFieldMap = new HashMap<String, FieldDefinition>(); 052 protected Map<String,InquiryCollectionDefinition> inquiryCollectionMap = new HashMap<String, InquiryCollectionDefinition>(); 053 protected Map<String,FieldDefinitionI> summaryFieldMap = new HashMap<String, FieldDefinitionI>(); 054 protected List<FieldDefinition> inquiryFields = new ArrayList<FieldDefinition>(); 055 protected List<InquiryCollectionDefinition> inquiryCollections = new ArrayList<InquiryCollectionDefinition>(); 056 protected List<FieldDefinition> summaryFields = new ArrayList<FieldDefinition>(); 057 058 protected String summaryTitle; 059 060 061 public InquiryCollectionDefinition() {} 062 063 public Class<? extends BusinessObject> getBusinessObjectClass() { 064 return businessObjectClass; 065 } 066 067 /** 068 This attribute is used in many contexts, for example, in maintenance docs, it's used to specify the classname 069 of the BO being maintained. 070 */ 071 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) { 072 this.businessObjectClass = businessObjectClass; 073 } 074 075 public Integer getNumberOfColumns() { 076 return numberOfColumns; 077 } 078 079 /** 080 numberOfColumns = the number of fields to be displayed in each row of the inquiry section. 081 For example, numberOfColumns = 2 indicates that the label and values for two fields will be 082 displayed in each row as follows: 083 field1label field1value | field2label field2value 084 field3label field3value | field4label field4value 085 etc. 086 */ 087 public void setNumberOfColumns(Integer numberOfColumns) { 088 this.numberOfColumns = numberOfColumns; 089 } 090 091 public String getName() { 092 return getAttributeName(); 093 } 094 095 public List<? extends CollectionDefinitionI> getCollections() { 096 return inquiryCollections; 097 } 098 099 public List<? extends FieldDefinitionI> getFields() { 100 return inquiryFields; 101 } 102 103 public boolean getIncludeAddLine() { 104 return false; 105 } 106 107 public boolean isAlwaysAllowCollectionDeletion() { 108 return false; 109 } 110 111 public boolean hasSummaryField(String key) { 112 return summaryFieldMap.containsKey(key); 113 } 114 115 /** 116 The title element is used specify the title that will appear in the header 117 of an Inquiry or Lookup screen. 118 */ 119 public void setSummaryTitle(String summaryTitle) { 120 this.summaryTitle = summaryTitle; 121 } 122 123 public String getSummaryTitle() { 124 return this.summaryTitle; 125 } 126 127 public List<FieldDefinition> getInquiryFields() { 128 return this.inquiryFields; 129 } 130 131 /** 132 JSTL: inquiryFields is a Map which is accessed using a 133 key of "inquiryFields". This map contains the following types 134 of elements: 135 * inquirySubSectionHeader 136 * field 137 * inquiryCollection 138 Each of these entries are keyed by "attributeName". 139 The associated value is the attributeName of the 140 mapped element. 141 142 The inquirySubSectionHeader allows a separator containing text to 143 separate groups of fields. The name attribute is the displayed text. 144 145 DD: See InquirySubSectionHeaderDefinition. 146 JSTL: inquirySubSectionHeader appears in the inquiryFields map as: 147 * key = "attributeName" 148 * value = name of inquirySubSectionHeader 149 150 151 The field element defines the attributes of a single data field. 152 153 DD: See FieldDefinition.java 154 JSTL: The field element is a Map which is accessed using 155 a key of the attributeName. This map contains the following keys: 156 * attributeName (String) 157 * forceInquiry (boolean String) 158 * noInquiry (boolean String) 159 * maxLength (String) 160 161 forceInquiry = true means that the displayed field value will 162 always be made inquirable (this attribute is not used within the code). 163 164 noInquiry = true means that the displayed field will never be made inquirable. 165 166 maxLength = the maximum allowable length of the field in the lookup result fields. In other contexts, 167 like inquiries, this field has no effect. 168 169 */ 170 public void setInquiryFields(List<FieldDefinition> inquiryFields) { 171 inquiryFieldMap.clear(); 172 for ( FieldDefinition inquiryField : inquiryFields ) { 173 if (inquiryField == null) { 174 throw new IllegalArgumentException("invalid (null) inquiryField"); 175 } 176 177 String itemName = inquiryField.getAttributeName(); 178 if (inquiryFieldMap.containsKey(itemName)) { 179 throw new DuplicateEntryException( 180 "duplicate itemName entry for item '" + itemName + "'"); 181 } 182 183 inquiryFieldMap.put(itemName, inquiryField); 184 } 185 186 this.inquiryFields = inquiryFields; 187 } 188 189 public List<InquiryCollectionDefinition> getInquiryCollections() { 190 return inquiryCollections; 191 } 192 193 /** 194 inquirySections allows inquiry to be presented in sections. 195 Each section can have a different format. 196 */ 197 public void setInquiryCollections(List<InquiryCollectionDefinition> inquiryCollections) { 198 inquiryCollectionMap.clear(); 199 for ( InquiryCollectionDefinition inquiryCollection : inquiryCollections ) { 200 if (inquiryCollection == null) { 201 throw new IllegalArgumentException( 202 "invalid (null) inquiryCollection"); 203 } 204 205 String fieldName = inquiryCollection.getName(); 206 if (inquiryCollectionMap.containsKey(fieldName)) { 207 throw new DuplicateEntryException( 208 "duplicate fieldName entry for field '" + fieldName + "'"); 209 } 210 211 inquiryCollectionMap.put(fieldName, inquiryCollection); 212 } 213 this.inquiryCollections = inquiryCollections; 214 } 215 216 public List<FieldDefinition> getSummaryFields() { 217 return this.summaryFields; 218 } 219 220 /** 221 The inquirySummaryField indicates which fields are to appear in 222 the header line of each record in a collection. For example, 223 the header of an address record may contain something like: 224 "Address ( Purchase_Order - San Francisco )" 225 where the two summary fields are: 226 Vendor Type = "Purchase_Order" 227 Vendor City = "San Francisco" 228 229 DD: See FieldDefinition.java 230 */ 231 public void setSummaryFields(List<FieldDefinition> summaryFields) { 232 summaryFieldMap.clear(); 233 for ( FieldDefinition inquiryField : summaryFields ) { 234 if (inquiryField == null) { 235 throw new IllegalArgumentException("invalid (null) summaryField"); 236 } 237 238 String itemName = inquiryField.getAttributeName(); 239 if (summaryFieldMap.containsKey(itemName)) { 240 throw new DuplicateEntryException( 241 "duplicate itemName entry for item '" + itemName + "'"); 242 } 243 244 summaryFieldMap.put(itemName, inquiryField); 245 } 246 this.summaryFields = summaryFields; 247 } 248 249 250 }