Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CollectionDefinition |
|
| 1.6;1.6 |
1 | /* | |
2 | * Copyright 2005-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
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 | ||
17 | package org.kuali.rice.kns.datadictionary; | |
18 | ||
19 | import org.apache.commons.lang.StringUtils; | |
20 | import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; | |
21 | ||
22 | /** | |
23 | * A single Collection attribute definition in the DataDictionary, which contains information relating to the display, validation, | |
24 | * and general maintenance of a specific Collection attribute of an entry. | |
25 | * | |
26 | * | |
27 | */ | |
28 | public class CollectionDefinition extends DataDictionaryDefinitionBase { | |
29 | private static final long serialVersionUID = -2644072136271281041L; | |
30 | ||
31 | protected String name; | |
32 | protected String label; | |
33 | protected String shortLabel; | |
34 | protected String elementLabel; | |
35 | ||
36 | protected String summary; | |
37 | protected String description; | |
38 | ||
39 | 0 | public CollectionDefinition() {} |
40 | ||
41 | public String getName() { | |
42 | 0 | return name; |
43 | } | |
44 | ||
45 | public void setName(String name) { | |
46 | 0 | if (StringUtils.isBlank(name)) { |
47 | 0 | throw new IllegalArgumentException("invalid (blank) name"); |
48 | } | |
49 | 0 | this.name = name; |
50 | 0 | } |
51 | ||
52 | public String getLabel() { | |
53 | 0 | return label; |
54 | } | |
55 | ||
56 | public void setLabel(String label) { | |
57 | 0 | if (StringUtils.isBlank(label)) { |
58 | 0 | throw new IllegalArgumentException("invalid (blank) label"); |
59 | } | |
60 | 0 | this.label = label; |
61 | 0 | } |
62 | ||
63 | /** | |
64 | * @return the shortLabel, or the label if no shortLabel has been set | |
65 | */ | |
66 | public String getShortLabel() { | |
67 | 0 | return (shortLabel != null) ? shortLabel : label; |
68 | } | |
69 | ||
70 | public void setShortLabel(String shortLabel) { | |
71 | 0 | if (StringUtils.isBlank(shortLabel)) { |
72 | 0 | throw new IllegalArgumentException("invalid (blank) shortLabel"); |
73 | } | |
74 | 0 | this.shortLabel = shortLabel; |
75 | 0 | } |
76 | ||
77 | /** | |
78 | * Gets the elementLabel attribute. | |
79 | * @return Returns the elementLabel. | |
80 | */ | |
81 | public String getElementLabel() { | |
82 | 0 | return elementLabel; |
83 | } | |
84 | ||
85 | /** | |
86 | The elementLabel defines the name to be used for a single object | |
87 | within the collection. For example: "Address" may be the name | |
88 | of one object within the "Addresses" collection. | |
89 | */ | |
90 | public void setElementLabel(String elementLabel) { | |
91 | 0 | this.elementLabel = elementLabel; |
92 | 0 | } |
93 | ||
94 | public String getSummary() { | |
95 | 0 | return summary; |
96 | } | |
97 | ||
98 | /** | |
99 | The summary element is used to provide a short description of the | |
100 | attribute or collection. This is designed to be used for help purposes. | |
101 | */ | |
102 | public void setSummary(String summary) { | |
103 | 0 | this.summary = summary; |
104 | 0 | } |
105 | ||
106 | public String getDescription() { | |
107 | 0 | return description; |
108 | } | |
109 | ||
110 | /** | |
111 | The description element is used to provide a long description of the | |
112 | attribute or collection. This is designed to be used for help purposes. | |
113 | */ | |
114 | public void setDescription(String description) { | |
115 | 0 | this.description = description; |
116 | 0 | } |
117 | ||
118 | ||
119 | /** | |
120 | * Directly validate simple fields, call completeValidation on Definition fields. | |
121 | * | |
122 | * @see org.kuali.rice.kns.datadictionary.DataDictionaryEntry#completeValidation() | |
123 | */ | |
124 | public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) { | |
125 | 0 | if (!DataDictionary.isCollectionPropertyOf(rootBusinessObjectClass, name)) { |
126 | 0 | throw new AttributeValidationException("property '" + name + "' is not a collection property of class '" + rootBusinessObjectClass + "' (" + "" + ")"); |
127 | } | |
128 | 0 | } |
129 | ||
130 | ||
131 | /** | |
132 | * @see java.lang.Object#toString() | |
133 | */ | |
134 | public String toString() { | |
135 | 0 | return "CollectionDefinition for collection " + getName(); |
136 | } | |
137 | } |