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.kfs.rules;
17:
18: import org.kuali.core.service.DataDictionaryService;
19: import org.kuali.kfs.context.SpringContext;
20:
21: /**
22: * This class refers to an attribute which has a value and is labeled in the DataDictionary.
23: */
24: public class AttributeReference {
25: private final String propertyName;
26: private final String valueString;
27: private final String label;
28:
29: /**
30: * Constructor. It takes the value instead of the BO instance (using PropertyUtils or BeanUtils with the propertyName), in order
31: * to promote the use of the property getter, to help usage searches and automated refactorings.
32: *
33: * @param businessObjectClass a class with a business object entry in the DataDictionary
34: * @param propertyName the name of the attribute in the DD entry and on the form (for the error path)
35: * @param value the value of the property on the form (may be null).
36: */
37: public AttributeReference(Class businessObjectClass,
38: String propertyName, Object value) {
39: this .propertyName = propertyName;
40: this .valueString = value == null ? null : value.toString();
41: this .label = SpringContext.getBean(DataDictionaryService.class)
42: .getAttributeLabel(businessObjectClass, propertyName);
43: }
44:
45: /**
46: * @return the name of the attribute in the DD entry and on the form (for the error path)
47: */
48: public String getPropertyName() {
49: return propertyName;
50: }
51:
52: /**
53: * @return the attribute value as a String
54: */
55: public String getValueString() {
56: return valueString;
57: }
58:
59: /**
60: * @return the label of the attribute in the DD
61: */
62: public String getLabel() {
63: return label;
64: }
65: }
|