01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.datadictionary;
17:
18: import org.apache.commons.logging.Log;
19: import org.apache.commons.logging.LogFactory;
20: import org.kuali.core.datadictionary.exception.AttributeValidationException;
21:
22: public class SupportAttributeDefinition extends
23: PrimitiveAttributeDefinition {
24: // logger
25: private static Log LOG = LogFactory
26: .getLog(SupportAttributeDefinition.class);
27:
28: private boolean identifier;
29:
30: public SupportAttributeDefinition() {
31: LOG.debug("creating new SupportAttributeDefinition");
32: }
33:
34: public boolean isIdentifier() {
35: return identifier;
36: }
37:
38: public void setIdentifier(boolean identifier) {
39: this .identifier = identifier;
40: }
41:
42: /**
43: * Directly validate simple fields.
44: *
45: * @see org.kuali.core.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object)
46: */
47: public void completeValidation(Class rootBusinessObjectClass,
48: Class otherBusinessObjectClass,
49: ValidationCompletionUtils validationCompletionUtils) {
50: String sourceClassName = rootBusinessObjectClass.getName();
51: if (!validationCompletionUtils.isPropertyOf(
52: rootBusinessObjectClass, getSourceName())) {
53: throw new AttributeValidationException(
54: "unable to find attribute '" + getSourceName()
55: + "' in relationship class '"
56: + rootBusinessObjectClass + "' ("
57: + getParseLocation() + ")");
58: }
59: String targetClassName = otherBusinessObjectClass.getName();
60: if (!validationCompletionUtils.isPropertyOf(
61: otherBusinessObjectClass, getTargetName())) {
62: throw new AttributeValidationException(
63: "unable to find attribute '" + getTargetName()
64: + "' in related class '"
65: + otherBusinessObjectClass.getName()
66: + "' (" + getParseLocation() + ")");
67: }
68:
69: // Class sourceClass = validationCompletionUtils.getAttributeClass(rootBusinessObjectClass, getSourceName());
70: // Class targetClass = validationCompletionUtils.getAttributeClass(otherBusinessObjectClass, getTargetName());
71: // if (!StringUtils.equals(sourceClass.getName(), targetClass.getName())) {
72: // String sourcePath = sourceClassName + "." + getSourceName();
73: // String targetPath = targetClassName + "." + getTargetName();
74: //
75: // throw new AttributeValidationException("source attribute '" + sourcePath + "' and target attribute '" + targetPath + "' are of differing types (" + getParseLocation() + ")");
76: // }
77: }
78:
79: /**
80: * @see java.lang.Object#toString()
81: */
82: @Override
83: public String toString() {
84: return "SupportAttributeDefinition (" + getSourceName() + ","
85: + getTargetName() + "," + identifier + ")";
86: }
87:
88: }
|