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