001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.datadictionary.exporter; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.kns.datadictionary.BusinessObjectEntry; 020import org.kuali.rice.krad.datadictionary.DataDictionaryEntry; 021import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry; 022import org.kuali.rice.kns.datadictionary.TransactionalDocumentEntry; 023import org.kuali.rice.krad.service.DataDictionaryService; 024import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 025 026import java.util.HashMap; 027import java.util.Map; 028 029@Deprecated 030public class DataDictionaryMap extends DataDictionaryMapBase { 031 032 private DataDictionaryService dataDictionaryService; 033 034 BusinessObjectEntryMapper boMapper = new BusinessObjectEntryMapper(); 035 MaintenanceDocumentEntryMapper maintDocMapper = new MaintenanceDocumentEntryMapper(); 036 TransactionalDocumentEntryMapper transDocMapper = new TransactionalDocumentEntryMapper(); 037 038 Map<String,Map> ddMap = new HashMap<String,Map>(); 039 040 public DataDictionaryMap(DataDictionaryService dataDictionaryService) { 041 super(); 042 this.dataDictionaryService = dataDictionaryService; 043 } 044 045 public Object get(Object key) { 046 Map subMap = ddMap.get( key ); 047 if ( subMap == null ) { // need to load from DD 048 synchronized( this ) { // ensure only one update access happening at a time 049 subMap = ddMap.get( key ); 050 if ( subMap == null ) { // recheck in case it was loaded by another thread while this one was blocked 051 DataDictionaryEntry entry = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry( key.toString() ); 052 // if that fails try just using the simple name if a full class name was passed 053 if ( entry == null && key.toString().contains(".")) { 054 entry = dataDictionaryService.getDataDictionary().getDictionaryObjectEntry( StringUtils.substringAfterLast( key.toString(), "." ) ); 055 } 056 if ( entry != null ) { 057 if ( entry instanceof BusinessObjectEntry ) { 058 subMap = boMapper.mapEntry( (BusinessObjectEntry)entry ).getExportData(); 059 } else if ( entry instanceof MaintenanceDocumentEntry ) { 060 subMap = maintDocMapper.mapEntry( (MaintenanceDocumentEntry)entry ).getExportData(); 061 } else if ( entry instanceof TransactionalDocumentEntry ) { 062 subMap = transDocMapper.mapEntry( (TransactionalDocumentEntry)entry ).getExportData(); 063 } 064 } 065 if ( subMap != null ) { 066 ddMap.put( key.toString(), subMap ); 067 } 068 } 069 } 070 } 071 return subMap; 072 } 073 074 public DataDictionaryService getDataDictionaryService() { 075 return dataDictionaryService; 076 } 077 078 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { 079 this.dataDictionaryService = dataDictionaryService; 080 } 081 082}