001: /*
002: * Copyright 2005-2007 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:
017: package org.kuali.core.datadictionary;
018:
019: import org.apache.commons.lang.StringUtils;
020: import org.apache.commons.logging.Log;
021: import org.apache.commons.logging.LogFactory;
022: import org.kuali.core.datadictionary.exception.AttributeValidationException;
023:
024: /**
025: * A single Collection attribute definition in the DataDictionary, which contains information relating to the display, validation,
026: * and general maintenance of a specific Collection attribute of an entry.
027: *
028: *
029: */
030: public class CollectionDefinition extends DataDictionaryDefinitionBase {
031: // logger
032: private static Log LOG = LogFactory
033: .getLog(CollectionDefinition.class);
034:
035: private String name;
036: private String label;
037: private String shortLabel;
038: private String elementLabel;
039:
040: private String summary;
041: private String description;
042:
043: public CollectionDefinition() {
044: LOG.debug("creating new CollectionDefinition");
045: }
046:
047: public String getName() {
048: return name;
049: }
050:
051: public void setName(String name) {
052: if (StringUtils.isBlank(name)) {
053: throw new IllegalArgumentException("invalid (blank) name");
054: }
055: LOG.debug("calling setName '" + name + "'");
056:
057: this .name = name;
058: }
059:
060: public String getLabel() {
061: return label;
062: }
063:
064: public void setLabel(String label) {
065: if (StringUtils.isBlank(label)) {
066: throw new IllegalArgumentException("invalid (blank) label");
067: }
068: LOG.debug("calling setLabel '" + label + "'");
069:
070: this .label = label;
071: }
072:
073: /**
074: * @return the shortLabel, or the label if no shortLabel has been set
075: */
076: public String getShortLabel() {
077: return (shortLabel != null) ? shortLabel : getLabel();
078: }
079:
080: public void setShortLabel(String shortLabel) {
081: if (StringUtils.isBlank(shortLabel)) {
082: throw new IllegalArgumentException(
083: "invalid (blank) shortLabel");
084: }
085: LOG.debug("calling setShortLabel '" + shortLabel + "'");
086:
087: this .shortLabel = shortLabel;
088: }
089:
090: /**
091: * Gets the elementLabel attribute.
092: * @return Returns the elementLabel.
093: */
094: public String getElementLabel() {
095: return elementLabel;
096: }
097:
098: /**
099: * Sets the elementLabel attribute value.
100: * @param elementLabel The elementLabel to set.
101: */
102: public void setElementLabel(String elementLabel) {
103: this .elementLabel = elementLabel;
104: }
105:
106: public String getSummary() {
107: return summary;
108: }
109:
110: public void setSummary(String summary) {
111: if (StringUtils.isBlank(summary)) {
112: throw new IllegalArgumentException(
113: "invalid (blank) summary");
114: }
115: LOG.debug("calling setSummary '" + summary + "'");
116:
117: this .summary = summary;
118: }
119:
120: public String getDescription() {
121: return description;
122: }
123:
124: public void setDescription(String description) {
125: if (StringUtils.isBlank(description)) {
126: throw new IllegalArgumentException(
127: "invalid (blank) description");
128: }
129: LOG.debug("calling setDescription '" + description + "'");
130:
131: this .description = description;
132: }
133:
134: /**
135: * Directly validate simple fields, call completeValidation on Definition fields.
136: *
137: * @see org.kuali.core.datadictionary.DataDictionaryEntry#completeValidation()
138: */
139: public void completeValidation(Class rootBusinessObjectClass,
140: Class otherBusinessObjectClass,
141: ValidationCompletionUtils validationCompletionUtils) {
142:
143: if (!validationCompletionUtils.isCollectionPropertyOf(
144: rootBusinessObjectClass, name)) {
145: throw new AttributeValidationException("property '" + name
146: + "' is not a collection property of class '"
147: + rootBusinessObjectClass + "' ("
148: + getParseLocation() + ")");
149: }
150: }
151:
152: /**
153: * @see java.lang.Object#toString()
154: */
155: public String toString() {
156: return "CollectionDefinition for collection " + getName();
157: }
158: }
|