View Javadoc
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.exporter;
17  
18  import java.util.Iterator;
19  
20  import org.kuali.rice.kns.datadictionary.FieldDefinition;
21  import org.kuali.rice.kns.datadictionary.InquiryDefinition;
22  import org.kuali.rice.kns.datadictionary.InquirySectionDefinition;
23  import org.kuali.rice.kns.datadictionary.BusinessObjectEntry;
24  import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
25  
26  /**
27   * InquiryMapBuilder
28   * 
29   * @deprecated Only used by KNS classes, no replacement.
30   */
31  @Deprecated
32  public class InquiryMapBuilder {
33  
34      /**
35       * Default constructor
36       */
37      public InquiryMapBuilder() {
38      }
39  
40  
41      /**
42       * @param inquiry
43       * @return ExportMap containing the standard entries for the entry's InquiryDefinition, or null if the given entry has no
44       *         inquiryDefinition
45       */
46      public ExportMap buildInquiryMap(BusinessObjectEntry entry) {
47      	try {
48  	        ExportMap inquiryMap = null;
49  	
50  	        if (entry.hasInquiryDefinition()) {
51  	            InquiryDefinition inquiryDefinition = entry.getInquiryDefinition();
52  	            inquiryMap = new ExportMap("inquiry");
53  	
54  	            inquiryMap.set("title", inquiryDefinition.getTitle());
55  	
56  	            inquiryMap.set(buildInquiryFieldsMap(inquiryDefinition));
57  	        }
58  	
59  	        return inquiryMap;
60      	} catch ( Exception ex ) {
61      		throw new RuntimeException( "Unable to build inquiry Map for " + entry, ex );
62      	}
63      }
64  
65      private ExportMap buildInquiryFieldsMap(InquiryDefinition inquiryDefinition) {
66          ExportMap inquiryFieldsMap = new ExportMap("inquiryFields");
67  
68          for (Iterator i = inquiryDefinition.getInquirySections().iterator(); i.hasNext();) {
69              InquirySectionDefinition inquirySection = (InquirySectionDefinition) i.next();
70              for (Iterator iter = inquirySection.getInquiryFields().iterator(); iter.hasNext();) {
71                  FieldDefinition FieldDefinition = (FieldDefinition) iter.next();
72                  inquiryFieldsMap.set(MapperUtils.buildFieldMap(FieldDefinition));
73              }
74          }
75  
76          return inquiryFieldsMap;
77      }
78  }