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