001/**
002 * Copyright 2005-2018 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 */
016package org.kuali.rice.kns.kim.type;
017
018import java.util.Map;
019
020import org.apache.commons.lang.ClassUtils;
021import org.apache.commons.lang.StringUtils;
022import org.apache.commons.lang.builder.ToStringBuilder;
023import org.kuali.rice.core.api.util.ClassLoaderUtils;
024import org.kuali.rice.krad.datadictionary.AttributeDefinition;
025import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
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
032public 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        @Override
114        public String toString() {
115                return new ToStringBuilder( this )
116                        .append( "name", getName() )
117                        .append( "label", getLabel() )
118                        .append( "lookupBoClass", this.lookupBoClass )
119                        .append( "required", isRequired() )
120                        .append( "lookupInputPropertyConversions", this.lookupInputPropertyConversions )
121                        .append( "lookupReturnPropertyConversions", this.lookupReturnPropertyConversions )
122                        .toString();
123        }
124
125        public String getLookupBoClass() {
126                return this.lookupBoClass;
127        }
128
129        public void setLookupBoClass(String lookupBoClass) {
130                this.lookupBoClass = lookupBoClass;
131        }
132
133    public boolean isHasLookupBoDefinition() {
134        return true;
135    }
136
137
138        @Override
139        public void completeValidation(Class rootObjectClass, Class otherObjectClass, ValidationTrace tracer) {
140                super.completeValidation(rootObjectClass, otherObjectClass,tracer);
141                if ( StringUtils.isNotBlank(lookupBoClass) ) {
142                try {
143                        ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getLookupBoClass());
144                } catch (ClassNotFoundException e) {
145                String currentValues[] = {"property = " + getName(), "class = " + rootObjectClass.getName(), "lookupBoClass = " + getLookupBoClass()};
146                tracer.createError("lookupBoClass could not be found", currentValues);
147                }
148        }
149        }
150
151}