58 |
58 |
return new Result("OK", "200", new ObjectMapper().readValue(redisResponse, Community.class));
|
59 |
59 |
} else {
|
60 |
60 |
connection = statsDB.getConnection();
|
61 |
|
st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT r.id) AS total, COUNT(DISTINCT CASE WHEN r.bestlicense='Open Access' THEN r.id END) AS open_access, COUNT(DISTINCT CASE WHEN r.bestlicense='Embargo' THEN r.id END) AS embargo, COUNT(DISTINCT CASE WHEN r.bestlicense='Restricted' THEN r.id END) AS restricted, COUNT(DISTINCT CASE WHEN r.bestlicense='Closed Access' THEN r.id END) AS closed_access FROM result_concepts rc, result r WHERE rc.id=r.id AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
|
|
61 |
st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT r.id) AS total, COUNT(DISTINCT CASE WHEN r.bestlicense='Open Access' THEN r.id END) AS open_access, COUNT(DISTINCT CASE WHEN r.bestlicense='Embargo' THEN r.id END) AS embargo, COUNT(DISTINCT CASE WHEN r.bestlicense='Restricted' THEN r.id END) AS restricted, COUNT(DISTINCT CASE WHEN r.bestlicense='Closed Access' THEN r.id END) AS closed_access FROM public.result_concepts rc, public.result r WHERE rc.id=r.id AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
|
62 |
62 |
st.setString(1, community_id);
|
63 |
63 |
st.setString(2, community_id);
|
64 |
64 |
|
65 |
65 |
StatsByAccessMode publications = new StatsByAccessMode();
|
66 |
66 |
StatsByAccessMode software = new StatsByAccessMode();
|
67 |
67 |
StatsByAccessMode datasets = new StatsByAccessMode();
|
|
68 |
StatsByAccessMode others = new StatsByAccessMode();
|
68 |
69 |
|
69 |
70 |
rs = st.executeQuery();
|
70 |
71 |
while (rs.next()) {
|
... | ... | |
78 |
79 |
case "dataset":
|
79 |
80 |
datasets = new StatsByAccessMode(rs.getInt(2), rs.getInt(3), rs.getInt(4), rs.getInt(5), rs.getInt(6));
|
80 |
81 |
break;
|
|
82 |
case "other":
|
|
83 |
others = new StatsByAccessMode(rs.getInt(2), rs.getInt(3), rs.getInt(4), rs.getInt(5), rs.getInt(6));
|
|
84 |
break;
|
81 |
85 |
}
|
82 |
86 |
}
|
83 |
87 |
rs.close();
|
84 |
88 |
st.close();
|
85 |
89 |
|
86 |
|
st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT pr.id) FROM result r, result_concepts rc, project_results pr WHERE r.id=rc.id AND r.id=pr.result AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
|
|
90 |
st = connection.prepareStatement("SELECT r.type, COUNT(DISTINCT pr.id) FROM public.result r, public.result_concepts rc, public.project_results pr WHERE r.id=rc.id AND r.id=pr.result AND (rc.concept=? OR rc.concept LIKE ? || '::%') GROUP BY r.type;");
|
87 |
91 |
st.setString(1, community_id);
|
88 |
92 |
st.setString(2, community_id);
|
89 |
93 |
|
... | ... | |
101 |
105 |
case "dataset":
|
102 |
106 |
datasets.setProjects(rs.getInt(2));
|
103 |
107 |
break;
|
|
108 |
case "other":
|
|
109 |
others.setProjects(rs.getInt(2));
|
|
110 |
break;
|
104 |
111 |
}
|
105 |
112 |
}
|
106 |
113 |
rs.close();
|
107 |
114 |
st.close();
|
108 |
115 |
|
109 |
|
st = connection.prepareStatement("SELECT COUNT(DISTINCT c.name) FROM result_concepts rc, concept c, category cat WHERE c.id=rc.concept AND cat.id=c.category AND cat.id=? || '::virtual';");
|
|
116 |
st = connection.prepareStatement("SELECT COUNT(DISTINCT c.name) FROM public.result_concepts rc, public.concept c, public.category cat WHERE c.id=rc.concept AND cat.id=c.category AND cat.id=? || '::virtual';");
|
110 |
117 |
st.setString(1, community_id);
|
111 |
118 |
|
112 |
119 |
int virtual_organizations = 0;
|
... | ... | |
115 |
122 |
virtual_organizations = rs.getInt(1);
|
116 |
123 |
}
|
117 |
124 |
|
118 |
|
Community community = new Community(publications, datasets, software, projects, virtual_organizations);
|
|
125 |
Community community = new Community(publications, datasets, software, others, projects, virtual_organizations);
|
119 |
126 |
jedis.put(redisKey, "persistent", "false");
|
120 |
127 |
jedis.put(redisKey, "result", new ObjectMapper().writeValueAsString(community));
|
121 |
128 |
|
add other research products