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