diff src/main/java/de/mpiwg/web/jsp/BooksPage.java @ 11:f15b0214cc1c

Adding query for table SectionVersion
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Tue, 26 May 2015 14:59:37 +0200
parents efe0e7174139
children d57fe2179f61
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/web/jsp/BooksPage.java	Tue May 26 14:39:34 2015 +0200
+++ b/src/main/java/de/mpiwg/web/jsp/BooksPage.java	Tue May 26 14:59:37 2015 +0200
@@ -4,7 +4,9 @@
 import java.sql.ResultSet;
 import java.sql.Statement;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -22,6 +24,7 @@
 	public static String bean = "booksBean";
 	public static String page = "pages/books.jsp";
 	private List<DBBook> completeBookList;
+	private Map<String, DBSectionVersion> sectionVersionMap = null;
 
 	
 	public void loadParameters(HttpServletRequest request, HttpServletResponse response){
@@ -37,6 +40,8 @@
 	public void loadBooks(){
 		logger.debug("loadBooks");
 
+		this.loadSectionsVersion();
+		
 		if(this.completeBookList == null){
 			logger.debug("loading book list");
 			this.completeBookList = new ArrayList<DBBook>();
@@ -45,6 +50,8 @@
 				for(DBBook book : DBService.getInstance().getBooks()){		
 					// TODO: get editor and date by book id
 					
+					book.setCurrentSectionVersion(sectionVersionMap.get(book.getId()));
+					
 					this.completeBookList.add(book);
 				}	
 			}
@@ -53,6 +60,23 @@
 		}
 	}
 	
+	private void loadSectionsVersion(){
+		this.sectionVersionMap = new HashMap<String, DBSectionVersion>();
+		
+		try {
+			for(DBSectionVersion sv : DBService.getInstance().getSectionVersionList()){
+				this.sectionVersionMap.put(sv.getBooks_id(), sv);
+			}	
+		} catch (Exception e) {
+			addMsg("There is an internal error: " + e.getLocalizedMessage());
+			e.printStackTrace();
+		}
+		
+		
+	}
 
+	
+
+	
 
 }