1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.datadictionary.exporter; |
17 | |
|
18 | |
import java.util.Iterator; |
19 | |
|
20 | |
import org.kuali.rice.krad.datadictionary.BusinessObjectEntry; |
21 | |
import org.kuali.rice.krad.datadictionary.FieldDefinition; |
22 | |
import org.kuali.rice.krad.datadictionary.InquiryDefinition; |
23 | |
import org.kuali.rice.krad.datadictionary.InquirySectionDefinition; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class InquiryMapBuilder { |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public InquiryMapBuilder() { |
36 | 0 | } |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
public ExportMap buildInquiryMap(BusinessObjectEntry entry) { |
45 | |
try { |
46 | 0 | ExportMap inquiryMap = null; |
47 | |
|
48 | 0 | if (entry.hasInquiryDefinition()) { |
49 | 0 | InquiryDefinition inquiryDefinition = entry.getInquiryDefinition(); |
50 | 0 | inquiryMap = new ExportMap("inquiry"); |
51 | |
|
52 | 0 | inquiryMap.set("title", inquiryDefinition.getTitle()); |
53 | |
|
54 | 0 | inquiryMap.set(buildInquiryFieldsMap(inquiryDefinition)); |
55 | |
} |
56 | |
|
57 | 0 | return inquiryMap; |
58 | 0 | } catch ( Exception ex ) { |
59 | 0 | throw new RuntimeException( "Unable to build inquiry Map for " + entry, ex ); |
60 | |
} |
61 | |
} |
62 | |
|
63 | |
private ExportMap buildInquiryFieldsMap(InquiryDefinition inquiryDefinition) { |
64 | 0 | ExportMap inquiryFieldsMap = new ExportMap("inquiryFields"); |
65 | |
|
66 | 0 | for (Iterator i = inquiryDefinition.getInquirySections().iterator(); i.hasNext();) { |
67 | 0 | InquirySectionDefinition inquirySection = (InquirySectionDefinition) i.next(); |
68 | 0 | for (Iterator iter = inquirySection.getInquiryFields().iterator(); iter.hasNext();) { |
69 | 0 | FieldDefinition FieldDefinition = (FieldDefinition) iter.next(); |
70 | 0 | inquiryFieldsMap.set(MapperUtils.buildFieldMap(FieldDefinition)); |
71 | 0 | } |
72 | 0 | } |
73 | |
|
74 | 0 | return inquiryFieldsMap; |
75 | |
} |
76 | |
} |