Mercurial > hg > LGServices
annotate src/main/java/de/mpiwg/gazetteer/rest/GetSectionMetadata.java @ 105:16a0796e3871 default tip
remove "console.log" from general.js
author | Calvin Yeh <cyeh@mpipw-berlin.mpg.com> |
---|---|
date | Fri, 29 Sep 2017 16:18:02 +0200 |
parents | 88a485937f9a |
children |
rev | line source |
---|---|
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
1 package de.mpiwg.gazetteer.rest; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
2 |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
3 import java.io.PrintWriter; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
4 |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
5 import javax.servlet.http.HttpServletRequest; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
6 import javax.servlet.http.HttpServletResponse; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
7 |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
8 import org.json.JSONObject; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
9 |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
10 import de.mpiwg.gazetteer.db.DBBook; |
19 | 11 import de.mpiwg.gazetteer.db.DBCoordinatesBook; |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
12 import de.mpiwg.gazetteer.db.DBSection; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
13 import de.mpiwg.gazetteer.utils.DBService; |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
14 |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
15 public class GetSectionMetadata extends AbstractServletMethod { |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
16 |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
17 public static String name = "getSectionMetadata"; |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
18 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
19 public static void execute(HttpServletRequest request, HttpServletResponse response) throws Exception{ |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
20 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
21 Long sectionId = getQueryLongParam(request, "sectionId"); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
22 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
23 if(sectionId != null){ |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
24 DBSection section = DBService.getSectionWithContent(sectionId); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
25 if(section != null){ |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
26 //DBBook book = DBService.getBookFromDB(section.getBookId()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
27 DBBook book = DBService.getInstance().getBook(section.getBookId()); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
28 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
29 response.setContentType("application/json"); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
30 JSONObject json = new JSONObject(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
31 json.put("status", "ok"); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
32 |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
33 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
34 JSONObject sectionJson = new JSONObject(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
35 sectionJson.put("id", section.getId()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
36 sectionJson.put("name", section.getName()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
37 sectionJson.put("start_page", section.getStart_page()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
38 sectionJson.put("end_page", section.getEnd_page()); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
39 |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
40 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
41 JSONObject bookJson = new JSONObject(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
42 bookJson.put("id", book.getId()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
43 bookJson.put("name", book.getName()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
44 bookJson.put("author", book.getAuthor()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
45 bookJson.put("edition", book.getEdition()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
46 bookJson.put("line", book.getLine()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
47 bookJson.put("period", book.getPeriod()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
48 bookJson.put("volume", book.getVolume()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
49 bookJson.put("level1", book.getLevel1()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
50 bookJson.put("level2", book.getLevel2()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
51 bookJson.put("admin_type", book.getAdmin_type()); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
52 bookJson.put("in_jibengujiku", book.getIn_jibengujiku()); |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
53 bookJson.put("dynasty", book.getDynasty()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
54 bookJson.put("start_year", book.getStart_year()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
55 bookJson.put("end_year", book.getEnd_year()); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
56 bookJson.put("book_year", book.getBookYear()); |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
57 bookJson.put("edition_year", book.getEditionYear()); |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
58 |
19 | 59 sectionJson.put("book", bookJson); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
60 |
19 | 61 |
62 DBCoordinatesBook coor_book = DBService.getInstance().getCoordinatesBook(section.getBookId()); | |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
63 |
19 | 64 JSONObject coordinates_books = new JSONObject(); |
65 coordinates_books.put("place_name", coor_book.getPlace_name()); | |
66 coordinates_books.put("x", coor_book.getX()); | |
67 coordinates_books.put("y", coor_book.getY()); | |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
68 |
19 | 69 sectionJson.put("coordinates_books", coordinates_books); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
70 |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
71 |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
72 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
73 json.put("section", sectionJson); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
74 |
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
75 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
76 PrintWriter out = response.getWriter(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
77 out.print(json.toString()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
78 out.flush(); |
93
88a485937f9a
New feature : export csv file with new two fields : book year and edition year
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
19
diff
changeset
|
79 |
0
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
80 }else{ |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
81 response.setContentType("application/json"); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
82 JSONObject json = new JSONObject(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
83 json.put("status", "error"); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
84 json.put("message", "Section no found (" + sectionId + ")"); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
85 PrintWriter out = response.getWriter(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
86 out.print(json.toString()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
87 out.flush(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
88 } |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
89 }else{ |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
90 response.setContentType("application/json"); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
91 JSONObject json = new JSONObject(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
92 json.put("status", "error"); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
93 json.put("message", "Following parameters are mandatory: sectionId."); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
94 PrintWriter out = response.getWriter(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
95 out.print(json.toString()); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
96 out.flush(); |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
97 } |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
98 } |
3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff
changeset
|
99 } |