diff src/main/java/de/mpiwg/gazetteer/utils/DBService.java @ 40:35ed4e650a53

bug fixed: full text search when section not found in section_index table. add paginator
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 07 Dec 2015 17:06:57 +0100
parents 37840afb7b80
children ba9515f22897
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java	Fri Dec 04 14:28:44 2015 +0100
+++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java	Mon Dec 07 17:06:57 2015 +0100
@@ -315,12 +315,21 @@
 				
 			}
 			rs.close();
+			
 		} catch (Exception e) {
 			e.printStackTrace();
 		} finally {
 			conn.close();
 		}
 		
+		if (section == null) {	
+			// section_index table is not completely correct by TOC_edit task (done by human), so query finds null in section
+
+			section = new DBSection();
+			section.setBookId(bookId);
+			DBBook book = getInstance().getBook(bookId);
+			section.setBook(book);
+		}
 		
 		return section;
 		
@@ -344,7 +353,7 @@
 		
 		String sql = "SELECT contents.id, contents.books_id AS books_id, contents.line AS line, contents.content AS content " +
                     	"FROM contents " +
-                    	"WHERE " + condition + "and (books_id='00204' or books_id='00219')";	// TODO: remove the books_id condition after debug
+                    	"WHERE " + condition;//+ "and (books_id='00204' or books_id='00219')";	// remove the books_id condition after debug
              
 		//logger.debug("sql: " + sql);
 
@@ -371,6 +380,17 @@
 			conn.close();
 		}
 		
+		// setting section in each DBContents content
+		for (DBContents content : resultSet) {
+			// set this.section by bookId and page
+			content.setSection(DBService.getInstance().getSectionByBookIdAndPage(content.getBookId(), content.getPage()));
+		
+			// set this.coordinatesBook by bookId
+			content.setCoordinatesBook(DBService.getInstance().getCoordinatesBook(content.getBookId()));
+		}		
+		
+		
+		
 		long end = System.currentTimeMillis();
 		logger.debug("Time execution full text search [ms]: " + (end - start));
 		
@@ -886,6 +906,9 @@
 		
 	}
 
+	
+	// remove it
+	/*
 	public static LGFullTextSearchFile getExistFullTextSearchFile(Long userId, String fileName) {		
 		//logger.info("getExistFullTextSearchFile: (userId,fileName)=" + userId + ","+fileName);
 		List<LGFullTextSearchFile> list = new ArrayList<LGFullTextSearchFile>();
@@ -908,5 +931,5 @@
 		}
 				
 	}
-
+	 */
 }