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