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