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