Mercurial > hg > LGServices
changeset 93:88a485937f9a
New feature : export csv file with new two fields : book year and edition year
author | Calvin Yeh <cyeh@mpipw-berlin.mpg.com> |
---|---|
date | Wed, 21 Jun 2017 06:25:34 +0200 |
parents | fce05323fb2f |
children | d0dcbe8254f5 |
files | src/main/java/de/mpiwg/gazetteer/rest/GetSectionMetadata.java |
diffstat | 1 files changed, 21 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/rest/GetSectionMetadata.java Wed Jun 21 06:20:29 2017 +0200 +++ b/src/main/java/de/mpiwg/gazetteer/rest/GetSectionMetadata.java Wed Jun 21 06:25:34 2017 +0200 @@ -15,29 +15,29 @@ public class GetSectionMetadata extends AbstractServletMethod { public static String name = "getSectionMetadata"; - + public static void execute(HttpServletRequest request, HttpServletResponse response) throws Exception{ - + Long sectionId = getQueryLongParam(request, "sectionId"); - + if(sectionId != null){ DBSection section = DBService.getSectionWithContent(sectionId); if(section != null){ //DBBook book = DBService.getBookFromDB(section.getBookId()); DBBook book = DBService.getInstance().getBook(section.getBookId()); - + response.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("status", "ok"); - - + + JSONObject sectionJson = new JSONObject(); sectionJson.put("id", section.getId()); sectionJson.put("name", section.getName()); sectionJson.put("start_page", section.getStart_page()); sectionJson.put("end_page", section.getEnd_page()); - - + + JSONObject bookJson = new JSONObject(); bookJson.put("id", book.getId()); bookJson.put("name", book.getName()); @@ -49,32 +49,34 @@ bookJson.put("level1", book.getLevel1()); bookJson.put("level2", book.getLevel2()); bookJson.put("admin_type", book.getAdmin_type()); - bookJson.put("in_jibengujiku", book.getIn_jibengujiku()); + bookJson.put("in_jibengujiku", book.getIn_jibengujiku()); bookJson.put("dynasty", book.getDynasty()); bookJson.put("start_year", book.getStart_year()); bookJson.put("end_year", book.getEnd_year()); - + bookJson.put("book_year", book.getBookYear()); + bookJson.put("edition_year", book.getEditionYear()); + sectionJson.put("book", bookJson); - + DBCoordinatesBook coor_book = DBService.getInstance().getCoordinatesBook(section.getBookId()); - + JSONObject coordinates_books = new JSONObject(); coordinates_books.put("place_name", coor_book.getPlace_name()); coordinates_books.put("x", coor_book.getX()); coordinates_books.put("y", coor_book.getY()); - + sectionJson.put("coordinates_books", coordinates_books); - - - + + + json.put("section", sectionJson); - - + + PrintWriter out = response.getWriter(); out.print(json.toString()); out.flush(); - + }else{ response.setContentType("application/json"); JSONObject json = new JSONObject();