1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.datadictionary.exporter; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.krad.datadictionary.BusinessObjectEntry; |
20 | |
import org.kuali.rice.krad.datadictionary.DataDictionaryEntry; |
21 | |
import org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry; |
22 | |
import org.kuali.rice.krad.datadictionary.TransactionalDocumentEntry; |
23 | |
import org.kuali.rice.krad.service.DataDictionaryService; |
24 | |
|
25 | |
import java.util.HashMap; |
26 | |
import java.util.Map; |
27 | |
|
28 | |
public class DataDictionaryMap extends DataDictionaryMapBase { |
29 | |
|
30 | |
private DataDictionaryService dataDictionaryService; |
31 | |
|
32 | 0 | BusinessObjectEntryMapper boMapper = new BusinessObjectEntryMapper(); |
33 | 0 | MaintenanceDocumentEntryMapper maintDocMapper = new MaintenanceDocumentEntryMapper(); |
34 | 0 | TransactionalDocumentEntryMapper transDocMapper = new TransactionalDocumentEntryMapper(); |
35 | |
|
36 | 0 | Map<String,Map> ddMap = new HashMap<String,Map>(); |
37 | |
|
38 | |
public DataDictionaryMap(DataDictionaryService dataDictionaryService) { |
39 | 0 | super(); |
40 | 0 | this.dataDictionaryService = dataDictionaryService; |
41 | 0 | } |
42 | |
|
43 | |
public Object get(Object key) { |
44 | 0 | Map subMap = ddMap.get( key ); |
45 | 0 | if ( subMap == null ) { |
46 | 0 | synchronized( this ) { |
47 | 0 | subMap = ddMap.get( key ); |
48 | 0 | if ( subMap == null ) { |
49 | 0 | DataDictionaryEntry entry = dataDictionaryService.getDataDictionary().getDictionaryObjectEntry( key.toString() ); |
50 | |
|
51 | 0 | if ( entry == null && key.toString().contains(".")) { |
52 | 0 | entry = dataDictionaryService.getDataDictionary().getDictionaryObjectEntry( StringUtils.substringAfterLast( key.toString(), "." ) ); |
53 | |
} |
54 | 0 | if ( entry != null ) { |
55 | 0 | if ( entry instanceof BusinessObjectEntry ) { |
56 | 0 | subMap = boMapper.mapEntry( (BusinessObjectEntry)entry ).getExportData(); |
57 | 0 | } else if ( entry instanceof MaintenanceDocumentEntry ) { |
58 | 0 | subMap = maintDocMapper.mapEntry( (MaintenanceDocumentEntry)entry ).getExportData(); |
59 | 0 | } else if ( entry instanceof TransactionalDocumentEntry ) { |
60 | 0 | subMap = transDocMapper.mapEntry( (TransactionalDocumentEntry)entry ).getExportData(); |
61 | |
} |
62 | |
} |
63 | 0 | if ( subMap != null ) { |
64 | 0 | ddMap.put( key.toString(), subMap ); |
65 | |
} |
66 | |
} |
67 | 0 | } |
68 | |
} |
69 | 0 | return subMap; |
70 | |
} |
71 | |
|
72 | |
public DataDictionaryService getDataDictionaryService() { |
73 | 0 | return dataDictionaryService; |
74 | |
} |
75 | |
|
76 | |
public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { |
77 | 0 | this.dataDictionaryService = dataDictionaryService; |
78 | 0 | } |
79 | |
|
80 | |
} |