View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.student.r2.common.datadictionary;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import org.kuali.rice.krad.datadictionary.AttributeDefinition;
21  import org.kuali.rice.krad.datadictionary.DataObjectEntry;
22  import org.kuali.student.r2.common.datadictionary.dto.AttributeDefinitionInfo;
23  import org.kuali.student.r2.common.datadictionary.dto.DictionaryEntryInfo;
24  
25  /**
26   *
27   * @author nwright
28   */
29  public class Rice2StudentDictionaryEntryConverter {
30  
31      private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(Rice2StudentDictionaryEntryConverter.class);
32  
33      public DictionaryEntryInfo convert(DataObjectEntry rice) {
34          DictionaryEntryInfo.Builder bldr = new DictionaryEntryInfo.Builder();
35          bldr.setObjectClass(rice.getFullClassName());
36          bldr.setName(rice.getName());
37          bldr.setObjectLabel(rice.getObjectLabel());
38          bldr.setObjectDescription(rice.getObjectDescription());
39          bldr.setTitleAttribute(rice.getTitleAttribute());
40          bldr.setPrimaryKeys(rice.getPrimaryKeys());
41          if (rice.getAttributes() != null) {
42              List<AttributeDefinitionInfo> list = new ArrayList(rice.getAttributes().size());
43              for (AttributeDefinition ad : rice.getAttributes()) {
44                  list.add(new Rice2StudentAttributeDefinitionConverter ().convert(ad));
45              }
46              bldr.setAttributes (list);
47          }
48          return bldr.build();
49      }
50  }