IR Report no Identifier selection

This commit is contained in:
Dimitris 2021-02-25 10:10:47 +02:00
parent 5a2d8fe1eb
commit 9ba8cc6bbd
4 changed files with 663 additions and 372 deletions

View File

@ -1,6 +1,7 @@
package eu.dnetlib.usagestats.controllers;
import eu.dnetlib.usagestats.services.SushiLiteService;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
@ -83,7 +84,7 @@ class SushiLiteController {
@RequestParam(value = "RequestorID", defaultValue = "anonymous") String requestorId,
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
@RequestParam(value = "MetricType", defaultValue = "") String metricType,
@RequestParam(value = "MetricType", defaultValue = "") List<String> metricType,
@RequestParam(value = "DataType", defaultValue = "") String dataType,
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
log.info("COUNTER TR Report request for repository " + repositoryIdentifier +" and for item "+ itemIdentifier);

View File

@ -5,7 +5,9 @@ import eu.dnetlib.usagestats.sushilite.domain.COUNTER_Platform_Report;
import eu.dnetlib.usagestats.sushilite.domain.COUNTER_Title_Report;
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
import eu.dnetlib.usagestats.sushilite.domain.ReportStatus;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public interface SushiLiteService {
@ -29,7 +31,7 @@ public interface SushiLiteService {
COUNTER_Platform_Report buildReportPR_P1(String customerID, String repositoryIdentifier, String beginDate,String endDate);
String displayReportPR_P1(String customerID, String repositoryIdentifier, String beginDate, String endDate);
COUNTER_Item_Report buildReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,String endDate, String metricType, String dataType,String granularity);
String displayReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,String endDate, String metricType, String dataType,String granularity);
COUNTER_Item_Report buildReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,String endDate, List<String> metricType, String dataType,String granularity) throws Exception;
String displayReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,String endDate, List<String> metricType, String dataType,String granularity);
}

View File

@ -16,6 +16,7 @@ import eu.dnetlib.usagestats.sushilite.domain.ReportResponse;
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
import eu.dnetlib.usagestats.sushilite.domain.ReportStatus;
import eu.dnetlib.usagestats.sushilite.domain.ReportSupported;
import java.sql.SQLException;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
@ -462,7 +463,7 @@ public class SushiLiteServiceImpl implements SushiLiteService {
@Override
public COUNTER_Item_Report buildReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,
String endDate, String metricType, String dataType, String granularity) {
String endDate, List<String> metricType, String dataType, String granularity) throws Exception {
ZonedDateTime dateTime = ZonedDateTime.now(); // Gets the current date and time, with your default time-zone
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
@ -570,7 +571,7 @@ public class SushiLiteServiceImpl implements SushiLiteService {
// reportExceptions.add(new SUSHI_Error_Model("3030", "Error", "usagecounts.openaire.eu", "No Usage Available for Requested Dates", "Service did not find any data"));
// }
// } else if (!repoid.equals("")) {
usageStatsRepository.executeBatchItemsIR(reportItems, repoid, itemIdentifier, beginDateParsed, endDateParsed, metricType, "Article", granularity);
usageStatsRepository.executeBatchItemsIR(reportItems, repoid, itemIdentifier, beginDateParsed, endDateParsed, metricType, dataType, granularity);
if (reportItems.isEmpty()) {
reportExceptions.add(new SUSHI_Error_Model("3030", "Error", "usagecounts.openaire.eu", "No Usage Available for Requested Dates", "Service did not find any data"));
@ -653,6 +654,8 @@ public class SushiLiteServiceImpl implements SushiLiteService {
return reportResponse;
}
// @Override
// public COUNTER_Title_Report buildReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,
// String endDate, String metricType, String dataType, String granularity) {
@ -761,12 +764,12 @@ public class SushiLiteServiceImpl implements SushiLiteService {
@Override
public String displayReportIR(String customerID, String repositoryIdentifier, String itemIdentifier, String beginDate,
String endDate, String metricType, String dataType, String granularity) {
String endDate, List<String> metricType, String dataType, String granularity) {
ObjectMapper objectMapper = new ObjectMapper();
log.info((beginDate + " " + endDate));
try {
return "<pre>" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(buildReportIR(customerID, repositoryIdentifier, itemIdentifier, beginDate, endDate, metricType, dataType, granularity)) + "</pre>";
} catch (JsonProcessingException ex) {
} catch (Exception ex) {
java.util.logging.Logger.getLogger(SushiLiteServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return null;