View Javadoc

1   /**
2    * Copyright 2005-2013 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.bo.Exporter;
20  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
21  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
22  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
23  import org.kuali.rice.krad.datadictionary.validation.capability.MustOccurConstrainable;
24  import org.kuali.rice.krad.datadictionary.validation.constraint.MustOccurConstraint;
25  import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
26  
27  import java.util.List;
28  
29  /**
30   * Generic dictionary entry for an object that does not have to implement BusinessObject. It provides support
31   * for general objects
32   *
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  @BeanTag(name = "dataObjectEntry-bean")
36  public class DataObjectEntry extends DataDictionaryEntryBase implements MustOccurConstrainable {
37  
38      protected String name;
39      protected Class<?> dataObjectClass;
40  
41      protected String titleAttribute;
42      protected String objectLabel;
43      protected String objectDescription;
44  
45      protected List<String> primaryKeys;
46      protected Class<? extends Exporter> exporterClass;
47  
48      protected List<MustOccurConstraint> mustOccurConstraints;
49  
50      protected List<String> groupByAttributesForEffectiveDating;
51  
52      protected HelpDefinition helpDefinition;
53  
54      protected boolean boNotesEnabled = false;
55  
56      protected List<InactivationBlockingDefinition> inactivationBlockingDefinitions;
57  
58      @Override
59      public void completeValidation() {
60          //KFSMI-1340 - Object label should never be blank
61          if (StringUtils.isBlank(getObjectLabel())) {
62              throw new AttributeValidationException(
63                      "Object label cannot be blank for class " + dataObjectClass.getName());
64          }
65  
66          super.completeValidation();
67      }
68  
69      /**
70       * Directly validate simple fields
71       *
72       * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#completeValidation(org.kuali.rice.krad.datadictionary.validator.ValidationTrace)
73       */
74      @Override
75      public void completeValidation(ValidationTrace tracer) {
76          tracer.addBean(this.getClass().getSimpleName(), dataObjectClass.getSimpleName());
77          if (StringUtils.isBlank(getObjectLabel())) {
78              String currentValues[] = {"objectLabel = " + getObjectLabel()};
79              tracer.createError("Object Label is not set", currentValues);
80          }
81  
82          super.completeValidation(tracer.getCopy());
83      }
84  
85      /**
86       * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#getJstlKey()
87       */
88      @Override
89      public String getJstlKey() {
90          if (dataObjectClass == null) {
91              throw new IllegalStateException("cannot generate JSTL key: dataObjectClass is null");
92          }
93  
94          return (dataObjectClass != null) ? dataObjectClass.getSimpleName() : dataObjectClass.getSimpleName();
95      }
96  
97      /**
98       * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#getFullClassName()
99       */
100     @Override
101     public String getFullClassName() {
102         return dataObjectClass.getName();
103     }
104 
105     /**
106      * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase#getEntryClass()
107      */
108     @Override
109     public Class<?> getEntryClass() {
110         return dataObjectClass;
111     }
112 
113     /**
114      * @return the dataObjectClass
115      */
116     @BeanTagAttribute(name = "dataObjectClass")
117     public Class<?> getDataObjectClass() {
118         return this.dataObjectClass;
119     }
120 
121     /**
122      * @param dataObjectClass the dataObjectClass to set
123      */
124     public void setDataObjectClass(Class<?> dataObjectClass) {
125         this.dataObjectClass = dataObjectClass;
126     }
127 
128     /**
129      * @return the name
130      */
131     @BeanTagAttribute(name = "name")
132     public String getName() {
133         return this.name;
134     }
135 
136     /**
137      * @param name the name to set
138      */
139     public void setName(String name) {
140         this.name = name;
141     }
142 
143     /**
144      * @return Returns the objectLabel.
145      */
146     @BeanTagAttribute(name = "objectLabel")
147     public String getObjectLabel() {
148         return objectLabel;
149     }
150 
151     /**
152      * The objectLabel provides a short name of the business
153      * object for use on help screens.
154      *
155      * @param objectLabel The objectLabel to set.
156      */
157     public void setObjectLabel(String objectLabel) {
158         this.objectLabel = objectLabel;
159     }
160 
161     /**
162      * @return Returns the description.
163      */
164     @BeanTagAttribute(name = "objectDescription")
165     public String getObjectDescription() {
166         return objectDescription;
167     }
168 
169     /**
170      * The objectDescription provides a brief description
171      * of the business object for use on help screens.
172      *
173      * @param objectDescription The description to set
174      */
175     public void setObjectDescription(String objectDescription) {
176         this.objectDescription = objectDescription;
177     }
178 
179     /**
180      * Gets the helpDefinition attribute.
181      *
182      * @return Returns the helpDefinition.
183      */
184     @BeanTagAttribute(name = "helpDefintion", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
185     public HelpDefinition getHelpDefinition() {
186         return helpDefinition;
187     }
188 
189     /**
190      * Sets the helpDefinition attribute value.
191      *
192      * The objectHelp element provides the keys to
193      * obtain a help description from the system parameters table.
194      *
195      * parameterNamespace the namespace of the parameter containing help information
196      * parameterName the name of the parameter containing help information
197      * parameterDetailType the detail type of the parameter containing help information
198      *
199      * @param helpDefinition The helpDefinition to set.
200      */
201     public void setHelpDefinition(HelpDefinition helpDefinition) {
202         this.helpDefinition = helpDefinition;
203     }
204 
205     /**
206      * @see java.lang.Object#toString()
207      */
208     @Override
209     public String toString() {
210         return "DataObjectEntry for " + getDataObjectClass();
211     }
212 
213     /**
214      * @return the mustOccurConstraints
215      */
216     @BeanTagAttribute(name = "mustOccurConstraints", type = BeanTagAttribute.AttributeType.LISTBEAN)
217     public List<MustOccurConstraint> getMustOccurConstraints() {
218         return this.mustOccurConstraints;
219     }
220 
221     /**
222      * @param mustOccurConstraints the mustOccurConstraints to set
223      */
224     public void setMustOccurConstraints(List<MustOccurConstraint> mustOccurConstraints) {
225         this.mustOccurConstraints = mustOccurConstraints;
226     }
227 
228     /**
229      * @return the titleAttribute
230      */
231     @BeanTagAttribute(name = "titleAttribute")
232     public String getTitleAttribute() {
233         return this.titleAttribute;
234     }
235 
236     /**
237      * The titleAttribute element is the name of the attribute that
238      * will be used as an inquiry field when the lookup search results
239      * fields are displayed.
240      *
241      * For some business objects, there is no obvious field to serve
242      * as the inquiry field. in that case a special field may be required
243      * for inquiry purposes.
244      */
245     public void setTitleAttribute(String titleAttribute) {
246         this.titleAttribute = titleAttribute;
247     }
248 
249     /**
250      * @return the primaryKeys
251      */
252     @BeanTagAttribute(name = "primaryKeys", type = BeanTagAttribute.AttributeType.LISTVALUE)
253     public List<String> getPrimaryKeys() {
254         return this.primaryKeys;
255     }
256 
257     /**
258      * @param primaryKeys the primaryKeys to set
259      */
260     public void setPrimaryKeys(List<String> primaryKeys) {
261         this.primaryKeys = primaryKeys;
262     }
263 
264     @BeanTagAttribute(name = "exporterClass")
265     public Class<? extends Exporter> getExporterClass() {
266         return this.exporterClass;
267     }
268 
269     public void setExporterClass(Class<? extends Exporter> exporterClass) {
270         this.exporterClass = exporterClass;
271     }
272 
273     /**
274      * Provides list of attributes that should be used for grouping
275      * when performing effective dating logic in the framework
276      *
277      * @return List<String> list of attributes to group by
278      */
279     @BeanTagAttribute(name = "groupByAttributesForEffectiveDating", type = BeanTagAttribute.AttributeType.LISTVALUE)
280     public List<String> getGroupByAttributesForEffectiveDating() {
281         return this.groupByAttributesForEffectiveDating;
282     }
283 
284     /**
285      * Setter for the list of attributes to group by
286      *
287      * @param groupByAttributesForEffectiveDating
288      */
289     public void setGroupByAttributesForEffectiveDating(List<String> groupByAttributesForEffectiveDating) {
290         this.groupByAttributesForEffectiveDating = groupByAttributesForEffectiveDating;
291     }
292 
293     /**
294      * Gets the boNotesEnabled flag for the Data object
295      *
296      * <p>
297      * true indicates that notes and attachments will be permanently
298      * associated with the business object
299      * false indicates that notes and attachments are associated
300      * with the document used to create or edit the business object.
301      * </p>
302      *
303      * @return the boNotesEnabled flag
304      */
305     @BeanTagAttribute(name = "boNotesEnabled")
306     public boolean isBoNotesEnabled() {
307         return boNotesEnabled;
308     }
309 
310     /**
311      * Setter for the boNotesEnabled flag
312      */
313     public void setBoNotesEnabled(boolean boNotesEnabled) {
314         this.boNotesEnabled = boNotesEnabled;
315     }
316 
317     /**
318      * Gets the inactivationBlockingDefinitions for the Data object
319      *
320      * <p>
321      *
322      * </p>
323      *
324      * @return the list of <code>InactivationBlockingDefinition</code>
325      */
326     @BeanTagAttribute(name = "inactivationBlockingDefinitions", type = BeanTagAttribute.AttributeType.LISTBEAN)
327     public List<InactivationBlockingDefinition> getInactivationBlockingDefinitions() {
328         return this.inactivationBlockingDefinitions;
329     }
330 
331     /**
332      * Setter for the inactivationBlockingDefinitions
333      */
334     public void setInactivationBlockingDefinitions(
335             List<InactivationBlockingDefinition> inactivationBlockingDefinitions) {
336         this.inactivationBlockingDefinitions = inactivationBlockingDefinitions;
337     }
338 }