View Javadoc

1   /*
2    * Copyright 2005-2007 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.kns.service.impl;
17  
18  import java.io.IOException;
19  import java.math.BigDecimal;
20  import java.util.ArrayList;
21  import java.util.Collections;
22  import java.util.HashMap;
23  import java.util.Iterator;
24  import java.util.List;
25  import java.util.Map;
26  import java.util.Set;
27  import java.util.regex.Pattern;
28  
29  import org.apache.commons.lang.StringUtils;
30  import org.apache.log4j.Logger;
31  import org.kuali.rice.core.util.ClassLoaderUtils;
32  import org.kuali.rice.kew.dto.DocumentTypeDTO;
33  import org.kuali.rice.kew.exception.WorkflowException;
34  import org.kuali.rice.kns.bo.BusinessObject;
35  import org.kuali.rice.kns.datadictionary.AttributeDefinition;
36  import org.kuali.rice.kns.datadictionary.AttributeSecurity;
37  import org.kuali.rice.kns.datadictionary.BusinessObjectEntry;
38  import org.kuali.rice.kns.datadictionary.CollectionDefinition;
39  import org.kuali.rice.kns.datadictionary.DataDictionary;
40  import org.kuali.rice.kns.datadictionary.DataDictionaryEntryBase;
41  import org.kuali.rice.kns.datadictionary.DocumentEntry;
42  import org.kuali.rice.kns.datadictionary.InactivationBlockingMetadata;
43  import org.kuali.rice.kns.datadictionary.PrimitiveAttributeDefinition;
44  import org.kuali.rice.kns.datadictionary.RelationshipDefinition;
45  import org.kuali.rice.kns.datadictionary.control.ControlDefinition;
46  import org.kuali.rice.kns.datadictionary.exporter.DataDictionaryMap;
47  import org.kuali.rice.kns.datadictionary.validation.ValidationPattern;
48  import org.kuali.rice.kns.document.Document;
49  import org.kuali.rice.kns.exception.UnknownBusinessClassAttributeException;
50  import org.kuali.rice.kns.exception.UnknownDocumentTypeException;
51  import org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder;
52  import org.kuali.rice.kns.rule.PromptBeforeValidation;
53  import org.kuali.rice.kns.service.DataDictionaryService;
54  import org.kuali.rice.kns.service.KNSServiceLocator;
55  import org.kuali.rice.kns.service.KualiConfigurationService;
56  import org.kuali.rice.kns.service.KualiModuleService;
57  import org.kuali.rice.kns.web.format.Formatter;
58  import org.kuali.rice.kns.workflow.service.KualiWorkflowInfo;
59  
60  /**
61   * This class is the service implementation for a DataDictionary. It is a thin wrapper around creating, initializing, and
62   * returning a DataDictionary. This is the default, Kuali delivered implementation.
63   */
64  public class DataDictionaryServiceImpl implements DataDictionaryService {
65      private static final Logger LOG = Logger.getLogger( DataDictionaryServiceImpl.class );
66  
67  
68      private DataDictionary dataDictionary;
69      private DataDictionaryMap dataDictionaryMap = new DataDictionaryMap(this);
70  
71      private KualiConfigurationService kualiConfigurationService;
72      private KualiModuleService kualiModuleService;
73      private KualiWorkflowInfo workflowInfoService;
74  
75  
76      /**
77       * @see org.kuali.rice.kns.service.DataDictionaryService#setBaselinePackages(java.lang.String)
78       */
79      public void setBaselinePackages(List baselinePackages) throws IOException {
80          this.addDataDictionaryLocations(baselinePackages);
81      }
82  
83      /**
84       * Default constructor.
85       */
86      public DataDictionaryServiceImpl() {
87          this.dataDictionary = new DataDictionary();
88      }
89  
90      public DataDictionaryServiceImpl(DataDictionary dataDictionary) {
91          this.dataDictionary = dataDictionary;
92      }
93  
94      /**
95       * @see org.kuali.rice.kns.service.DataDictionaryService#getDataDictionary()
96       */
97      public DataDictionary getDataDictionary() {
98          return dataDictionary;
99      }
100 
101     /**
102      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeControlDefinition(java.lang.String)
103      */
104     public ControlDefinition getAttributeControlDefinition(String entryName, String attributeName) {
105         ControlDefinition controlDefinition = null;
106 
107         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
108         if (attributeDefinition != null) {
109             controlDefinition = attributeDefinition.getControl();
110         }
111 
112         return controlDefinition;
113     }
114 
115     /**
116      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeSize(java.lang.String)
117      */
118     public Integer getAttributeSize(String entryName, String attributeName) {
119         Integer size = null;
120 
121         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
122         if (attributeDefinition != null) {
123             ControlDefinition controlDefinition = attributeDefinition.getControl();
124             if (controlDefinition.isText() || controlDefinition.isCurrency()) {
125                 size = controlDefinition.getSize();
126             }
127         }
128 
129         return size;
130     }
131 
132     /**
133      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeMaxLength(java.lang.String)
134      */
135     public Integer getAttributeMaxLength(String entryName, String attributeName) {
136         Integer maxLength = null;
137 
138         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
139         if (attributeDefinition != null) {
140             maxLength = attributeDefinition.getMaxLength();
141         }
142 
143         return maxLength;
144     }
145 
146     /**
147      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeExclusiveMin
148      */
149     public BigDecimal getAttributeExclusiveMin(String entryName, String attributeName) {
150         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
151         return attributeDefinition == null ? null : attributeDefinition.getExclusiveMin();
152     }
153 
154     /**
155      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeInclusiveMax
156      */
157     public BigDecimal getAttributeInclusiveMax(String entryName, String attributeName) {
158         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
159         return attributeDefinition == null ? null : attributeDefinition.getInclusiveMax();
160     }
161 
162     /**
163      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeValidatingExpression(java.lang.String)
164      */
165     public Pattern getAttributeValidatingExpression(String entryName, String attributeName) {
166         Pattern regex = null;
167 
168         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
169         if (attributeDefinition != null) {
170             if (attributeDefinition.hasValidationPattern()) {
171                 regex = attributeDefinition.getValidationPattern().getRegexPattern();
172             } else {
173                 // workaround for existing calls which don't bother checking for null return values
174                 regex = Pattern.compile(".*");
175             }
176         }
177 
178         return regex;
179     }
180 
181     /**
182      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeLabel(java.lang.String)
183      */
184     public String getAttributeLabel(String entryName, String attributeName) {
185         String label = "";
186 
187         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
188         if (attributeDefinition != null) {
189         	// KULRICE-4445 prevent NullPointerException by ensuring a label is set
190      	 	label = attributeDefinition.getLabel();
191         	if (!StringUtils.isEmpty(attributeDefinition.getDisplayLabelAttribute())) {
192                 attributeDefinition = getAttributeDefinition(entryName, attributeDefinition.getDisplayLabelAttribute());
193                 if (attributeDefinition != null) {
194                     label = attributeDefinition.getLabel();
195                 }
196             }
197         }
198 
199         return label;
200     }
201 
202     /**
203      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeShortLabel(java.lang.String)
204      */
205     public String getAttributeShortLabel(String entryName, String attributeName) {
206         String shortLabel = "";
207 
208         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
209         if (attributeDefinition != null) {
210             if (!StringUtils.isEmpty(attributeDefinition.getDisplayLabelAttribute())) {
211                 attributeDefinition = getAttributeDefinition(entryName, attributeDefinition.getDisplayLabelAttribute());
212                 if (attributeDefinition != null) {
213                     shortLabel = attributeDefinition.getShortLabel();
214                 }
215             } else {
216                 shortLabel = attributeDefinition.getShortLabel();
217             }
218         }
219 
220         return shortLabel;
221     }
222 
223     /**
224      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeErrorLabel(java.lang.String)
225      */
226     public String getAttributeErrorLabel(String entryName, String attributeName) {
227         String longAttributeLabel = this.getAttributeLabel(entryName, attributeName);
228         String shortAttributeLabel = this.getAttributeShortLabel(entryName, attributeName);
229         return longAttributeLabel + " (" + shortAttributeLabel + ")";
230     }
231 
232     /**
233      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeFormatter(java.lang.String)
234      */
235     public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName) {
236         Class formatterClass = null;
237 
238         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
239         if (attributeDefinition != null) {
240             if (attributeDefinition.hasFormatterClass()) {
241                 formatterClass = ClassLoaderUtils.getClass(attributeDefinition.getFormatterClass());
242             }
243         }
244 
245         return formatterClass;
246     }
247 
248     /**
249      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeForceUppercase(java.lang.String)
250      */
251     public Boolean getAttributeForceUppercase(String entryName, String attributeName) throws UnknownBusinessClassAttributeException {
252         Boolean forceUppercase = null;
253 
254         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
255         if (attributeDefinition == null) {
256             throw new UnknownBusinessClassAttributeException("Could not find a matching data dictionary business class attribute entry for " + entryName + "." + attributeName);
257         }
258         forceUppercase = attributeDefinition.getForceUppercase();
259 
260         return forceUppercase;
261     }
262 
263     /**
264      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeDisplayMask(java.lang.String, java.lang.String)
265      */
266     public AttributeSecurity getAttributeSecurity(String entryName, String attributeName) {
267         AttributeSecurity attributeSecurity = null;
268 
269         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
270         if (attributeDefinition != null) {
271             attributeSecurity = attributeDefinition.getAttributeSecurity();
272         }
273 
274         return attributeSecurity;
275     }
276 
277 
278     /**
279      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeSummary(java.lang.String)
280      */
281     public String getAttributeSummary(String entryName, String attributeName) {
282         String summary = null;
283 
284         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
285         if (attributeDefinition != null) {
286             summary = attributeDefinition.getSummary();
287         }
288 
289         return summary;
290     }
291 
292     /**
293      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeDescription(java.lang.String)
294      */
295     public String getAttributeDescription(String entryName, String attributeName) {
296         String description = null;
297 
298         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
299         if (attributeDefinition != null) {
300             description = attributeDefinition.getDescription();
301         }
302 
303         return description;
304     }
305 
306     /**
307      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#isAttributeRequired(java.lang.Class, java.lang.String)
308      */
309     public Boolean isAttributeRequired(String entryName, String attributeName) {
310         Boolean required = null;
311 
312         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
313         if (attributeDefinition != null) {
314             required = attributeDefinition.isRequired();
315         }
316 
317         return required;
318     }
319 
320     /**
321      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#isAttributeDefined(java.lang.Class, java.lang.String)
322      */
323     public Boolean isAttributeDefined(String entryName, String attributeName) {
324         boolean isDefined = false;
325 
326         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
327         if (attributeDefinition != null) {
328             isDefined = true;
329         }
330 
331         return isDefined;
332     }
333 
334     /**
335      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getAttributeValuesScopeId(java.lang.Class,
336      *      java.lang.String)
337      */
338     public Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(String entryName, String attributeName) {
339         Class valuesFinderClass = null;
340 
341         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
342         if (attributeDefinition != null) {
343             String valuesFinderClassName = attributeDefinition.getControl().getValuesFinderClass();
344             valuesFinderClass = ClassLoaderUtils.getClass(valuesFinderClassName);
345         }
346 
347         return valuesFinderClass;
348     }
349 
350     /**
351      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getCollectionLabel(java.lang.Class, java.lang.String)
352      */
353     public String getCollectionLabel(String entryName, String collectionName) {
354         String label = "";
355 
356         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
357         if (collectionDefinition != null) {
358             label = collectionDefinition.getLabel();
359         }
360 
361         return label;
362     }
363 
364     /**
365      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getCollectionShortLabel(java.lang.Class, java.lang.String)
366      */
367     public String getCollectionShortLabel(String entryName, String collectionName) {
368         String shortLabel = "";
369 
370         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
371         if (collectionDefinition != null) {
372             shortLabel = collectionDefinition.getShortLabel();
373         }
374 
375         return shortLabel;
376     }
377 
378     /**
379      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getCollectionElementLabel(java.lang.Class,
380      *      java.lang.String)
381      */
382     public String getCollectionElementLabel(String entryName, String collectionName, Class businessObjectClass) {
383         String elementLabel = "";
384 
385         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
386         if (collectionDefinition != null) {
387             elementLabel = collectionDefinition.getElementLabel();
388             if (StringUtils.isEmpty(elementLabel)) {
389                 BusinessObjectEntry boe = getDataDictionary().getBusinessObjectEntry(businessObjectClass.getName());
390                 if (boe != null) {
391                     elementLabel = boe.getObjectLabel();
392                 }
393             }
394         }
395 
396         return elementLabel;
397     }
398 
399     /**
400      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getCollectionSummary(java.lang.Class, java.lang.String)
401      */
402     public String getCollectionSummary(String entryName, String collectionName) {
403         String summary = null;
404 
405         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
406         if (collectionDefinition != null) {
407             summary = collectionDefinition.getSummary();
408         }
409 
410         return summary;
411     }
412 
413     /**
414      * @see org.kuali.rice.kns.service.BusinessObjectDictionaryService#getCollectionDescription(java.lang.Class,
415      *      java.lang.String)
416      */
417     public String getCollectionDescription(String entryName, String collectionName) {
418         String description = null;
419 
420         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
421         if (collectionDefinition != null) {
422             description = collectionDefinition.getDescription();
423         }
424 
425         return description;
426     }
427 
428     public Class<? extends BusinessObject> getRelationshipSourceClass(String entryName, String relationshipName) {
429         Class sourceClass = null;
430 
431         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
432         if (rd != null) {
433             sourceClass = rd.getSourceClass();
434         }
435 
436         return sourceClass;
437     }
438 
439     public Class<? extends BusinessObject> getRelationshipTargetClass(String entryName, String relationshipName) {
440         Class targetClass = null;
441 
442         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
443         if (rd != null) {
444             targetClass = rd.getTargetClass();
445         }
446 
447         return targetClass;
448     }
449 
450     public List<String> getRelationshipSourceAttributes(String entryName, String relationshipName) {
451         List<String> sourceAttributes = null;
452 
453         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
454         if (rd != null) {
455             sourceAttributes = new ArrayList<String>();
456 
457             for (PrimitiveAttributeDefinition pad : rd.getPrimitiveAttributes()) {
458                 sourceAttributes.add(pad.getSourceName());
459             }
460         }
461 
462         return sourceAttributes;
463     }
464 
465     public List<String> getRelationshipTargetAttributes(String entryName, String relationshipName) {
466         List<String> targetAttributes = null;
467 
468         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
469         if (rd != null) {
470             targetAttributes = new ArrayList<String>();
471 
472             for (PrimitiveAttributeDefinition pad : rd.getPrimitiveAttributes()) {
473                 targetAttributes.add(pad.getTargetName());
474             }
475         }
476 
477         return targetAttributes;
478     }
479 
480     public List<String> getRelationshipEntriesForSourceAttribute(String entryName, String sourceAttributeName) {
481         List<String> relationships = new ArrayList<String>();
482 
483         DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
484 
485         for (RelationshipDefinition def : entry.getRelationships()) {
486             for (PrimitiveAttributeDefinition pddef : def.getPrimitiveAttributes()) {
487                 if (StringUtils.equals(sourceAttributeName, pddef.getSourceName())) {
488                     relationships.add(def.getObjectAttributeName());
489                     break;
490                 }
491             }
492         }
493         return relationships;
494     }
495 
496     public List<String> getRelationshipEntriesForTargetAttribute(String entryName, String targetAttributeName) {
497         List<String> relationships = new ArrayList<String>();
498 
499         DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
500 
501         for (RelationshipDefinition def : entry.getRelationships()) {
502             for (PrimitiveAttributeDefinition pddef : def.getPrimitiveAttributes()) {
503                 if (StringUtils.equals(targetAttributeName, pddef.getTargetName())) {
504                     relationships.add(def.getObjectAttributeName());
505                     break;
506                 }
507             }
508         }
509         return relationships;
510     }
511 
512     /**
513      * @param objectClass
514      * @param attributeName
515      * @return AttributeDefinition for the given objectClass and attribute name, or null if there is none
516      * @throws IllegalArgumentException
517      *             if the given Class is null or is not a BusinessObject class
518      */
519     private AttributeDefinition getAttributeDefinition(String entryName, String attributeName) {
520         if (StringUtils.isBlank(attributeName)) {
521             throw new IllegalArgumentException("invalid (blank) attributeName");
522         }
523         AttributeDefinition attributeDefinition = null;
524 
525         DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
526         if (entry != null) {
527             attributeDefinition = entry.getAttributeDefinition(attributeName);
528         }
529 
530         return attributeDefinition;
531     }
532 
533     /**
534      * @param entryName
535      * @param collectionName
536      * @return CollectionDefinition for the given entryName and collectionName, or null if there is none
537      */
538     private CollectionDefinition getCollectionDefinition(String entryName, String collectionName) {
539         if (StringUtils.isBlank(collectionName)) {
540             throw new IllegalArgumentException("invalid (blank) collectionName");
541         }
542         CollectionDefinition collectionDefinition = null;
543 
544         DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
545         if (entry != null) {
546             collectionDefinition = entry.getCollectionDefinition(collectionName);
547         }
548 
549         return collectionDefinition;
550     }
551 
552     /**
553      * @param entryName
554      * @param relationshipName
555      * @return RelationshipDefinition for the given entryName and relationshipName, or null if there is none
556      */
557     private RelationshipDefinition getRelationshipDefinition(String entryName, String relationshipName) {
558         if (StringUtils.isBlank(relationshipName)) {
559             throw new IllegalArgumentException("invalid (blank) relationshipName");
560         }
561 
562         RelationshipDefinition relationshipDefinition = null;
563 
564         DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
565         if (entry != null) {
566             relationshipDefinition = entry.getRelationshipDefinition(relationshipName);
567         }
568 
569         return relationshipDefinition;
570     }
571 
572     /**
573      * @see org.kuali.rice.kns.service.DataDictionaryService#getRelationshipAttributeMap(java.lang.String, java.lang.String)
574      */
575     public Map<String, String> getRelationshipAttributeMap(String entryName, String relationshipName) {
576         Map<String, String> attributeMap = new HashMap<String, String>();
577         RelationshipDefinition relationshipDefinition = getRelationshipDefinition(entryName, relationshipName);
578         for (Iterator iter = relationshipDefinition.getPrimitiveAttributes().iterator(); iter.hasNext();) {
579             PrimitiveAttributeDefinition attribute = (PrimitiveAttributeDefinition) iter.next();
580             attributeMap.put(attribute.getTargetName(), attribute.getSourceName());
581         }
582         return attributeMap;
583     }
584 
585     public boolean hasRelationship(String entryName, String relationshipName) {
586         return getRelationshipDefinition(entryName, relationshipName) != null;
587     }
588 
589     public List<String> getRelationshipNames(String entryName) {
590         DataDictionaryEntryBase entry = (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
591 
592         List<String> relationshipNames = new ArrayList<String>();
593         for (RelationshipDefinition def : entry.getRelationships()) {
594             relationshipNames.add(def.getObjectAttributeName());
595         }
596         return relationshipNames;
597     }
598 
599     /**
600      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeControlDefinition(java.lang.String, java.lang.String)
601      */
602     public ControlDefinition getAttributeControlDefinition(Class businessObjectClass, String attributeName) {
603         return getAttributeControlDefinition(businessObjectClass.getName(), attributeName);
604     }
605 
606     /**
607      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeDescription(java.lang.String, java.lang.String)
608      */
609     public String getAttributeDescription(Class businessObjectClass, String attributeName) {
610         return getAttributeDescription(businessObjectClass.getName(), attributeName);
611     }
612 
613     /**
614      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeForceUppercase(java.lang.String, java.lang.String)
615      */
616     public Boolean getAttributeForceUppercase(Class businessObjectClass, String attributeName) {
617         return getAttributeForceUppercase(businessObjectClass.getName(), attributeName);
618     }
619 
620     /**
621      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeFormatter(java.lang.String, java.lang.String)
622      */
623     public Class<? extends Formatter> getAttributeFormatter(Class businessObjectClass, String attributeName) {
624         return getAttributeFormatter(businessObjectClass.getName(), attributeName);
625     }
626 
627     /**
628      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeLabel(java.lang.String, java.lang.String)
629      */
630     public String getAttributeLabel(Class businessObjectClass, String attributeName) {
631         return getAttributeLabel(businessObjectClass.getName(), attributeName);
632     }
633 
634     /**
635      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeMaxLength(java.lang.String, java.lang.String)
636      */
637     public Integer getAttributeMaxLength(Class businessObjectClass, String attributeName) {
638         return getAttributeMaxLength(businessObjectClass.getName(), attributeName);
639     }
640 
641     /**
642      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeShortLabel(java.lang.String, java.lang.String)
643      */
644     public String getAttributeShortLabel(Class businessObjectClass, String attributeName) {
645         return getAttributeShortLabel(businessObjectClass.getName(), attributeName);
646     }
647 
648     /**
649      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeErrorLabel(java.lang.String, java.lang.String)
650      */
651     public String getAttributeErrorLabel(Class businessObjectClass, String attributeName) {
652         return getAttributeErrorLabel(businessObjectClass.getName(), attributeName);
653     }
654 
655     /**
656      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeSize(java.lang.String, java.lang.String)
657      */
658     public Integer getAttributeSize(Class businessObjectClass, String attributeName) {
659         return getAttributeSize(businessObjectClass.getName(), attributeName);
660     }
661 
662     /**
663      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeSummary(java.lang.String, java.lang.String)
664      */
665     public String getAttributeSummary(Class businessObjectClass, String attributeName) {
666         return getAttributeSummary(businessObjectClass.getName(), attributeName);
667     }
668 
669     /**
670      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeValidatingExpression(java.lang.String, java.lang.String)
671      */
672     public Pattern getAttributeValidatingExpression(Class businessObjectClass, String attributeName) {
673         return getAttributeValidatingExpression(businessObjectClass.getName(), attributeName);
674     }
675 
676     /**
677      * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeValuesFinderClass(java.lang.String, java.lang.String)
678      */
679     public Class getAttributeValuesFinderClass(Class businessObjectClass, String attributeName) {
680         return getAttributeValuesFinderClass(businessObjectClass.getName(), attributeName);
681     }
682 
683     /**
684 	 * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeValidatingErrorMessageKey(java.lang.String, java.lang.String)
685 	 */
686 	public String getAttributeValidatingErrorMessageKey(String entryName, String attributeName) {
687         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
688         if (attributeDefinition != null) {
689         	if (attributeDefinition.hasValidationPattern()) {
690         		ValidationPattern validationPattern = attributeDefinition.getValidationPattern();
691         		return validationPattern.getValidationErrorMessageKey();
692         	}
693         }
694         return null;
695 	}
696 
697 	/**
698 	 * @see org.kuali.rice.kns.service.DataDictionaryService#getAttributeValidatingErrorMessageParameters(java.lang.String, java.lang.String)
699 	 */
700 	public String[] getAttributeValidatingErrorMessageParameters(String entryName, String attributeName) {
701 		AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
702         if (attributeDefinition != null) {
703         	if (attributeDefinition.hasValidationPattern()) {
704         		ValidationPattern validationPattern = attributeDefinition.getValidationPattern();
705         		String attributeLabel = getAttributeErrorLabel(entryName, attributeName);
706         		return validationPattern.getValidationErrorMessageParameters(attributeLabel);
707         	}
708         }
709         return null;
710 	}
711 
712 	/**
713      * @see org.kuali.rice.kns.service.DataDictionaryService#getCollectionDescription(java.lang.String, java.lang.String)
714      */
715     public String getCollectionDescription(Class businessObjectClass, String collectionName) {
716         return getCollectionDescription(businessObjectClass.getName(), collectionName);
717     }
718 
719     /**
720      * @see org.kuali.rice.kns.service.DataDictionaryService#getCollectionLabel(java.lang.String, java.lang.String)
721      */
722     public String getCollectionLabel(Class businessObjectClass, String collectionName) {
723         return getCollectionLabel(businessObjectClass.getName(), collectionName);
724     }
725 
726     /**
727      * @see org.kuali.rice.kns.service.DataDictionaryService#getCollectionShortLabel(java.lang.String, java.lang.String)
728      */
729     public String getCollectionShortLabel(Class businessObjectClass, String collectionName) {
730         return getCollectionShortLabel(businessObjectClass.getName(), collectionName);
731     }
732 
733     /**
734      * @see org.kuali.rice.kns.service.DataDictionaryService#getCollectionSummary(java.lang.String, java.lang.String)
735      */
736     public String getCollectionSummary(Class businessObjectClass, String collectionName) {
737         return getCollectionSummary(businessObjectClass.getName(), collectionName);
738     }
739 
740     /**
741      * @see org.kuali.rice.kns.service.DataDictionaryService#isAttributeDefined(java.lang.String, java.lang.String)
742      */
743     public Boolean isAttributeDefined(Class businessObjectClass, String attributeName) {
744         return isAttributeDefined(businessObjectClass.getName(), attributeName);
745     }
746 
747     /**
748      * @see org.kuali.rice.kns.service.DataDictionaryService#isAttributeRequired(java.lang.String, java.lang.String)
749      */
750     public Boolean isAttributeRequired(Class businessObjectClass, String attributeName) {
751         return isAttributeRequired(businessObjectClass.getName(), attributeName);
752 
753     }
754 
755     /**
756      * @see org.kuali.rice.kns.service.DataDictionaryService#getDocumentLabelByClass(java.lang.Class)
757      */
758     public String getDocumentLabelByClass(Class documentOrBusinessObjectClass) {
759         return getDocumentLabelByTypeName(getDocumentTypeNameByClass(documentOrBusinessObjectClass));
760     }
761 
762     /**
763      * @see org.kuali.rice.kns.service.DataDictionaryService#getDocumentLabelByTypeName(java.lang.String)
764      */
765     public String getDocumentLabelByTypeName(String documentTypeName) {
766         String label = null;
767         if (StringUtils.isNotBlank(documentTypeName)) {
768             try {
769                 DocumentTypeDTO documentType = getWorkflowInfoService().getDocType(documentTypeName);
770                 if (documentType != null) {
771                     label = documentType.getDocTypeLabel();
772                 }
773             } catch (WorkflowException e) {
774                 // stop blowing up when workflow doc does not exist
775                 LOG.error("Caught Workflow Exception trying to get document type '" + documentTypeName + "'", e);
776                 return documentTypeName;
777             }
778         }
779         return label;
780     }
781 
782     /**
783      * @see org.kuali.rice.kns.service.DataDictionaryService#getDocumentTypeNameByClass(java.lang.Class)
784      */
785     public String getDocumentTypeNameByClass(Class documentClass) {
786         if (documentClass == null) {
787             throw new IllegalArgumentException("invalid (null) documentClass");
788         }
789         if (!Document.class.isAssignableFrom(documentClass)) {
790             throw new IllegalArgumentException("invalid (non-Document) documentClass");
791         }
792 
793         String documentTypeName = null;
794 
795         DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(documentClass.getName());
796         if (documentEntry != null) {
797             documentTypeName = documentEntry.getDocumentTypeName();
798         }
799 
800         return documentTypeName;
801     }
802 
803     /**
804      * @see org.kuali.rice.kns.service.DataDictionaryService#getValidDocumentTypeNameByClass(java.lang.Class)
805      */
806     public String getValidDocumentTypeNameByClass(Class documentClass) {
807         String documentTypeName = getDocumentTypeNameByClass(documentClass);
808         if (StringUtils.isBlank(documentTypeName)) {
809             throw new UnknownDocumentTypeException("unable to get documentTypeName for unknown documentClass '" + documentClass.getName() + "'");
810         }
811         return documentTypeName;
812     }
813 
814     /**
815      * @see org.kuali.rice.kns.service.DataDictionaryService#getDocumentClassByTypeName(java.lang.String)
816      */
817     public Class<? extends Document> getDocumentClassByTypeName(String documentTypeName) {
818         Class clazz = null;
819 
820         DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(documentTypeName);
821         if (documentEntry != null) {
822             clazz = documentEntry.getDocumentClass();
823         }
824 
825         return clazz;
826     }
827 
828     /**
829      * @see org.kuali.rice.kns.service.DataDictionaryService#getValidDocumentClassByTypeName(java.lang.String)
830      */
831     public Class<? extends Document> getValidDocumentClassByTypeName(String documentTypeName) {
832         Class clazz = getDocumentClassByTypeName(documentTypeName);
833         if (clazz == null) {
834             throw new UnknownDocumentTypeException("unable to get class for unknown documentTypeName '" + documentTypeName + "'");
835         }
836         return clazz;
837     }
838 
839     /**
840      * @see org.kuali.rice.kns.service.DataDictionaryService#getPromptBeforeValidationClass(java.lang.String)
841      */
842     public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass(String docTypeName) {
843         Class preRulesCheckClass = null;
844 
845         DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(docTypeName);
846         if (documentEntry != null) {
847             preRulesCheckClass = documentEntry.getPromptBeforeValidationClass();
848         }
849 
850         return preRulesCheckClass;
851     }
852 
853     public void addDataDictionaryLocation(String location) throws IOException {
854         dataDictionary.addConfigFileLocation(location);
855     }
856 
857     public void addDataDictionaryLocations(List<String> locations) throws IOException {
858         for (String location : locations) {
859             addDataDictionaryLocation(location);
860         }
861     }
862 
863     public Map getDataDictionaryMap() {
864         return dataDictionaryMap;
865     }
866 
867     public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
868         this.kualiConfigurationService = kualiConfigurationService;
869     }
870 
871     public KualiConfigurationService getKualiConfigurationService() {
872         return kualiConfigurationService;
873     }
874 
875     public KualiModuleService getKualiModuleService() {
876         return kualiModuleService;
877     }
878 
879     public void setKualiModuleService(KualiModuleService kualiModuleService) {
880         this.kualiModuleService = kualiModuleService;
881     }
882 
883     /**
884      * Returns all of the inactivation blocks registered for a particular business object
885      *
886      * @see org.kuali.rice.kns.service.DataDictionaryService#getAllInactivationBlockingDefinitions(java.lang.Class)
887      */
888     public Set<InactivationBlockingMetadata> getAllInactivationBlockingDefinitions(Class inactivationBlockedBusinessObjectClass) {
889         Set<InactivationBlockingMetadata> blockingClasses = dataDictionary.getAllInactivationBlockingMetadatas(inactivationBlockedBusinessObjectClass);
890         if (blockingClasses == null) {
891             return Collections.emptySet();
892         }
893         return blockingClasses;
894     }
895 
896 	public KualiWorkflowInfo getWorkflowInfoService() {
897 		if ( workflowInfoService == null ) {
898 			workflowInfoService = KNSServiceLocator.getWorkflowInfoService();
899 		}
900 		return workflowInfoService;
901 	}
902 }