64 |
64 |
}*/
|
65 |
65 |
|
66 |
66 |
|
67 |
|
protected UsageStats executePreparedQuery(String query, List<String> values) {
|
|
67 |
protected UsageStats executePreparedQuery(String query, List<String> values, String type) {
|
68 |
68 |
UsageStats usageStats = new UsageStats();
|
69 |
69 |
int total_views = 0;
|
70 |
70 |
int total_downloads = 0;
|
... | ... | |
82 |
82 |
|
83 |
83 |
ResultSet rs = st.executeQuery();
|
84 |
84 |
|
85 |
|
while (rs.next()) {
|
86 |
|
if(rs.getString(3) != null && !rs.getString(3).equals("") && !rs.getString(3).equals("null")) {
|
87 |
|
if (rs.getString(1).equals("views")) {
|
88 |
|
//usageStats.addViews(rs.getString(2) + ":" + rs.getString(3));
|
89 |
|
usageStats.addViews(new RepoStats("",rs.getString(2),rs.getString(3)));
|
90 |
|
total_views += Integer.parseInt(rs.getString(3));
|
91 |
|
} else if (rs.getString(1).equals("downloads")) {
|
92 |
|
//usageStats.addDownloads(rs.getString(2) + ":" + rs.getString(3));
|
93 |
|
usageStats.addDownloads(new RepoStats("",rs.getString(2),rs.getString(3)));
|
94 |
|
total_downloads += Integer.parseInt(rs.getString(3));
|
|
85 |
if(type.equals("result") || type.equals("datasource")){
|
|
86 |
while (rs.next()) {
|
|
87 |
//if() {
|
|
88 |
if (rs.getString(1).equals("views") && rs.getString(4) != null && !rs.getString(4).equals("") && !rs.getString(4).equals("null")) {
|
|
89 |
//usageStats.addViews(rs.getString(2) + ":" + rs.getString(3));
|
|
90 |
//usageStats.addViews(new RepoStats("",rs.getString(2),rs.getString(3)));
|
|
91 |
usageStats.addViews(new RepoStats(rs.getString(3),rs.getString(2),rs.getString(4)));
|
|
92 |
total_views += Integer.parseInt(rs.getString(4));
|
|
93 |
} else if (rs.getString(1).equals("downloads") && rs.getString(4) != null && !rs.getString(4).equals("") && !rs.getString(4).equals("null")) {
|
|
94 |
//usageStats.addDownloads(rs.getString(2) + ":" + rs.getString(3));
|
|
95 |
//usageStats.addDownloads(new RepoStats("",rs.getString(2),rs.getString(3)));
|
|
96 |
usageStats.addDownloads(new RepoStats(rs.getString(3),rs.getString(2),rs.getString(4)));
|
|
97 |
total_downloads += Integer.parseInt(rs.getString(4));
|
|
98 |
}
|
|
99 |
//}
|
|
100 |
//UsageStats stats = new UsageStats();
|
|
101 |
//stats.setId(rs.getString(1));
|
|
102 |
//stats.setName(rs.getString(2));
|
|
103 |
//stats.setOid(rs.getString(3));
|
|
104 |
//stats.setSource(rs.getString(1));
|
|
105 |
//stats.setValue(rs.getInt(2));
|
|
106 |
//statsList.add(stats);
|
|
107 |
}
|
|
108 |
|
|
109 |
//if (total_views!= 0){
|
|
110 |
//usageStats.addViews(new RepoStats("Total",Integer.toString(total_views)));
|
|
111 |
usageStats.setTotal_views(Integer.toString(total_views));
|
|
112 |
//}
|
|
113 |
//if (total_downloads!= 0){
|
|
114 |
//usageStats.addDownloads(new RepoStats("Total",Integer.toString(total_downloads)));
|
|
115 |
usageStats.setTotal_downloads(Integer.toString(total_downloads));
|
|
116 |
//}
|
|
117 |
}
|
|
118 |
else if(type.equals("project")){
|
|
119 |
while(rs.next()){
|
|
120 |
if (rs.getString(1).equals("views") && rs.getString(2) != null && !rs.getString(2).equals("") && !rs.getString(2).equals("null")) {
|
|
121 |
total_views += Integer.parseInt(rs.getString(2));
|
|
122 |
} else if (rs.getString(1).equals("downloads") && rs.getString(2) != null && !rs.getString(2).equals("") && !rs.getString(2).equals("null")) {
|
|
123 |
total_downloads += Integer.parseInt(rs.getString(2));
|
95 |
124 |
}
|
96 |
125 |
}
|
97 |
|
//UsageStats stats = new UsageStats();
|
98 |
|
//stats.setId(rs.getString(1));
|
99 |
|
//stats.setName(rs.getString(2));
|
100 |
|
//stats.setOid(rs.getString(3));
|
101 |
|
//stats.setSource(rs.getString(1));
|
102 |
|
//stats.setValue(rs.getInt(2));
|
103 |
|
//statsList.add(stats);
|
|
126 |
usageStats.setTotal_views(Integer.toString(total_views));
|
|
127 |
usageStats.setTotal_downloads(Integer.toString(total_downloads));
|
104 |
128 |
}
|
105 |
|
//if (total_views!= 0){
|
106 |
|
//usageStats.addViews(new RepoStats("Total",Integer.toString(total_views)));
|
107 |
|
usageStats.setTotal_views(Integer.toString(total_views));
|
108 |
|
//}
|
109 |
|
//if (total_downloads!= 0){
|
110 |
|
//usageStats.addDownloads(new RepoStats("Total",Integer.toString(total_downloads)));
|
111 |
|
usageStats.setTotal_downloads(Integer.toString(total_downloads));
|
112 |
|
//}
|
113 |
129 |
|
114 |
130 |
rs.close();
|
115 |
131 |
st.close();
|
... | ... | |
175 |
191 |
ResultSet rs;
|
176 |
192 |
switch (split[0].toLowerCase()) {
|
177 |
193 |
case "openaire":
|
178 |
|
st = connection.prepareStatement("select \"PiwikID\" from \"DatasourcesPiwikOAIDs\" where \"OpenAIRE_ID\"=?");
|
|
194 |
st = connection.prepareStatement("select piwik_id from datasource_piwik where openaire_id=?");
|
|
195 |
//st = connection.prepareStatement("select piwik_id from datasource where id=?");
|
179 |
196 |
st.setString(1, repositoryIdentifier.replaceFirst(split[0] + ":", ""));
|
180 |
197 |
|
181 |
198 |
rs = st.executeQuery();
|
... | ... | |
188 |
205 |
return piwikid;
|
189 |
206 |
|
190 |
207 |
case "repoid":
|
191 |
|
st = connection.prepareStatement("select \"PiwikID\" from \"DatasourcesPiwikOAIDs\" where \"PiwikID\"=?");
|
|
208 |
st = connection.prepareStatement("select piwik_id from datasource_piwik where piwik_id=?");
|
|
209 |
//st = connection.prepareStatement("select piwik_id from datasource where id=?");
|
192 |
210 |
st.setInt(1, Integer.parseInt(repositoryIdentifier.replaceFirst(split[0] + ":", "")));
|
193 |
211 |
|
194 |
212 |
rs = st.executeQuery();
|
... | ... | |
278 |
296 |
PreparedStatement st;
|
279 |
297 |
if(itemDataType.equals("")) {
|
280 |
298 |
st = connection.prepareStatement("select r.title, r.publisher, rc.type, r.source, r.id from result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=? limit 1");
|
|
299 |
//st = connection.prepareStatement("select r.title, r.publisher, rc.type, r.source, r.id, d.name from result r, result_oids roid, result_classifications rc, result_datasources rd, datasource d where rd.id=r.id and rd.datasource=d.id and r.id=roid.id and r.id=rc.id and roid.orid=? limit 1");
|
281 |
300 |
st.setString(1, oid);
|
282 |
301 |
}
|
283 |
302 |
else{
|
284 |
303 |
st = connection.prepareStatement("select r.title, r.publisher, rc.type, r.source, r.id from result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=? and rc.type=? limit 1");
|
|
304 |
//st = connection.prepareStatement("select r.title, r.publisher, rc.type, r.source, r.id, d.name from result r, result_oids roid, result_classifications rc, result_datasources rd, datasource d where rd.id=r.id and rd.datasource=d.id and r.id=roid.id and r.id=rc.id and roid.orid=? and rc.type=? limit 1");
|
285 |
305 |
st.setString(1, oid);
|
286 |
306 |
st.setString(2, itemDataType);
|
287 |
307 |
}
|
... | ... | |
291 |
311 |
boolean hasData = false;
|
292 |
312 |
while (rs.next()) {
|
293 |
313 |
reportItem = new ReportItem(rs.getString(2),"", rs.getString(3),rs.getString(1));
|
|
314 |
//reportItem = new ReportItem(rs.getString(2),rs.getString(6), rs.getString(3),rs.getString(1));
|
294 |
315 |
reportItem.addIdentifier(new ItemIdentifier("URL",rs.getString(4)));
|
295 |
316 |
reportItem.addIdentifier(new ItemIdentifier("OAI",oid));
|
296 |
317 |
reportItem.addIdentifier(new ItemIdentifier("OPENAIRE",rs.getString(5)));
|
... | ... | |
338 |
359 |
|
339 |
360 |
//st = connection.prepareStatement("select extract('year' from date) ||'-'|| extract('month' from date) ||'-01' as new_date, sum(number_of_downloads) from repo_download_stats where id=? and date>=? and date<=? group by new_date order by new_date");
|
340 |
361 |
if(repositoryIdentifier.equals("")) {
|
341 |
|
//st = connection.prepareStatement("select month, sum from repo_download_stats_monthly where id=? and month>=? and month<=? order by month;");
|
342 |
|
st = connection.prepareStatement("select d.date, case when sum is null then 0 else sum end as sum from (SELECT to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS date FROM generate_series(0, ?, 1) AS offs) d LEFT JOIN (select month, sum from repo_download_stats_monthly where id=? and month>=? and month<=?) rdsm ON d.date=rdsm.month;");
|
|
362 |
//st = connection.prepareStatement("select month, sum from repo_download_stats_monthly_sushi where id=? and month>=? and month<=? order by month;");
|
|
363 |
st = connection.prepareStatement("select d.date, case when sum is null then 0 else sum end as sum from (SELECT to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS date FROM generate_series(0, ?, 1) AS offs) d LEFT JOIN (select month, sum from repo_download_stats_monthly_sushi where id=? and month>=? and month<=?) rdsm ON d.date=rdsm.month;");
|
343 |
364 |
}
|
344 |
365 |
else{
|
345 |
|
//st = connection.prepareStatement("select month, sum from repo_download_stats_monthly where id=? and month>=? and month<=? and source=? order by month;");
|
346 |
|
st = connection.prepareStatement("select d.date, case when sum is null then 0 else sum end as sum from (SELECT to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS date FROM generate_series(0, ?, 1) AS offs) d LEFT JOIN (select month, sum from repo_download_stats_monthly where id=? and month>=? and month<=? and source=?) rdsm ON d.date=rdsm.month;");
|
|
366 |
//st = connection.prepareStatement("select month, sum from repo_download_stats_monthly_sushi where id=? and month>=? and month<=? and source=? order by month;");
|
|
367 |
st = connection.prepareStatement("select d.date, case when sum is null then 0 else sum end as sum from (SELECT to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS date FROM generate_series(0, ?, 1) AS offs) d LEFT JOIN (select month, sum from repo_download_stats_monthly_sushi where id=? and month>=? and month<=? and source=?) rdsm ON d.date=rdsm.month;");
|
347 |
368 |
st.setInt(6, Integer.parseInt(repositoryIdentifier));
|
348 |
369 |
}
|
349 |
370 |
st.setString(1, report_dateFormat.format(beginDate));
|
... | ... | |
384 |
405 |
}
|
385 |
406 |
return 0;
|
386 |
407 |
}
|
387 |
|
protected int executeOidOLD(List<ReportItem> reportItems, String oid, String repositoryIdentifier, String itemDataType, Date beginDate, Date endDate, String granularity){
|
388 |
|
ReportItem reportItem = null;
|
389 |
|
SimpleDateFormat report_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
390 |
|
Boolean hasReports = false;
|
391 |
408 |
|
392 |
|
try {
|
393 |
|
Connection connection = dataSource.getConnection();
|
394 |
|
PreparedStatement st;
|
395 |
|
if(itemDataType.equals("")) {
|
396 |
|
st = connection.prepareStatement("select r.title, r.publisher, rc.type, r.source, r.id from result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=? limit 1");
|
397 |
|
st.setString(1, oid);
|
398 |
|
}
|
399 |
|
else{
|
400 |
|
st = connection.prepareStatement("select r.title, r.publisher, rc.type, r.source, r.id from result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=? and rc.type=? limit 1");
|
401 |
|
st.setString(1, oid);
|
402 |
|
st.setString(2, itemDataType);
|
403 |
|
}
|
404 |
|
|
405 |
|
ResultSet rs = st.executeQuery();
|
406 |
|
|
407 |
|
boolean hasData = false;
|
408 |
|
while (rs.next()) {
|
409 |
|
reportItem = new ReportItem(rs.getString(2),"", rs.getString(3),rs.getString(1));
|
410 |
|
reportItem.addIdentifier(new ItemIdentifier("URL",rs.getString(4)));
|
411 |
|
reportItem.addIdentifier(new ItemIdentifier("OAI",oid));
|
412 |
|
reportItem.addIdentifier(new ItemIdentifier("OPENAIRE",rs.getString(5)));
|
413 |
|
hasData = true;
|
414 |
|
}
|
415 |
|
rs.close();
|
416 |
|
st.close();
|
417 |
|
if(!hasData){
|
418 |
|
connection.close();
|
419 |
|
return -1;
|
420 |
|
}
|
421 |
|
//log.error(report_dateFormat.format(c.getTime()));
|
422 |
|
if (granularity.toLowerCase().equals("totals")){
|
423 |
|
if(repositoryIdentifier.equals("")) {
|
424 |
|
st = connection.prepareStatement("select sum(number_of_downloads) from repo_download_stats where id=? and date>=? and date<=?");
|
425 |
|
}
|
426 |
|
else{
|
427 |
|
st = connection.prepareStatement("select sum(number_of_downloads) from repo_download_stats where id=? and date>=? and date<=? and source=?");
|
428 |
|
st.setInt(4, Integer.parseInt(repositoryIdentifier));
|
429 |
|
}
|
430 |
|
st.setString(1, oid);
|
431 |
|
//st.setString(2, sql_dateFormat.format(in_beginDate));
|
432 |
|
//st.setString(3, sql_dateFormat.format(in_endDate));
|
433 |
|
st.setDate(2, new java.sql.Date(beginDate.getTime()));
|
434 |
|
st.setDate(3, new java.sql.Date(endDate.getTime()));
|
435 |
|
//log.error(new SimpleDateFormat("yyyy-MM-dd").format(input_dateFormat.parse(beginDate)));
|
436 |
|
|
437 |
|
log.error("qqqq: " + st);
|
438 |
|
|
439 |
|
rs = st.executeQuery();
|
440 |
|
while(rs.next()){
|
441 |
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), rs.getString(1)));
|
442 |
|
hasReports = true;
|
443 |
|
}
|
444 |
|
rs.close();
|
445 |
|
st.close();
|
446 |
|
}
|
447 |
|
else if (granularity.toLowerCase().equals("monthly")){
|
448 |
|
//st = connection.prepareStatement("select extract('year' from date) ||'-'|| extract('month' from date) ||'-01' as new_date, sum(number_of_downloads) from repo_download_stats where id=? and date>=? and date<=? group by new_date order by new_date");
|
449 |
|
if(repositoryIdentifier.equals("")) {
|
450 |
|
st = connection.prepareStatement("select month, sum from repo_download_stats_monthly where id=? and month>=? and month<=? order by month;");
|
451 |
|
}
|
452 |
|
else{
|
453 |
|
st = connection.prepareStatement("select month, sum from repo_download_stats_monthly where id=? and month>=? and month<=? and source=? order by month;");
|
454 |
|
st.setInt(4, Integer.parseInt(repositoryIdentifier));
|
455 |
|
}
|
456 |
|
st.setString(1, oid);
|
457 |
|
//st.setString(2, sql_dateFormat.format(in_beginDate));
|
458 |
|
//st.setString(3, sql_dateFormat.format(in_endDate));
|
459 |
|
//st.setDate(2, new java.sql.Date(beginDate.getTime()));
|
460 |
|
//st.setDate(3, new java.sql.Date(endDate.getTime()));
|
461 |
|
st.setString(2, new SimpleDateFormat("yyyy-MM-dd").format(beginDate));
|
462 |
|
st.setString(3, new SimpleDateFormat("yyyy-MM-dd").format(endDate));
|
463 |
|
|
464 |
|
log.error("qqqq: " + st);
|
465 |
|
|
466 |
|
Calendar start = Calendar.getInstance();
|
467 |
|
start.setTime(beginDate);
|
468 |
|
Calendar end = Calendar.getInstance();
|
469 |
|
end.setTime(endDate);
|
470 |
|
Date date = start.getTime();
|
471 |
|
|
472 |
|
rs = st.executeQuery();
|
473 |
|
|
474 |
|
while(rs.next()){
|
475 |
|
hasReports = true;
|
476 |
|
Date rs_date = rs.getDate(1);
|
477 |
|
while(date.before(rs_date) && !date.equals(rs_date)){
|
478 |
|
Calendar temp_c = Calendar.getInstance();
|
479 |
|
temp_c.setTime(date);
|
480 |
|
temp_c.set(Calendar.DAY_OF_MONTH, temp_c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
481 |
|
Date temp_endDate = temp_c.getTime();
|
482 |
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(date), report_dateFormat.format(temp_endDate),"0"));
|
483 |
|
start.add(Calendar.MONTH, 1);
|
484 |
|
date = start.getTime();
|
485 |
|
}
|
486 |
|
Calendar temp_c = Calendar.getInstance();
|
487 |
|
temp_c.setTime(rs_date);
|
488 |
|
temp_c.set(Calendar.DAY_OF_MONTH, temp_c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
489 |
|
Date temp_endDate = temp_c.getTime();
|
490 |
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(rs_date), report_dateFormat.format(temp_endDate), rs.getString(2)));
|
491 |
|
start.add(Calendar.MONTH, 1);
|
492 |
|
date = start.getTime();
|
493 |
|
}
|
494 |
|
rs.close();
|
495 |
|
st.close();
|
496 |
|
|
497 |
|
for (; start.before(end); start.add(Calendar.MONTH, 1), date = start.getTime()) {
|
498 |
|
Calendar temp_c = Calendar.getInstance();
|
499 |
|
temp_c.setTime(date);
|
500 |
|
temp_c.set(Calendar.DAY_OF_MONTH, temp_c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
501 |
|
Date temp_endDate = temp_c.getTime();
|
502 |
|
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(date), report_dateFormat.format(temp_endDate),"0"));
|
503 |
|
//log.error("DATE: " + date + " TO: " + temp_endDate);
|
504 |
|
|
505 |
|
}
|
506 |
|
}
|
507 |
|
|
508 |
|
connection.close();
|
509 |
|
} catch (Exception e) {
|
510 |
|
log.error("Cannot execute oid : " + e);
|
511 |
|
}
|
512 |
|
if(hasReports) {
|
513 |
|
reportItems.add(reportItem);
|
514 |
|
}
|
515 |
|
return 0;
|
516 |
|
}
|
517 |
|
|
518 |
409 |
protected int executeRepo(List<ReportItem> reportItems, String repositoryIdentifier, String itemDataType, Date beginDate, Date endDate, String granularity){
|
519 |
410 |
SimpleDateFormat report_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
520 |
411 |
try {
|
... | ... | |
524 |
415 |
if (granularity.toLowerCase().equals("totals")) {
|
525 |
416 |
if(repositoryIdentifier.equals("")){
|
526 |
417 |
if(itemDataType.equals("")){
|
527 |
|
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, \"DatasourcesPiwikOAIDs\" dpo, datasource d where rds.source=dpo.\"PiwikID\" and dpo.\"OpenAIRE_ID\"=d.id and rds.date>=? and rds.date<=? group by source, d.id, d.name, d.websiteurl order by source;");
|
|
418 |
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource_piwik dpo, datasource d where rds.source=dpo.piwik_id and dpo.openaire_id=d.id and rds.date>=? and rds.date<=? group by source, d.id, d.name, d.websiteurl order by source;");
|
|
419 |
//st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource d where rds.source=d.piwik_id and rds.date>=? and rds.date<=? group by source, d.id, d.name, d.websiteurl order by source;");
|
528 |
420 |
st.setDate(1, new java.sql.Date(beginDate.getTime()));
|
529 |
421 |
st.setDate(2, new java.sql.Date(endDate.getTime()));
|
530 |
422 |
}
|
531 |
423 |
else{
|
532 |
|
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, \"DatasourcesPiwikOAIDs\" dpo, datasource d, result_oids roid, result_classifications rc where roid.orid=rds.id and roid.id=rc.id and rds.source=dpo.\"PiwikID\" and dpo.\"OpenAIRE_ID\"=d.id and rds.date>=? and rds.date<=? and rc.type=? group by source, d.id, d.name, d.websiteurl order by source;");
|
|
424 |
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datsource_piwik dpo, datasource d, result_oids roid, result_classifications rc where roid.orid=rds.id and roid.id=rc.id and rds.source=dpo.piwik_id and dpo.openaire_id=d.id and rds.date>=? and rds.date<=? and rc.type=? group by source, d.id, d.name, d.websiteurl order by source;");
|
|
425 |
//st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource d, result_oids roid, result_classifications rc where roid.orid=rds.id and roid.id=rc.id and rds.source=d.piwik_id and rds.date>=? and rds.date<=? and rc.type=? group by source, d.id, d.name, d.websiteurl order by source;");
|
533 |
426 |
st.setDate(1, new java.sql.Date(beginDate.getTime()));
|
534 |
427 |
st.setDate(2, new java.sql.Date(endDate.getTime()));
|
535 |
428 |
st.setString(3, itemDataType);
|
536 |
429 |
}
|
537 |
430 |
} else {
|
538 |
431 |
if(itemDataType.equals("")){
|
539 |
|
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, \"DatasourcesPiwikOAIDs\" dpo, datasource d where rds.source=dpo.\"PiwikID\" and dpo.\"OpenAIRE_ID\"=d.id and rds.date>=? and rds.date<=? and rds.source=? group by rds.source, d.id, d.name, d.websiteurl;");
|
|
432 |
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource_piwik dpo, datasource d where rds.source=dpo.piwik_id and dpo.openaire_id=d.id and rds.date>=? and rds.date<=? and rds.source=? group by rds.source, d.id, d.name, d.websiteurl;");
|
|
433 |
//st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource d where rds.source=d.piwik_id and rds.date>=? and rds.date<=? and rds.source=? group by rds.source, d.id, d.name, d.websiteurl;");
|
540 |
434 |
st.setDate(1, new java.sql.Date(beginDate.getTime()));
|
541 |
435 |
st.setDate(2, new java.sql.Date(endDate.getTime()));
|
542 |
436 |
st.setInt(3, Integer.parseInt(repositoryIdentifier));
|
543 |
437 |
}
|
544 |
438 |
else{
|
545 |
|
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, \"DatasourcesPiwikOAIDs\" dpo, datasource d, result_oids roid, result_classifications rc where roid.orid=rds.id and roid.id=rc.id and rds.source=dpo.\"PiwikID\" and dpo.\"OpenAIRE_ID\"=d.id and rds.date>=? and rds.date<=? and rc.type=? and rds.source=? group by source, d.id, d.name, d.websiteurl;");
|
|
439 |
st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource_piwik dpo, datasource d, result_oids roid, result_classifications rc where roid.orid=rds.id and roid.id=rc.id and rds.source=dpo.piwik_id and dpo.openaire_id=d.id and rds.date>=? and rds.date<=? and rc.type=? and rds.source=? group by source, d.id, d.name, d.websiteurl;");
|
|
440 |
//st = connection.prepareStatement("select source, d.id, d.name, d.websiteurl, sum(number_of_downloads) from repo_download_stats rds, datasource d, result_oids roid, result_classifications rc where roid.orid=rds.id and roid.id=rc.id and rds.source=d.piwik_id and rds.date>=? and rds.date<=? and rc.type=? and rds.source=? group by source, d.id, d.name, d.websiteurl;");
|
546 |
441 |
st.setDate(1, new java.sql.Date(beginDate.getTime()));
|
547 |
442 |
st.setDate(2, new java.sql.Date(endDate.getTime()));
|
548 |
443 |
st.setString(3, itemDataType);
|
... | ... | |
573 |
468 |
|
574 |
469 |
if(repositoryIdentifier.equals("")){
|
575 |
470 |
if(itemDataType.equals("")){
|
576 |
|
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.\"PiwikID\" AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM \"DatasourcesPiwikOAIDs\" dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.\"OpenAIRE_ID\"=d.id order by d.id, new_date) dd LEFT JOIN (SELECT source, month, SUM(sum) as tsum FROM repo_download_stats_monthly where month>=? and month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
471 |
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.piwik_id AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource_piwik dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.openaire_id=d.id order by d.id, new_date) dd LEFT JOIN (SELECT source, month, SUM(sum) as tsum FROM repo_download_stats_monthly_sushi where month>=? and month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
472 |
//st = connection.prepareStatement("select dd.piwik_id, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, d.piwik_id, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource d, generate_series(0, ?, 1) AS offs where d.piwik_id is not null order by d.id, new_date) dd LEFT JOIN (SELECT source, month, SUM(sum) as tsum FROM repo_download_stats_monthly_sushi where month>=? and month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwik_id order by dd.piwik_id, dd.new_date;");
|
577 |
473 |
st.setString(1, report_dateFormat.format(beginDate));
|
578 |
474 |
st.setInt(2, diffMonth);
|
579 |
475 |
st.setDate(3, new java.sql.Date(beginDate.getTime()));
|
580 |
476 |
st.setDate(4, new java.sql.Date(endDate.getTime()));
|
581 |
477 |
}
|
582 |
478 |
else{
|
583 |
|
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.\"PiwikID\" AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM \"DatasourcesPiwikOAIDs\" dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.\"OpenAIRE_ID\"=d.id order by d.id, new_date) dd LEFT JOIN (SELECT rds.source, rds.month, SUM(rds.sum) as tsum FROM repo_download_stats_monthly rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? and rds.month>=? and rds.month<=? group by rds.source, rds.month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
479 |
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.piwik_id AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource_piwik dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.openaire_id=d.id order by d.id, new_date) dd LEFT JOIN (SELECT rds.source, rds.month, SUM(rds.sum) as tsum FROM repo_download_stats_monthly_sushi rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? and rds.month>=? and rds.month<=? group by rds.source, rds.month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
480 |
//st = connection.prepareStatement("select dd.piwik_id, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, d.piwik_id, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource d, generate_series(0, ?, 1) AS offs where d.piwik_id is not null order by d.id, new_date) dd LEFT JOIN (SELECT rds.source, rds.month, SUM(rds.sum) as tsum FROM repo_download_stats_monthly_sushi rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? and rds.month>=? and rds.month<=? group by rds.source, rds.month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwik_id order by dd.piwik_id, dd.new_date;");
|
584 |
481 |
st.setString(1, report_dateFormat.format(beginDate));
|
585 |
482 |
st.setInt(2, diffMonth);
|
586 |
483 |
st.setString(3, itemDataType);
|
... | ... | |
589 |
486 |
}
|
590 |
487 |
} else {
|
591 |
488 |
if(itemDataType.equals("")){
|
592 |
|
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.\"PiwikID\" AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM \"DatasourcesPiwikOAIDs\" dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.\"OpenAIRE_ID\"=d.id and dpo.\"PiwikID\"=? order by d.id, new_date) dd LEFT JOIN (SELECT source, month, SUM(sum) as tsum FROM repo_download_stats_monthly where source=? and month>=? and month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
489 |
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.piwik_id AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource_piwik dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.openaire_id=d.id and dpo.piwik_id=? order by d.id, new_date) dd LEFT JOIN (SELECT source, month, SUM(sum) as tsum FROM repo_download_stats_monthly_sushi where source=? and month>=? and month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
490 |
//st = connection.prepareStatement("select dd.piwik_id, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, d.piwik_id, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource d, generate_series(0, ?, 1) AS offs where d.piwik_id=? order by d.id, new_date) dd LEFT JOIN (SELECT source, month, SUM(sum) as tsum FROM repo_download_stats_monthly_sushi where source=? and month>=? and month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwik_id order by dd.piwik_id, dd.new_date;");
|
593 |
491 |
st.setString(1, report_dateFormat.format(beginDate));
|
594 |
492 |
st.setInt(2, diffMonth);
|
595 |
493 |
st.setInt(3, Integer.parseInt(repositoryIdentifier));
|
... | ... | |
598 |
496 |
st.setDate(6, new java.sql.Date(endDate.getTime()));
|
599 |
497 |
}
|
600 |
498 |
else{
|
601 |
|
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.\"PiwikID\" AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM \"DatasourcesPiwikOAIDs\" dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.\"OpenAIRE_ID\"=d.id and dpo.\"PiwikID\"=? order by d.id, new_date) dd LEFT JOIN (SELECT rds.source, rds.month, SUM(rds.sum) as tsum FROM repo_download_stats_monthly rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? and rds.source=? and rds.month>=? and rds.month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
499 |
st = connection.prepareStatement("select dd.piwikid, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, dpo.piwik_id AS piwikid, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource_piwik dpo, datasource d, generate_series(0, ?, 1) AS offs where dpo.openaire_id=d.id and dpo.piwik_id=? order by d.id, new_date) dd LEFT JOIN (SELECT rds.source, rds.month, SUM(rds.sum) as tsum FROM repo_download_stats_monthly_sushi rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? and rds.source=? and rds.month>=? and rds.month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwikid order by dd.piwikid, dd.new_date;");
|
|
500 |
//st = connection.prepareStatement("select dd.piwik_id, dd.id, dd.name, dd.websiteurl, dd.new_date, case when rdm.tsum is null then 0 else rdm.tsum end FROM (select d.id, d.name, d.piwik_id, d.websiteurl, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date FROM datasource d, generate_series(0, ?, 1) AS offs where dpo.piwik_id=? order by d.id, new_date) dd LEFT JOIN (SELECT rds.source, rds.month, SUM(rds.sum) as tsum FROM repo_download_stats_monthly_sushi rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? and rds.source=? and rds.month>=? and rds.month<=? group by source, month) rdm ON dd.new_date=rdm.month and rdm.source=dd.piwik_id order by dd.piwik_id, dd.new_date;");
|
602 |
501 |
st.setString(1, report_dateFormat.format(beginDate));
|
603 |
502 |
st.setInt(2, diffMonth);
|
604 |
503 |
st.setInt(3, Integer.parseInt(repositoryIdentifier));
|
... | ... | |
653 |
552 |
if(granularity.toLowerCase().equals("totals")){
|
654 |
553 |
if(itemDataType.equals("")) {
|
655 |
554 |
st = connection.prepareStatement("select rds.id, r.title, r.publisher, rc.type, r.source, r.id, sum(rds.number_of_downloads) from repo_download_stats rds, result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=rds.id and rds.source=? and rds.date>=? and rds.date<=? group by rds.id, r.title, r.publisher, rc.type, r.source, r.id;");
|
|
555 |
//st = connection.prepareStatement("select rds.id, r.title, r.publisher, rc.type, r.source, d.name r.id, sum(rds.number_of_downloads) from repo_download_stats rds, result r, result_oids roid, result_classifications rc, result_datasources rd, datasource d where rd.id=r.id and rd.datasource=d.id and r.id=roid.id and r.id=rc.id and roid.orid=rds.id and rds.source=? and rds.date>=? and rds.date<=? group by rds.id, r.title, r.publisher, rc.type, r.source, d.name, r.id;");
|
656 |
556 |
st.setInt(1, Integer.parseInt(repositoryIdentifier));
|
657 |
557 |
st.setDate(2, new java.sql.Date(beginDate.getTime()));
|
658 |
558 |
st.setDate(3, new java.sql.Date(endDate.getTime()));
|
659 |
559 |
}
|
660 |
560 |
else{
|
661 |
561 |
st = connection.prepareStatement("select rds.id, r.title, r.publisher, rc.type, r.source, r.id, sum(rds.number_of_downloads) from repo_download_stats rds, result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=rds.id and rds.source=? and rds.date>=? and rds.date<=? and rc.type=? group by rds.id, r.title, r.publisher, rc.type, r.source, r.id;");
|
|
562 |
//st = connection.prepareStatement("select rds.id, r.title, r.publisher, rc.type, r.source, d.name, r.id, sum(rds.number_of_downloads) from repo_download_stats rds, result r, result_oids roid, result_classifications rc, result_datasources rd, datasource d where rd.id=r.id and rd.datasource=d.id and r.id=roid.id and r.id=rc.id and roid.orid=rds.id and rds.source=? and rds.date>=? and rds.date<=? and rc.type=? group by rds.id, r.title, r.publisher, rc.type, r.source, d.name, r.id;");
|
662 |
563 |
st.setInt(1, Integer.parseInt(repositoryIdentifier));
|
663 |
564 |
st.setDate(2, new java.sql.Date(beginDate.getTime()));
|
664 |
565 |
st.setDate(3, new java.sql.Date(endDate.getTime()));
|
... | ... | |
668 |
569 |
|
669 |
570 |
while (rs.next()) {
|
670 |
571 |
ReportItem reportItem = new ReportItem(rs.getString(3), "", rs.getString(4), rs.getString(2));
|
|
572 |
//ReportItem reportItem = new ReportItem(rs.getString(3), rs.getString(6), rs.getString(4), rs.getString(2));
|
671 |
573 |
reportItem.addIdentifier(new ItemIdentifier("URL",rs.getString(5)));
|
672 |
574 |
reportItem.addIdentifier(new ItemIdentifier("OAI",rs.getString(1)));
|
673 |
575 |
reportItem.addIdentifier(new ItemIdentifier("OPENAIRE",rs.getString(6)));
|
|
576 |
//reportItem.addIdentifier(new ItemIdentifier("OPENAIRE",rs.getString(7)));
|
674 |
577 |
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), rs.getString(7)));
|
|
578 |
//reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(beginDate), report_dateFormat.format(endDate), rs.getString(8)));
|
675 |
579 |
reportItems.add(reportItem);
|
676 |
580 |
}
|
677 |
581 |
rs.close();
|
... | ... | |
685 |
589 |
int diffMonth = diffYear * 12 + endCalendar.get(Calendar.MONTH) - startCalendar.get(Calendar.MONTH);
|
686 |
590 |
|
687 |
591 |
if(itemDataType.equals("")){
|
688 |
|
st = connection.prepareStatement("select d.orid, d.title, d.publisher, d.rctype, d.rsource, d.rid, d.new_date, case when rdm.sum is null then 0 else rdm.sum end from (select distinct roid.orid, r.title, r.publisher, rc.type as rctype, r.source as rsource, r.id as rid, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date from generate_series(0, ?, 1) AS offs, repo_download_stats_monthly rdsm, result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=rdsm.id and rdsm.source=? and rdsm.month>=? and rdsm.month<=?) d LEFT JOIN (select id, month, sum from repo_download_stats_monthly where source=?) rdm ON d.new_date=rdm.month and d.orid=rdm.id order by d.orid, d.new_date;");
|
|
592 |
st = connection.prepareStatement("select d.orid, d.title, d.publisher, d.rctype, d.rsource, d.rid, d.new_date, case when rdm.sum is null then 0 else rdm.sum end from (select distinct roid.orid, r.title, r.publisher, rc.type as rctype, r.source as rsource, r.id as rid, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date from generate_series(0, ?, 1) AS offs, repo_download_stats_monthly_sushi rdsm, result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=rdsm.id and rdsm.source=? and rdsm.month>=? and rdsm.month<=?) d LEFT JOIN (select id, month, sum from repo_download_stats_monthly_sushi where source=?) rdm ON d.new_date=rdm.month and d.orid=rdm.id order by d.orid, d.new_date;");
|
|
593 |
//st = connection.prepareStatement("select d.orid, d.title, d.publisher, d.rctype, d.rsource, d.name, d.rid, d.new_date, case when rdm.sum is null then 0 else rdm.sum end from (select distinct roid.orid, r.title, r.publisher, rc.type as rctype, r.source as rsource, d.name, r.id as rid, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date from generate_series(0, ?, 1) AS offs, result r, result_oids roid, result_classifications rc, result_datasources rd, datasource ds where rd.id=r.id and rd.datasource=ds.id and r.id=roid.id and r.id=rc.id ds.piwik_id=?) d LEFT JOIN (select id, month, sum from repo_download_stats_monthly_sushi where source=?) rdm ON d.new_date=rdm.month and d.orid=rdm.id order by d.orid, d.new_date;");
|
689 |
594 |
st.setString(1, report_dateFormat.format(beginDate));
|
690 |
595 |
st.setInt(2, diffMonth);
|
691 |
596 |
st.setInt(3, Integer.parseInt(repositoryIdentifier));
|
... | ... | |
693 |
598 |
st.setDate(5, new java.sql.Date(endDate.getTime()));
|
694 |
599 |
st.setInt(6, Integer.parseInt(repositoryIdentifier));
|
695 |
600 |
} else{
|
696 |
|
st = connection.prepareStatement("select d.orid, d.title, d.publisher, d.rctype, d.rsource, d.rid, d.new_date, case when rdm.sum is null then 0 else rdm.sum end from (select distinct roid.orid, r.title, r.publisher, rc.type as rctype, r.source as rsource, r.id as rid, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date from generate_series(0, ?, 1) AS offs, repo_download_stats_monthly rdsm, result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=rdsm.id and rdsm.source=? and rc.type=? and rdsm.month>=? and rdsm.month<=?) d LEFT JOIN (select id, month, sum from repo_download_stats_monthly where source=?) rdm ON d.new_date=rdm.month and d.orid=rdm.id order by d.orid, d.new_date;");
|
|
601 |
st = connection.prepareStatement("select d.orid, d.title, d.publisher, d.rctype, d.rsource, d.rid, d.new_date, case when rdm.sum is null then 0 else rdm.sum end from (select distinct roid.orid, r.title, r.publisher, rc.type as rctype, r.source as rsource, r.id as rid, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date from generate_series(0, ?, 1) AS offs, repo_download_stats_monthly_sushi rdsm, result r, result_oids roid, result_classifications rc where r.id=roid.id and r.id=rc.id and roid.orid=rdsm.id and rdsm.source=? and rc.type=? and rdsm.month>=? and rdsm.month<=?) d LEFT JOIN (select id, month, sum from repo_download_stats_monthly_sushi where source=?) rdm ON d.new_date=rdm.month and d.orid=rdm.id order by d.orid, d.new_date;");
|
|
602 |
//st = connection.prepareStatement("select d.orid, d.title, d.publisher, d.rctype, d.rsource, d.name, d.rid, d.new_date, case when rdm.sum is null then 0 else rdm.sum end from (select distinct roid.orid, r.title, r.publisher, rc.type as rctype, r.source as rsource, d.name, r.id as rid, to_char(date_trunc('month', (?::date + interval '1 month'*offs)), 'YYYY-MM-DD') AS new_date from generate_series(0, ?, 1) AS offs, result r, result_oids roid, result_classifications rc, result_datasources rd, datasource ds where rd.id=r.id and rd.datasource=ds.id and r.id=roid.id and r.id=rc.id ds.piwik_id=? and rc.type=?) d LEFT JOIN (select id, month, sum from repo_download_stats_monthly_sushi where source=?) rdm ON d.new_date=rdm.month and d.orid=rdm.id order by d.orid, d.new_date;");
|
697 |
603 |
st.setString(1, report_dateFormat.format(beginDate));
|
698 |
604 |
st.setInt(2, diffMonth);
|
699 |
605 |
st.setInt(3, Integer.parseInt(repositoryIdentifier));
|
... | ... | |
706 |
612 |
|
707 |
613 |
while (rs.next()) {
|
708 |
614 |
ReportItem reportItem = new ReportItem(rs.getString(3), "", rs.getString(4), rs.getString(2));
|
|
615 |
//ReportItem reportItem = new ReportItem(rs.getString(3), rs.getString(6), rs.getString(4), rs.getString(2));
|
709 |
616 |
reportItem.addIdentifier(new ItemIdentifier("URL",rs.getString(5)));
|
710 |
617 |
reportItem.addIdentifier(new ItemIdentifier("OAI",rs.getString(1)));
|
711 |
618 |
reportItem.addIdentifier(new ItemIdentifier("OPENAIRE",rs.getString(6)));
|
|
619 |
//reportItem.addIdentifier(new ItemIdentifier("OPENAIRE",rs.getString(7)));
|
712 |
620 |
for(int i = 0; i <= diffMonth; i++) {
|
713 |
621 |
Calendar temp_c = Calendar.getInstance();
|
714 |
622 |
temp_c.setTime(rs.getDate(7));
|
715 |
623 |
temp_c.set(Calendar.DAY_OF_MONTH, temp_c.getActualMaximum(Calendar.DAY_OF_MONTH));
|
716 |
624 |
Date temp_endDate = temp_c.getTime();
|
717 |
625 |
reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(rs.getDate(7)), report_dateFormat.format(temp_endDate), rs.getString(8)));
|
|
626 |
//reportItem.addPerformance(new ItemPerformance(report_dateFormat.format(rs.getDate(8)), report_dateFormat.format(temp_endDate), rs.getString(9)));
|
718 |
627 |
if(i != diffMonth) {
|
719 |
628 |
rs.next();
|
720 |
629 |
}
|
... | ... | |
730 |
639 |
}
|
731 |
640 |
return 0;
|
732 |
641 |
}
|
733 |
|
|
734 |
|
protected int executeRepoOLD(List<ReportItem> reportItems, String repositoryIdentifier, String itemDataType, Date beginDate, Date endDate, String granularity){
|
735 |
|
|
736 |
|
try {
|
737 |
|
Connection connection = dataSource.getConnection();
|
738 |
|
PreparedStatement st;
|
739 |
|
if(itemDataType.equals("")) {
|
740 |
|
st = connection.prepareStatement("select distinct id from repo_download_stats where source=? order by id");
|
741 |
|
st.setInt(1, Integer.parseInt(repositoryIdentifier));
|
742 |
|
}
|
743 |
|
else{
|
744 |
|
st = connection.prepareStatement("select distinct rds.id from repo_download_stats rds, result_oids roid, result_classifications rc where rds.id=roid.orid and roid.id=rc.id and rc.type=? order by rds.id");
|
745 |
|
st.setInt(1, Integer.parseInt(repositoryIdentifier));
|
746 |
|
st.setString(2, itemDataType);
|
747 |
|
}
|
748 |
|
|
749 |
|
ResultSet rs = st.executeQuery();
|
750 |
|
|
751 |
|
while (rs.next()) {
|
752 |
|
executeDoi(reportItems, rs.getString(1), repositoryIdentifier, itemDataType, beginDate, endDate, granularity);
|
753 |
|
}
|
754 |
|
rs.close();
|
755 |
|
st.close();
|
756 |
|
connection.close();
|
757 |
|
|
758 |
|
} catch (Exception e){
|
759 |
|
log.error("Cannot execute repo : " + e);
|
760 |
|
}
|
761 |
|
|
762 |
|
return 0;
|
763 |
|
}
|
764 |
642 |
}
|
rev