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