01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.datadictionary.exporter;
17:
18: import java.util.Iterator;
19:
20: import org.kuali.core.datadictionary.BusinessObjectEntry;
21: import org.kuali.core.datadictionary.FieldDefinition;
22: import org.kuali.core.datadictionary.InquiryDefinition;
23: import org.kuali.core.datadictionary.InquirySectionDefinition;
24:
25: /**
26: * InquiryMapBuilder
27: *
28: *
29: */
30: public class InquiryMapBuilder {
31:
32: /**
33: * Default constructor
34: */
35: public InquiryMapBuilder() {
36: }
37:
38: /**
39: * @param inquiry
40: * @return ExportMap containing the standard entries for the entry's InquiryDefinition, or null if the given entry has no
41: * inquiryDefinition
42: */
43: public ExportMap buildInquiryMap(BusinessObjectEntry entry) {
44: ExportMap inquiryMap = null;
45:
46: if (entry.hasInquiryDefinition()) {
47: InquiryDefinition inquiryDefinition = entry
48: .getInquiryDefinition();
49: inquiryMap = new ExportMap("inquiry");
50:
51: inquiryMap.set("title", inquiryDefinition.getTitle());
52:
53: inquiryMap.set(buildInquiryFieldsMap(inquiryDefinition));
54: }
55:
56: return inquiryMap;
57: }
58:
59: private ExportMap buildInquiryFieldsMap(
60: InquiryDefinition inquiryDefinition) {
61: ExportMap inquiryFieldsMap = new ExportMap("inquiryFields");
62:
63: for (Iterator i = inquiryDefinition.getInquirySections()
64: .iterator(); i.hasNext();) {
65: InquirySectionDefinition inquirySection = (InquirySectionDefinition) i
66: .next();
67: for (Iterator iter = inquirySection.getInquiryFields()
68: .iterator(); iter.hasNext();) {
69: FieldDefinition FieldDefinition = (FieldDefinition) iter
70: .next();
71: inquiryFieldsMap.set(MapperUtils
72: .buildFieldMap(FieldDefinition));
73: }
74: }
75:
76: return inquiryFieldsMap;
77: }
78: }
|