View Javadoc

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