Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AttributeDefinitionBase |
|
| 1.411764705882353;1.412 |
1 | /** | |
2 | * Copyright 2005-2011 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 | package org.kuali.rice.krad.datadictionary; | |
17 | ||
18 | import org.apache.commons.lang.StringUtils; | |
19 | import org.kuali.rice.krad.datadictionary.validation.capability.ExistenceConstrainable; | |
20 | ||
21 | /** | |
22 | * Common class for attribute definitions in the DataDictionary, which contains | |
23 | * information relating to the display, validation, and general maintenance of a | |
24 | * specific attribute of an entry. An attribute can be a simple or complex attribute. | |
25 | * | |
26 | */ | |
27 | 338 | public abstract class AttributeDefinitionBase extends DataDictionaryDefinitionBase implements ExistenceConstrainable{ |
28 | ||
29 | protected String name; | |
30 | ||
31 | protected String label; | |
32 | protected String shortLabel; | |
33 | protected String displayLabelAttribute; | |
34 | ||
35 | protected String messageKey; | |
36 | protected String constraintText; | |
37 | protected String summary; | |
38 | protected String description; | |
39 | ||
40 | 338 | protected Boolean required = Boolean.FALSE; |
41 | ||
42 | public String getName() { | |
43 | 428 | return name; |
44 | } | |
45 | ||
46 | /* | |
47 | * name = name of attribute | |
48 | */ | |
49 | public void setName(String name) { | |
50 | 284 | if (StringUtils.isBlank(name)) { |
51 | 0 | throw new IllegalArgumentException("invalid (blank) name"); |
52 | } | |
53 | 284 | this.name = name; |
54 | 284 | } |
55 | ||
56 | public String getLabel() { | |
57 | 9 | return label; |
58 | } | |
59 | ||
60 | /** | |
61 | * The label element is the field or collection name that will be shown on | |
62 | * inquiry and maintenance screens. This will be overridden by presence of | |
63 | * displayLabelAttribute element. | |
64 | */ | |
65 | public void setLabel(String label) { | |
66 | 0 | if (StringUtils.isBlank(label)) { |
67 | 0 | throw new IllegalArgumentException("invalid (blank) label"); |
68 | } | |
69 | 0 | this.label = label; |
70 | 0 | } |
71 | ||
72 | /** | |
73 | * @return the shortLabel, or the label if no shortLabel has been set | |
74 | */ | |
75 | public String getShortLabel() { | |
76 | 0 | return (shortLabel != null) ? shortLabel : getLabel(); |
77 | } | |
78 | ||
79 | /** | |
80 | * @return the shortLabel directly, without substituting in the label | |
81 | */ | |
82 | protected String getDirectShortLabel() { | |
83 | 0 | return shortLabel; |
84 | } | |
85 | ||
86 | /** | |
87 | * The shortLabel element is the field or collection name that will be used | |
88 | * in applications when a shorter name (than the label element) is required. | |
89 | * This will be overridden by presence of displayLabelAttribute element. | |
90 | */ | |
91 | public void setShortLabel(String shortLabel) { | |
92 | 0 | if (StringUtils.isBlank(shortLabel)) { |
93 | 0 | throw new IllegalArgumentException("invalid (blank) shortLabel"); |
94 | } | |
95 | 0 | this.shortLabel = shortLabel; |
96 | 0 | } |
97 | ||
98 | /** | |
99 | * The required element allows values of "true" or "false". A value of | |
100 | * "true" indicates that a value must be entered for this business object | |
101 | * when creating or editing a new business object. | |
102 | */ | |
103 | public void setRequired(Boolean required) { | |
104 | 0 | this.required = required; |
105 | 0 | } |
106 | ||
107 | @Override | |
108 | public Boolean isRequired() { | |
109 | 0 | return this.required; |
110 | } | |
111 | ||
112 | /** | |
113 | * Text that display a restriction on the value a field can hold | |
114 | * | |
115 | * <p> | |
116 | * For example when the value must be a valid format (phone number, email), certain length, min/max value and | |
117 | * so on this text can be used to indicate the constraint to the user. Generally displays with the control so | |
118 | * it is visible when the user tabs to the field | |
119 | * </p> | |
120 | * | |
121 | * @return String text to display for the constraint message | |
122 | */ | |
123 | public String getConstraintText() { | |
124 | 0 | return this.constraintText; |
125 | } | |
126 | ||
127 | /** | |
128 | * Setter for the constraint message text | |
129 | * | |
130 | * @param constraintText | |
131 | */ | |
132 | public void setConstraintText(String constraintText) { | |
133 | 0 | this.constraintText = constraintText; |
134 | 0 | } |
135 | ||
136 | public String getSummary() { | |
137 | 0 | return summary; |
138 | } | |
139 | ||
140 | /** | |
141 | * The summary element is used to provide a short description of the | |
142 | * attribute or collection. This is designed to be used for help purposes. | |
143 | */ | |
144 | public void setSummary(String summary) { | |
145 | 0 | this.summary = summary; |
146 | 0 | } |
147 | ||
148 | public String getDescription() { | |
149 | 0 | return description; |
150 | } | |
151 | ||
152 | /** | |
153 | * The description element is used to provide a long description of the | |
154 | * attribute or collection. This is designed to be used for help purposes. | |
155 | */ | |
156 | public void setDescription(String description) { | |
157 | 0 | this.description = description; |
158 | 0 | } |
159 | ||
160 | public String getDisplayLabelAttribute() { | |
161 | 0 | return displayLabelAttribute; |
162 | } | |
163 | ||
164 | /** | |
165 | * The displayLabelAttribute element is used to indicate that the label and | |
166 | * short label should be obtained from another attribute. | |
167 | * | |
168 | * The label element and short label element defined for this attribute will | |
169 | * be overridden. Instead, the label and short label values will be obtained | |
170 | * by referencing the corresponding values from the attribute indicated by | |
171 | * this element. | |
172 | */ | |
173 | public void setDisplayLabelAttribute(String displayLabelAttribute) { | |
174 | 0 | this.displayLabelAttribute = displayLabelAttribute; |
175 | 0 | } |
176 | ||
177 | } |