diff src/main/java/de/mpiwg/gazetteer/utils/AbstractDataProvider.java @ 0:3e62083dbcbf

First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Thu, 23 Apr 2015 15:46:01 +0200
parents
children ce2e3f2814c0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/gazetteer/utils/AbstractDataProvider.java	Thu Apr 23 15:46:01 2015 +0200
@@ -0,0 +1,50 @@
+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);
+		}
+	}
+}