1 /**
2 * Copyright 2005-2015 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 data that should be displayed
27 * with the BO when the inquiry is performed.
28 *
29 * Each inquiryCollection defines a set of data fields, nested inquiryCollections and summaryFields. The summaryFields
30 * will be reported in the header of this inquiryCollection.
31 *
32 * DD: See InquiryCollectionDefinition.java
33 * JSTL: The inquiryCollection element is a Map with the following keys:
34 * * name (String)
35 * * dataObjectClass (String)
36 * * numberOfColumns (String)
37 * * inquiryFields (Map)
38 * * inquiryCollections (Map, optional)
39 * * summaryTitle (String)
40 * * summaryFields (Map, optional)
41 *
42 * @deprecated Use collections inside of {@link org.kuali.rice.krad.uif.view.InquiryView}.
43 */
44 @Deprecated
45 public class InquiryCollectionDefinition extends FieldDefinition implements CollectionDefinitionI {
46 private static final long serialVersionUID = 2257743293609536893L;
47
48 protected Class<? extends BusinessObject> businessObjectClass;
49
50 protected Integer numberOfColumns = 1;
51
52 protected Map<String,FieldDefinition> inquiryFieldMap = new HashMap<String, FieldDefinition>();
53 protected Map<String,InquiryCollectionDefinition> inquiryCollectionMap = new HashMap<String, InquiryCollectionDefinition>();
54 protected Map<String,FieldDefinitionI> summaryFieldMap = new HashMap<String, FieldDefinitionI>();
55 protected List<FieldDefinition> inquiryFields = new ArrayList<FieldDefinition>();
56 protected List<InquiryCollectionDefinition> inquiryCollections = new ArrayList<InquiryCollectionDefinition>();
57 protected List<FieldDefinition> summaryFields = new ArrayList<FieldDefinition>();
58
59 protected String summaryTitle;
60
61
62 public InquiryCollectionDefinition() {}
63
64 public Class<? extends BusinessObject> getBusinessObjectClass() {
65 return businessObjectClass;
66 }
67
68 /**
69 This attribute is used in many contexts, for example, in maintenance docs, it's used to specify the classname
70 of the BO being maintained.
71 */
72 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
73 this.businessObjectClass = businessObjectClass;
74 }
75
76 public Integer getNumberOfColumns() {
77 return numberOfColumns;
78 }
79
80 /**
81 numberOfColumns = the number of fields to be displayed in each row of the inquiry section.
82 For example, numberOfColumns = 2 indicates that the label and values for two fields will be
83 displayed in each row as follows:
84 field1label field1value | field2label field2value
85 field3label field3value | field4label field4value
86 etc.
87 */
88 public void setNumberOfColumns(Integer numberOfColumns) {
89 this.numberOfColumns = numberOfColumns;
90 }
91
92 public String getName() {
93 return getAttributeName();
94 }
95
96 public List<? extends CollectionDefinitionI> getCollections() {
97 return inquiryCollections;
98 }
99
100 public List<? extends FieldDefinitionI> getFields() {
101 return inquiryFields;
102 }
103
104 public boolean getIncludeAddLine() {
105 return false;
106 }
107
108 public boolean isAlwaysAllowCollectionDeletion() {
109 return false;
110 }
111
112 public boolean hasSummaryField(String key) {
113 return summaryFieldMap.containsKey(key);
114 }
115
116 /**
117 The title element is used specify the title that will appear in the header
118 of an Inquiry or Lookup screen.
119 */
120 public void setSummaryTitle(String summaryTitle) {
121 this.summaryTitle = summaryTitle;
122 }
123
124 public String getSummaryTitle() {
125 return this.summaryTitle;
126 }
127
128 public List<FieldDefinition> getInquiryFields() {
129 return this.inquiryFields;
130 }
131
132 /**
133 JSTL: inquiryFields is a Map which is accessed using a
134 key of "inquiryFields". This map contains the following types
135 of elements:
136 * inquirySubSectionHeader
137 * field
138 * inquiryCollection
139 Each of these entries are keyed by "attributeName".
140 The associated value is the attributeName of the
141 mapped element.
142
143 The inquirySubSectionHeader allows a separator containing text to
144 separate groups of fields. The name attribute is the displayed text.
145
146 DD: See InquirySubSectionHeaderDefinition.
147 JSTL: inquirySubSectionHeader appears in the inquiryFields map as:
148 * key = "attributeName"
149 * value = name of inquirySubSectionHeader
150
151
152 The field element defines the attributes of a single data field.
153
154 DD: See FieldDefinition.java
155 JSTL: The field element is a Map which is accessed using
156 a key of the attributeName. This map contains the following keys:
157 * attributeName (String)
158 * forceInquiry (boolean String)
159 * noInquiry (boolean String)
160 * maxLength (String)
161
162 forceInquiry = true means that the displayed field value will
163 always be made inquirable (this attribute is not used within the code).
164
165 noInquiry = true means that the displayed field will never be made inquirable.
166
167 maxLength = the maximum allowable length of the field in the lookup result fields. In other contexts,
168 like inquiries, this field has no effect.
169
170 */
171 public void setInquiryFields(List<FieldDefinition> inquiryFields) {
172 inquiryFieldMap.clear();
173 for ( FieldDefinition inquiryField : inquiryFields ) {
174 if (inquiryField == null) {
175 throw new IllegalArgumentException("invalid (null) inquiryField");
176 }
177
178 String itemName = inquiryField.getAttributeName();
179 if (inquiryFieldMap.containsKey(itemName)) {
180 throw new DuplicateEntryException(
181 "duplicate itemName entry for item '" + itemName + "'");
182 }
183
184 inquiryFieldMap.put(itemName, inquiryField);
185 }
186
187 this.inquiryFields = inquiryFields;
188 }
189
190 public List<InquiryCollectionDefinition> getInquiryCollections() {
191 return inquiryCollections;
192 }
193
194 /**
195 inquirySections allows inquiry to be presented in sections.
196 Each section can have a different format.
197 */
198 public void setInquiryCollections(List<InquiryCollectionDefinition> inquiryCollections) {
199 inquiryCollectionMap.clear();
200 for ( InquiryCollectionDefinition inquiryCollection : inquiryCollections ) {
201 if (inquiryCollection == null) {
202 throw new IllegalArgumentException(
203 "invalid (null) inquiryCollection");
204 }
205
206 String fieldName = inquiryCollection.getName();
207 if (inquiryCollectionMap.containsKey(fieldName)) {
208 throw new DuplicateEntryException(
209 "duplicate fieldName entry for field '" + fieldName + "'");
210 }
211
212 inquiryCollectionMap.put(fieldName, inquiryCollection);
213 }
214 this.inquiryCollections = inquiryCollections;
215 }
216
217 public List<FieldDefinition> getSummaryFields() {
218 return this.summaryFields;
219 }
220
221 /**
222 The inquirySummaryField indicates which fields are to appear in
223 the header line of each record in a collection. For example,
224 the header of an address record may contain something like:
225 "Address ( Purchase_Order - San Francisco )"
226 where the two summary fields are:
227 Vendor Type = "Purchase_Order"
228 Vendor City = "San Francisco"
229
230 DD: See FieldDefinition.java
231 */
232 public void setSummaryFields(List<FieldDefinition> summaryFields) {
233 summaryFieldMap.clear();
234 for ( FieldDefinition inquiryField : summaryFields ) {
235 if (inquiryField == null) {
236 throw new IllegalArgumentException("invalid (null) summaryField");
237 }
238
239 String itemName = inquiryField.getAttributeName();
240 if (summaryFieldMap.containsKey(itemName)) {
241 throw new DuplicateEntryException(
242 "duplicate itemName entry for item '" + itemName + "'");
243 }
244
245 summaryFieldMap.put(itemName, inquiryField);
246 }
247 this.summaryFields = summaryFields;
248 }
249
250
251 }