view src/main/java/de/mpiwg/gazetteer/utils/AbstractDataProvider.java @ 22:2c6f44ef34ab

new: add comment textarea
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 23 Jun 2015 16:18:52 +0200
parents 3e62083dbcbf
children ce2e3f2814c0
line wrap: on
line source

package de.mpiwg.gazetteer.utils;

import java.util.List;

import cl.maps.duplex.DuplexMap;
import de.mpiwg.gazetteer.bo.LGBranch;
import de.mpiwg.gazetteer.bo.LGFile;
import de.mpiwg.gazetteer.bo.SearchRulesFile;

public class AbstractDataProvider {

	
	//###############################
	
	private DuplexMap<LGBranch, Long, Long> branchMap = null;
	
	protected DuplexMap<LGBranch, Long, Long> getBranchMap(){
		if(branchMap == null){
			loadBranches();
		}
		return branchMap;
	}
	
	public void loadBranches(){
		List<LGBranch> list = DBService.getAllLGBranchFromDB();
		this.branchMap = new DuplexMap<LGBranch, Long, Long>();
		for(LGBranch item : list){
			this.branchMap.put(item.getKey(), item);
		}
	}
	
	
	private DuplexMap<LGFile, Long, Long> fileMap = null;
	
	protected DuplexMap<LGFile, Long, Long> getFileMap(){
		if(fileMap == null){
			loadFiles();
		}
		return fileMap;
	}
	
	
	private void loadFiles(){
		List<LGFile> list = DBService.getAllLGFileFromDB();
		this.fileMap = new DuplexMap<LGFile, Long, Long>();
		for(LGFile file : list){
			this.fileMap.put(file.getKey(), file);
		}
	}
}