001/** 002 * Copyright 2005-2015 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/** 030 * @deprecated Only used by KNS classes, no replacement. 031 */ 032@Deprecated 033public class DataDictionaryMap extends DataDictionaryMapBase { 034 035 private DataDictionaryService dataDictionaryService; 036 037 BusinessObjectEntryMapper boMapper = new BusinessObjectEntryMapper(); 038 MaintenanceDocumentEntryMapper maintDocMapper = new MaintenanceDocumentEntryMapper(); 039 TransactionalDocumentEntryMapper transDocMapper = new TransactionalDocumentEntryMapper(); 040 041 Map<String,Map> ddMap = new HashMap<String,Map>(); 042 043 public DataDictionaryMap(DataDictionaryService dataDictionaryService) { 044 super(); 045 this.dataDictionaryService = dataDictionaryService; 046 } 047 048 public Object get(Object key) { 049 Map subMap = ddMap.get( key ); 050 if ( subMap == null ) { // need to load from DD 051 synchronized( this ) { // ensure only one update access happening at a time 052 subMap = ddMap.get( key ); 053 if ( subMap == null ) { // recheck in case it was loaded by another thread while this one was blocked 054 DataDictionaryEntry entry = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry( key.toString() ); 055 // if that fails try just using the simple name if a full class name was passed 056 if ( entry == null && key.toString().contains(".")) { 057 entry = dataDictionaryService.getDataDictionary().getDictionaryObjectEntry( StringUtils.substringAfterLast( key.toString(), "." ) ); 058 } 059 if ( entry != null ) { 060 if ( entry instanceof BusinessObjectEntry ) { 061 subMap = boMapper.mapEntry( (BusinessObjectEntry)entry ).getExportData(); 062 } else if ( entry instanceof MaintenanceDocumentEntry ) { 063 subMap = maintDocMapper.mapEntry( (MaintenanceDocumentEntry)entry ).getExportData(); 064 } else if ( entry instanceof TransactionalDocumentEntry ) { 065 subMap = transDocMapper.mapEntry( (TransactionalDocumentEntry)entry ).getExportData(); 066 } 067 } 068 if ( subMap != null ) { 069 ddMap.put( key.toString(), subMap ); 070 } 071 } 072 } 073 } 074 return subMap; 075 } 076 077 public DataDictionaryService getDataDictionaryService() { 078 return dataDictionaryService; 079 } 080 081 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { 082 this.dataDictionaryService = dataDictionaryService; 083 } 084 085}