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