annotate src/main/java/de/mpiwg/gazetteer/utils/JSONUtils.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 3e62083dbcbf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.utils;
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 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
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 de.mpiwg.gazetteer.bo.LGBranch;
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 de.mpiwg.gazetteer.bo.LGFile;
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 public class JSONUtils {
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 public static String getString(JSONObject json, String label){
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
11 try {
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 return (json.has(label)) ? json.getString(label) : 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
13 } catch (Exception e) {}
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 return 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
15 }
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 Long getLong(JSONObject json, String label){
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
18 try {
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 return (json.has(label)) ? json.getLong(label) : 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
20 } catch (Exception e) {}
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 return 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
22 }
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
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 public static JSONObject branch2JSON(LGBranch branch){
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 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
26
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 try {
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
28
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 json.put("id", branch.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
30 json.put("label", branch.getLabel());
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("sectionId", branch.getSectionId());
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
32 json.put("currentLastFileId", branch.getCurrentLastFileId());
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
33 json.put("creatorId", branch.getUserId());
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 json.put("creationDate", branch.getFomattedCreation());
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 json.put("info", branch.getInfo());
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
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 } catch (Exception e) {
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 e.printStackTrace();
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
39 }
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
40
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 return 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
42 }
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
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 public static JSONObject file2JSON(LGFile file, boolean includeText){
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 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
46
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 try {
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
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 json.put("id", file.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
50 json.put("version", file.getVersion());
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 json.put("fileName", file.getFileName());
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
52 json.put("info", file.getInfo());
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 json.put("creatorId", file.getUserId());
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 json.put("creationDate", file.getFomattedCreation());
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
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
56 if(includeText){
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
57 json.put("text", file.getContent());
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
58 }
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
59
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
60 } catch (Exception e) {
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
61 e.printStackTrace();
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
62 }
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
63
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
64 return 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
65 }
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
66 }