001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kns.datadictionary.exporter; 017 018 import java.util.Iterator; 019 020 import org.kuali.rice.kns.datadictionary.FieldDefinition; 021 import org.kuali.rice.kns.datadictionary.InquiryDefinition; 022 import org.kuali.rice.kns.datadictionary.InquirySectionDefinition; 023 import org.kuali.rice.kns.datadictionary.BusinessObjectEntry; 024 import org.kuali.rice.krad.datadictionary.exporter.ExportMap; 025 026 /** 027 * InquiryMapBuilder 028 * 029 * 030 */ 031 @Deprecated 032 public class InquiryMapBuilder { 033 034 /** 035 * Default constructor 036 */ 037 public InquiryMapBuilder() { 038 } 039 040 041 /** 042 * @param inquiry 043 * @return ExportMap containing the standard entries for the entry's InquiryDefinition, or null if the given entry has no 044 * inquiryDefinition 045 */ 046 public ExportMap buildInquiryMap(BusinessObjectEntry entry) { 047 try { 048 ExportMap inquiryMap = null; 049 050 if (entry.hasInquiryDefinition()) { 051 InquiryDefinition inquiryDefinition = entry.getInquiryDefinition(); 052 inquiryMap = new ExportMap("inquiry"); 053 054 inquiryMap.set("title", inquiryDefinition.getTitle()); 055 056 inquiryMap.set(buildInquiryFieldsMap(inquiryDefinition)); 057 } 058 059 return inquiryMap; 060 } catch ( Exception ex ) { 061 throw new RuntimeException( "Unable to build inquiry Map for " + entry, ex ); 062 } 063 } 064 065 private ExportMap buildInquiryFieldsMap(InquiryDefinition inquiryDefinition) { 066 ExportMap inquiryFieldsMap = new ExportMap("inquiryFields"); 067 068 for (Iterator i = inquiryDefinition.getInquirySections().iterator(); i.hasNext();) { 069 InquirySectionDefinition inquirySection = (InquirySectionDefinition) i.next(); 070 for (Iterator iter = inquirySection.getInquiryFields().iterator(); iter.hasNext();) { 071 FieldDefinition FieldDefinition = (FieldDefinition) iter.next(); 072 inquiryFieldsMap.set(MapperUtils.buildFieldMap(FieldDefinition)); 073 } 074 } 075 076 return inquiryFieldsMap; 077 } 078 }