Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DataObjectEntry |
|
| 1.2;1.2 |
1 | /* | |
2 | * Copyright 2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 1.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/ecl1.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.bo.Exporter; | |
20 | import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException; | |
21 | import org.kuali.rice.krad.datadictionary.validation.capability.MustOccurConstrainable; | |
22 | import org.kuali.rice.krad.datadictionary.validation.constraint.MustOccurConstraint; | |
23 | ||
24 | import java.util.List; | |
25 | ||
26 | /** | |
27 | * Generic dictionary entry for an object that does not have to implement BusinessObject. It provides support | |
28 | * for general objects. | |
29 | * | |
30 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
31 | */ | |
32 | 33 | public class DataObjectEntry extends DataDictionaryEntryBase implements MustOccurConstrainable { |
33 | ||
34 | protected String name; | |
35 | protected Class<?> dataObjectClass; | |
36 | ||
37 | protected String titleAttribute; | |
38 | protected String objectLabel; | |
39 | protected String objectDescription; | |
40 | ||
41 | protected List<String> primaryKeys; | |
42 | protected Class<? extends Exporter> exporterClass; | |
43 | ||
44 | protected List<MustOccurConstraint> mustOccurConstraints; | |
45 | ||
46 | protected List<String> groupByAttributesForEffectiveDating; | |
47 | ||
48 | protected HelpDefinition helpDefinition; | |
49 | ||
50 | @Override | |
51 | public void completeValidation() { | |
52 | //KFSMI-1340 - Object label should never be blank | |
53 | 0 | if (StringUtils.isBlank(getObjectLabel())) { |
54 | 0 | throw new AttributeValidationException("Object label cannot be blank for class " + dataObjectClass.getName()); |
55 | } | |
56 | ||
57 | 0 | super.completeValidation(); |
58 | 0 | } |
59 | ||
60 | /** | |
61 | * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#getJstlKey() | |
62 | */ | |
63 | @Override | |
64 | public String getJstlKey() { | |
65 | 0 | if (dataObjectClass == null) { |
66 | 0 | throw new IllegalStateException("cannot generate JSTL key: dataObjectClass is null"); |
67 | } | |
68 | ||
69 | 0 | return (dataObjectClass != null) ? dataObjectClass.getSimpleName() : dataObjectClass.getSimpleName(); |
70 | } | |
71 | ||
72 | /** | |
73 | * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#getFullClassName() | |
74 | */ | |
75 | @Override | |
76 | public String getFullClassName() { | |
77 | 0 | return dataObjectClass.getName(); |
78 | } | |
79 | ||
80 | /** | |
81 | * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase#getEntryClass() | |
82 | */ | |
83 | @Override | |
84 | public Class<?> getEntryClass() { | |
85 | 0 | return dataObjectClass; |
86 | } | |
87 | ||
88 | /** | |
89 | * @return the dataObjectClass | |
90 | */ | |
91 | public Class<?> getDataObjectClass() { | |
92 | 0 | return this.dataObjectClass; |
93 | } | |
94 | ||
95 | /** | |
96 | * @param dataObjectClass the dataObjectClass to set | |
97 | */ | |
98 | public void setDataObjectClass(Class<?> dataObjectClass) { | |
99 | 0 | this.dataObjectClass = dataObjectClass; |
100 | 0 | } |
101 | ||
102 | /** | |
103 | * @return the name | |
104 | */ | |
105 | public String getName() { | |
106 | 0 | return this.name; |
107 | } | |
108 | ||
109 | /** | |
110 | * @param name the name to set | |
111 | */ | |
112 | public void setName(String name) { | |
113 | 0 | this.name = name; |
114 | 0 | } |
115 | ||
116 | /** | |
117 | * @return Returns the objectLabel. | |
118 | */ | |
119 | public String getObjectLabel() { | |
120 | 0 | return objectLabel; |
121 | } | |
122 | ||
123 | /** | |
124 | * The objectLabel provides a short name of the business | |
125 | * object for use on help screens. | |
126 | * | |
127 | * @param objectLabel The objectLabel to set. | |
128 | */ | |
129 | public void setObjectLabel(String objectLabel) { | |
130 | 0 | this.objectLabel = objectLabel; |
131 | 0 | } |
132 | ||
133 | /** | |
134 | * @return Returns the description. | |
135 | */ | |
136 | public String getObjectDescription() { | |
137 | 0 | return objectDescription; |
138 | } | |
139 | ||
140 | /** | |
141 | * The objectDescription provides a brief description | |
142 | * of the business object for use on help screens. | |
143 | * | |
144 | * @param description The description to set. | |
145 | */ | |
146 | public void setObjectDescription(String objectDescription) { | |
147 | 0 | this.objectDescription = objectDescription; |
148 | 0 | } |
149 | ||
150 | /** | |
151 | * Gets the helpDefinition attribute. | |
152 | * | |
153 | * @return Returns the helpDefinition. | |
154 | */ | |
155 | public HelpDefinition getHelpDefinition() { | |
156 | 0 | return helpDefinition; |
157 | } | |
158 | ||
159 | /** | |
160 | * Sets the helpDefinition attribute value. | |
161 | * | |
162 | * The objectHelp element provides the keys to | |
163 | * obtain a help description from the system parameters table. | |
164 | * | |
165 | * parameterNamespace the namespace of the parameter containing help information | |
166 | * parameterName the name of the parameter containing help information | |
167 | * parameterDetailType the detail type of the parameter containing help information | |
168 | * | |
169 | * @param helpDefinition The helpDefinition to set. | |
170 | */ | |
171 | public void setHelpDefinition(HelpDefinition helpDefinition) { | |
172 | 0 | this.helpDefinition = helpDefinition; |
173 | 0 | } |
174 | ||
175 | /** | |
176 | * @see java.lang.Object#toString() | |
177 | */ | |
178 | @Override | |
179 | public String toString() { | |
180 | 0 | return "DataObjectEntry for " + getDataObjectClass(); |
181 | } | |
182 | ||
183 | /** | |
184 | * @return the mustOccurConstraints | |
185 | */ | |
186 | public List<MustOccurConstraint> getMustOccurConstraints() { | |
187 | 0 | return this.mustOccurConstraints; |
188 | } | |
189 | ||
190 | /** | |
191 | * @param mustOccurConstraints the mustOccurConstraints to set | |
192 | */ | |
193 | public void setMustOccurConstraints(List<MustOccurConstraint> mustOccurConstraints) { | |
194 | 5 | this.mustOccurConstraints = mustOccurConstraints; |
195 | 5 | } |
196 | ||
197 | /** | |
198 | * @return the titleAttribute | |
199 | */ | |
200 | public String getTitleAttribute() { | |
201 | 0 | return this.titleAttribute; |
202 | } | |
203 | ||
204 | /** | |
205 | * The titleAttribute element is the name of the attribute that | |
206 | * will be used as an inquiry field when the lookup search results | |
207 | * fields are displayed. | |
208 | * | |
209 | * For some business objects, there is no obvious field to serve | |
210 | * as the inquiry field. in that case a special field may be required | |
211 | * for inquiry purposes. | |
212 | */ | |
213 | public void setTitleAttribute(String titleAttribute) { | |
214 | 0 | this.titleAttribute = titleAttribute; |
215 | 0 | } |
216 | ||
217 | /** | |
218 | * @return the primaryKeys | |
219 | */ | |
220 | public List<String> getPrimaryKeys() { | |
221 | 0 | return this.primaryKeys; |
222 | } | |
223 | ||
224 | /** | |
225 | * @param primaryKeys the primaryKeys to set | |
226 | */ | |
227 | public void setPrimaryKeys(List<String> primaryKeys) { | |
228 | 0 | this.primaryKeys = primaryKeys; |
229 | 0 | } |
230 | ||
231 | public Class<? extends Exporter> getExporterClass() { | |
232 | 0 | return this.exporterClass; |
233 | } | |
234 | ||
235 | public void setExporterClass(Class<? extends Exporter> exporterClass) { | |
236 | 0 | this.exporterClass = exporterClass; |
237 | 0 | } |
238 | ||
239 | /** | |
240 | * Provides list of attributes that should be used for grouping | |
241 | * when performing effective dating logic in the framework | |
242 | * | |
243 | * @return List<String> list of attributes to group by | |
244 | */ | |
245 | public List<String> getGroupByAttributesForEffectiveDating() { | |
246 | 0 | return this.groupByAttributesForEffectiveDating; |
247 | } | |
248 | ||
249 | /** | |
250 | * Setter for the list of attributes to group by | |
251 | * | |
252 | * @param groupByAttributesForEffectiveDating | |
253 | */ | |
254 | public void setGroupByAttributesForEffectiveDating(List<String> groupByAttributesForEffectiveDating) { | |
255 | 0 | this.groupByAttributesForEffectiveDating = groupByAttributesForEffectiveDating; |
256 | 0 | } |
257 | } |