44 |
44 |
|
45 |
45 |
|
46 |
46 |
@Override
|
47 |
|
public Map<String, String> getStatistics() throws JSONException {
|
|
47 |
public Map<String, Object> getStatistics() throws JSONException {
|
48 |
48 |
|
49 |
49 |
|
50 |
50 |
String aggregators = getTotalByType("datasource",baseAddress+"/resources",
|
... | ... | |
72 |
72 |
String publications = getTotalByType("other",baseAddress,"/publications/count");
|
73 |
73 |
String datasets = getTotalByType("other",baseAddress,"/datasets/count");
|
74 |
74 |
String software = getTotalByType("other",baseAddress,"/software/count");
|
75 |
|
String usagestats = getUsageStatsTotal();
|
|
75 |
JSONObject usagestats = getUsageStatsTotal();
|
76 |
76 |
|
77 |
77 |
|
78 |
|
HashMap<String,String> stats = new HashMap<>();
|
|
78 |
HashMap<String,Object> stats = new HashMap<>();
|
79 |
79 |
stats.put("aggregators",aggregators);
|
80 |
80 |
stats.put("dataRepositories",dataRepositories);
|
81 |
81 |
stats.put("literature",literature);
|
... | ... | |
84 |
84 |
stats.put("publications",publications);
|
85 |
85 |
stats.put("datasets",datasets);
|
86 |
86 |
stats.put("software",software);
|
87 |
|
stats.put("usagestats",usagestats);
|
88 |
87 |
|
|
88 |
stats.put("usagestats",usagestats.toString());
|
89 |
89 |
|
|
90 |
|
90 |
91 |
return stats;
|
91 |
92 |
}
|
92 |
93 |
|
... | ... | |
109 |
110 |
|
110 |
111 |
}
|
111 |
112 |
|
112 |
|
private String getUsageStatsTotal() throws JSONException {
|
|
113 |
private JSONObject getUsageStatsTotal() throws JSONException {
|
113 |
114 |
UriComponents uriComponents = UriComponentsBuilder
|
114 |
115 |
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
115 |
116 |
.build().encode();
|
... | ... | |
121 |
122 |
|
122 |
123 |
Integer downloads = lastYear.getInt("downloads");
|
123 |
124 |
Integer views = lastYear.getInt("views");
|
|
125 |
String year = lastYear.getString("year");
|
124 |
126 |
|
125 |
|
return String.valueOf(downloads+views);
|
|
127 |
JSONObject usagestats = new JSONObject();
|
|
128 |
usagestats.put("number",String.valueOf(downloads+views));
|
|
129 |
usagestats.put("year",year);
|
|
130 |
|
|
131 |
return usagestats;
|
126 |
132 |
}
|
127 |
133 |
}
|
Add year on usagestats