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