1 /**
2 * Copyright 2005-2012 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.bo.BusinessObject;
19 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException;
20
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 /**
26 The inquiryCollection defines a collection within the Business Object which contains
27 data that should be displayed with the BO when the inquiry is performed.
28
29 Each inquiryCollection defines a set of data fields, nested inquiryCollections
30 and summaryFields. The summaryFields will be reported in the header of
31 this inquiryCollection, .
32
33 DD: See InquiryCollectionDefinition.java
34 JSTL: The inquiryCollection element is a Map with the following keys:
35 * name (String)
36 * dataObjectClass (String)
37 * numberOfColumns (String)
38 * inquiryFields (Map)
39 * inquiryCollections (Map, optional)
40 * summaryTitle (String)
41 * summaryFields (Map, optional)
42 */
43 @Deprecated
44 public class InquiryCollectionDefinition extends FieldDefinition implements CollectionDefinitionI {
45 private static final long serialVersionUID = 2257743293609536893L;
46
47 protected Class<? extends BusinessObject> businessObjectClass;
48
49 protected Integer numberOfColumns = 1;
50
51 protected Map<String,FieldDefinition> inquiryFieldMap = new HashMap<String, FieldDefinition>();
52 protected Map<String,InquiryCollectionDefinition> inquiryCollectionMap = new HashMap<String, InquiryCollectionDefinition>();
53 protected Map<String,FieldDefinitionI> summaryFieldMap = new HashMap<String, FieldDefinitionI>();
54 protected List<FieldDefinition> inquiryFields = new ArrayList<FieldDefinition>();
55 protected List<InquiryCollectionDefinition> inquiryCollections = new ArrayList<InquiryCollectionDefinition>();
56 protected List<FieldDefinition> summaryFields = new ArrayList<FieldDefinition>();
57
58 protected String summaryTitle;
59
60
61 public InquiryCollectionDefinition() {}
62
63 public Class<? extends BusinessObject> getBusinessObjectClass() {
64 return businessObjectClass;
65 }
66
67 /**
68 This attribute is used in many contexts, for example, in maintenance docs, it's used to specify the classname
69 of the BO being maintained.
70 */
71 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
72 this.businessObjectClass = businessObjectClass;
73 }
74
75 public Integer getNumberOfColumns() {
76 return numberOfColumns;
77 }
78
79 /**
80 numberOfColumns = the number of fields to be displayed in each row of the inquiry section.
81 For example, numberOfColumns = 2 indicates that the label and values for two fields will be
82 displayed in each row as follows:
83 field1label field1value | field2label field2value
84 field3label field3value | field4label field4value
85 etc.
86 */
87 public void setNumberOfColumns(Integer numberOfColumns) {
88 this.numberOfColumns = numberOfColumns;
89 }
90
91 public String getName() {
92 return getAttributeName();
93 }
94
95 public List<? extends CollectionDefinitionI> getCollections() {
96 return inquiryCollections;
97 }
98
99 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 }