001 /* 002 * Copyright 2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 1.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/ecl1.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.student.r2.common.datadictionary; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 import org.kuali.rice.krad.datadictionary.AttributeDefinition; 021 import org.kuali.rice.krad.datadictionary.DataObjectEntry; 022 import org.kuali.student.r2.common.datadictionary.dto.AttributeDefinitionInfo; 023 import org.kuali.student.r2.common.datadictionary.dto.DictionaryEntryInfo; 024 025 /** 026 * 027 * @author nwright 028 */ 029 public class Rice2StudentDictionaryEntryConverter { 030 031 private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(Rice2StudentDictionaryEntryConverter.class); 032 033 public DictionaryEntryInfo convert(DataObjectEntry rice) { 034 DictionaryEntryInfo.Builder bldr = new DictionaryEntryInfo.Builder(); 035 bldr.setObjectClass(rice.getFullClassName()); 036 bldr.setName(rice.getName()); 037 bldr.setObjectLabel(rice.getObjectLabel()); 038 bldr.setObjectDescription(rice.getObjectDescription()); 039 bldr.setTitleAttribute(rice.getTitleAttribute()); 040 bldr.setPrimaryKeys(rice.getPrimaryKeys()); 041 if (rice.getAttributes() != null) { 042 List<AttributeDefinitionInfo> list = new ArrayList(rice.getAttributes().size()); 043 for (AttributeDefinition ad : rice.getAttributes()) { 044 list.add(new Rice2StudentAttributeDefinitionConverter ().convert(ad)); 045 } 046 bldr.setAttributes (list); 047 } 048 return bldr.build(); 049 } 050 }