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 org.kuali.rice.krad.datadictionary.AttributeDefinition;
019    import org.kuali.student.r2.common.datadictionary.dto.AttributeDefinitionInfo;
020    
021    /**
022     *
023     * @author nwright
024     */
025    public class Rice2StudentAttributeDefinitionConverter {
026    
027        private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(Rice2StudentAttributeDefinitionConverter.class);
028    
029        public AttributeDefinitionInfo convert(AttributeDefinition rice) {
030            AttributeDefinitionInfo.Builder bldr = new AttributeDefinitionInfo.Builder();
031            bldr.setName (rice.getName());
032            bldr.setChildEntryName (rice.getChildEntryName());
033            bldr.setDataType (rice.getDataType());
034            bldr.setRequired (rice.isRequired());
035    //        bldr.setMinOccurs (rice.getMustOccurConstraints().get(0).getMin());
036    //        bldr.setMaxOccurs (rice.getMustOccurConstraints().get (0).getMax());
037            bldr.setMinLength (rice.getMinLength());
038            bldr.setMaxLength (rice.getMaxLength());
039            bldr.setForceUppercase (rice.getForceUppercase());
040            bldr.setShortLabel (rice.getShortLabel());
041            bldr.setSummary (rice.getSummary());
042            bldr.setLabel (rice.getLabel());
043            bldr.setDescription (rice.getDescription());
044            bldr.setExclusiveMin (rice.getExclusiveMin());
045            bldr.setInclusiveMax (rice.getInclusiveMax());
046            bldr.setDisplayLabelAttribute (rice.getDisplayLabelAttribute());
047            bldr.setUnique (rice.getUnique());
048            bldr.setCustomValidatorClass (rice.getCustomValidatorClass());
049            bldr.setFormatterClass (rice.getFormatterClass());
050            if (rice.getValidCharactersConstraint() != null) {
051                bldr.setValidCharactersConstraint (new Rice2StudentValidCharactersConstraintConverter ().convert(rice.getValidCharactersConstraint()));
052            }
053            return bldr.build();
054        }
055    }