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.datadictionary;
17  
18  import org.kuali.rice.kns.datadictionary.AttributeDefinition;
19  import org.kuali.student.datadictionary.dto.AttributeDefinitionInfo;
20  import org.kuali.student.datadictionary.dto.ValidCharactersConstraintInfo;
21  
22  /**
23   *
24   * @author nwright
25   */
26  public class Rice2StudentAttributeDefinitionConverter {
27  
28      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(Rice2StudentAttributeDefinitionConverter.class);
29  
30      public AttributeDefinitionInfo convert(AttributeDefinition rice) {
31          AttributeDefinitionInfo.Builder bldr = new AttributeDefinitionInfo.Builder();
32          bldr.setName (rice.getName());
33          bldr.setChildEntryName (rice.getChildEntryName());
34          bldr.setDataType (rice.getDataType());
35          bldr.setRequired (rice.isRequired());
36  //        bldr.setMinOccurs (rice.getMustOccurConstraints().get(0).getMin());
37  //        bldr.setMaxOccurs (rice.getMustOccurConstraints().get (0).getMax());
38          bldr.setMinLength (rice.getMinLength());
39          bldr.setMaxLength (rice.getMaxLength());
40          bldr.setForceUppercase (rice.getForceUppercase());
41          bldr.setShortLabel (rice.getShortLabel());
42          bldr.setSummary (rice.getSummary());
43          bldr.setLabel (rice.getLabel());
44          bldr.setDescription (rice.getDescription());
45          bldr.setExclusiveMin (rice.getExclusiveMin());
46          bldr.setInclusiveMax (rice.getInclusiveMax());
47          bldr.setDisplayLabelAttribute (rice.getDisplayLabelAttribute());
48          bldr.setUnique (rice.getUnique());
49          bldr.setCustomValidatorClass (rice.getCustomValidatorClass());
50          bldr.setFormatterClass (rice.getFormatterClass());
51          if (rice.getValidCharactersConstraint() != null) {
52              bldr.setValidCharactersConstraint (new Rice2StudentValidCharactersConstraintConverter ().convert(rice.getValidCharactersConstraint()));
53          }
54          return bldr.build();
55      }
56  }