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.kim.type;
017    
018    import org.apache.commons.lang.ClassUtils;
019    import org.apache.commons.lang.builder.ToStringBuilder;
020    import org.kuali.rice.core.api.util.ClassLoaderUtils;
021    import org.kuali.rice.krad.bo.BusinessObject;
022    import org.kuali.rice.krad.datadictionary.AttributeDefinition;
023    import org.kuali.rice.krad.datadictionary.exception.ClassValidationException;
024    
025    import java.util.Map;
026    
027    /**
028     * @deprecated A krad integrated type service base class will be provided in the future.
029     * This is only used for the legacy {@link DataDictionaryTypeServiceBase}.
030     */
031    @Deprecated
032    public final class KimAttributeDefinition extends AttributeDefinition {
033            private static final long serialVersionUID = 7006569761728813805L;
034    
035            protected Map<String, String> lookupInputPropertyConversions;
036            protected Map<String, String> lookupReturnPropertyConversions;
037            protected String lookupBoClass;
038        protected String sortCode;
039            protected String kimAttrDefnId;
040            protected String kimTypeId;
041    
042            /**
043             * @return the sortCode
044             */
045            public String getSortCode() {
046                    return this.sortCode;
047            }
048    
049            /**
050             * @param sortCode
051             *            the sortCode to set
052             */
053            public void setSortCode(String sortCode) {
054                    this.sortCode = sortCode;
055            }
056    
057            public String getKimAttrDefnId() {
058                    return this.kimAttrDefnId;
059            }
060    
061            public void setKimAttrDefnId(String kimAttrDefnId) {
062                    this.kimAttrDefnId = kimAttrDefnId;
063            }
064    
065            /**
066             * @return the kimTypeId
067             */
068            public String getKimTypeId() {
069                    return this.kimTypeId;
070            }
071    
072            /**
073             * @param kimTypeId the kimTypeId to set
074             */
075            public void setKimTypeId(String kimTypeId) {
076                    this.kimTypeId = kimTypeId;
077            }
078    
079    
080            /**
081             * @return the lookupInputPropertyConversions
082             */
083            public Map<String, String> getLookupInputPropertyConversions() {
084                    return this.lookupInputPropertyConversions;
085            }
086    
087            /**
088             * @param lookupInputPropertyConversions
089             *            the lookupInputPropertyConversions to set
090             */
091            public void setLookupInputPropertyConversions(Map<String, String> lookupInputPropertyConversions) {
092                    this.lookupInputPropertyConversions = lookupInputPropertyConversions;
093            }
094    
095            /**
096             * @return the lookupReturnPropertyConversions
097             */
098            public Map<String, String> getLookupReturnPropertyConversions() {
099                    return this.lookupReturnPropertyConversions;
100            }
101    
102            /**
103             * @param lookupReturnPropertyConversions
104             *            the lookupReturnPropertyConversions to set
105             */
106            public void setLookupReturnPropertyConversions(Map<String, String> lookupReturnPropertyConversions) {
107                    this.lookupReturnPropertyConversions = lookupReturnPropertyConversions;
108            }
109    
110            /**
111             * @see java.lang.Object#toString()
112             */
113            public String toString() {
114                    return new ToStringBuilder( this )
115                            .append( "name", getName() )
116                            .append( "label", getLabel() )
117                            .append( "lookupBoClass", this.lookupBoClass )
118                            .append( "required", isRequired() )
119                            .append( "lookupInputPropertyConversions", this.lookupInputPropertyConversions )
120                            .append( "lookupReturnPropertyConversions", this.lookupReturnPropertyConversions )
121                            .toString();
122            }
123    
124            public String getLookupBoClass() {
125                    return this.lookupBoClass;
126            }
127    
128            public void setLookupBoClass(String lookupBoClass) {
129                    this.lookupBoClass = lookupBoClass;
130            }
131    
132        public boolean isHasLookupBoDefinition() {
133            return true;
134        }
135    
136    
137            @SuppressWarnings("unchecked")
138            @Override
139            public void completeValidation(Class rootObjectClass, Class otherObjectClass) {
140                    if (lookupBoClass != null) {
141                    try {
142                            Class lookupBoClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getLookupBoClass());
143                            if (!BusinessObject.class.isAssignableFrom(lookupBoClassObject)) {
144                                    throw new ClassValidationException("lookupBoClass is not a valid instance of " + BusinessObject.class.getName() + " instead was: " + lookupBoClassObject.getName());
145                            }
146                    } catch (ClassNotFoundException e) {
147                            throw new ClassValidationException("lookupBoClass could not be found: " + getLookupBoClass(), e);
148                    }
149            }
150                    super.completeValidation(rootObjectClass, otherObjectClass);
151            }
152        
153        
154    
155            
156    }