annotate src/main/java/de/mpiwg/gazetteer/db/DBSectionVersion.java @ 102:6a508b605b5f

1. add new page : footer.jsp. 2. embed footer.jsp into other pages.
author Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
date Fri, 29 Sep 2017 16:03:06 +0200
parents ce2e3f2814c0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1 package de.mpiwg.gazetteer.db;
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
2
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
3 import java.sql.ResultSet;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
4 import java.sql.SQLException;
25
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
5 import java.text.DateFormat;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
6 import java.text.ParseException;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
7 import java.text.SimpleDateFormat;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
8 import java.util.Date;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
9 import java.util.TimeZone;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
10
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
11 import org.apache.log4j.Logger;
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
12
15
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
13 public class DBSectionVersion implements Comparable<DBSectionVersion>{
25
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
14 private static Logger logger = Logger.getLogger(DBSectionVersion.class);
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
15
10
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
16 private String id;
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
17 private String version;
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
18 private String editor;
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
19 private String date;
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
20 private String books_id;
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
21
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
22 public DBSectionVersion(ResultSet rs) throws SQLException{
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
23 this.id = rs.getString("id");
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
24 this.version = rs.getString("version");
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
25 this.editor = rs.getString("editor");
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
26 this.date = rs.getString("date");
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
27 this.books_id = rs.getString("books_id");
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
28 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
29
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
30 public String getId() {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
31 return id;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
32 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
33
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
34 public void setId(String id) {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
35 this.id = id;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
36 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
37
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
38 public String getVersion() {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
39 return version;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
40 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
41
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
42 public void setVersion(String version) {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
43 this.version = version;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
44 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
45
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
46 public String getEditor() {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
47 return editor;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
48 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
49
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
50 public void setEditor(String editor) {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
51 this.editor = editor;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
52 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
53
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
54 public String getDate() {
25
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
55 // TODO optional time zone
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
56
26
ce2e3f2814c0 new: check userGroup when login
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 25
diff changeset
57 // time zone convert
25
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
58 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
59
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
60 String dateInString = this.date;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
61 Date dateBerlin = null;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
62 try {
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
63 dateBerlin = formatter.parse(dateInString);
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
64 } catch (ParseException e) {
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
65 // TODO Auto-generated catch block
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
66 e.printStackTrace();
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
67 }
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
68 TimeZone tz = TimeZone.getDefault();
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
69
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
70 // From TimeZone Europe/Berlin
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
71 /*
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
72 System.out.println("\nOrignal TimeZone");
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
73 System.out.println("TimeZone : " + tz.getID() + " - " + tz.getDisplayName());
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
74 System.out.println("TimeZone : " + tz);
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
75 System.out.println("Date : " + formatter.format(dateBerlin));
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
76 */
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
77
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
78 // To TimeZone Asia/Taipei
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
79 SimpleDateFormat sdfTaipei = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
80 TimeZone tzInTaipei = TimeZone.getTimeZone("Asia/Taipei"); // Asia/Taipei
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
81 sdfTaipei.setTimeZone(tzInTaipei);
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
82
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
83 String sDateInTaipei = sdfTaipei.format(dateBerlin); // Convert to String first
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
84 Date dateInTaipei = null;
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
85 try {
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
86 dateInTaipei = formatter.parse(sDateInTaipei);
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
87 } catch (ParseException e) {
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
88 // TODO Auto-generated catch block
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
89 e.printStackTrace();
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
90 }
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
91
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
92 /*
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
93 System.out.println("New TimeZone");
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
94 System.out.println("TimeZone : " + tzInTaipei.getID() + " - " + tzInTaipei.getDisplayName());
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
95 System.out.println("TimeZone : " + tzInTaipei);
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
96 System.out.println("Date (String) : " + dateInTaipei);
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
97 System.out.println("Date (Object) : " + formatter.format(dateInTaipei));
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
98 */
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
99
86694755415d new: convert shown edit time to UTC+8
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
100 return formatter.format(dateInTaipei)+"(UTC+8)";
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
101 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
102
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
103 public void setDate(String date) {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
104 this.date = date;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
105 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
106
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
107 public String getBooks_id() {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
108 return books_id;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
109 }
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
110
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
111 public void setBooks_id(String books_id) {
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
112 this.books_id = books_id;
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
113 }
15
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
114
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
115 @Override
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
116 public int compareTo(DBSectionVersion o) {
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
117 return this.getId().compareTo(o.getId());
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
118
15
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
119 }
d81a5401b9af new: sorting in books page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
120
11
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
121
f15b0214cc1c Adding query for table SectionVersion
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents: 10
diff changeset
122
10
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
123
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
124
efe0e7174139 add BooksPage
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
125 }