Make year dynamic for stats tool publicationsOA and publicationsPR

This commit is contained in:
Konstantinos Triantafyllou 2024-10-31 10:26:10 +02:00
parent e808dfa247
commit 91c1b88b0d
3 changed files with 19 additions and 7 deletions

View File

@ -1,10 +1,21 @@
package eu.dnetlib.irishmonitorservice.configuration.properties;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
public class Indicators {
private static final Calendar calendar = Calendar.getInstance();
String publications;
String publicationsPR;
String publicationsPROA;
private String getYear() {
return (calendar.get(Calendar.YEAR) - 1) + "";
}
public String getPublications() {
return publications;
}
@ -14,7 +25,7 @@ public class Indicators {
}
public String getPublicationsPR() {
return publicationsPR;
return URLEncoder.encode(URLDecoder.decode(this.publicationsPR, StandardCharsets.UTF_8).replace("((__year__))", getYear()), StandardCharsets.UTF_8);
}
public void setPublicationsPR(String publicationsPR) {
@ -22,7 +33,7 @@ public class Indicators {
}
public String getPublicationsPROA() {
return publicationsPROA;
return URLEncoder.encode(URLDecoder.decode(this.publicationsPROA, StandardCharsets.UTF_8).replace("((__year__))", getYear()), StandardCharsets.UTF_8);
}
public void setPublicationsPROA(String publicationsPROA) {

View File

@ -20,6 +20,7 @@ import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
public class StatsToolService {
@ -67,7 +68,7 @@ public class StatsToolService {
try {
ResponseEntity<Data> response = restTemplate.getForEntity(uri, Data.class);
if(response.getStatusCode() == HttpStatus.OK) {
return response.getBody().getData();
return Objects.requireNonNull(response.getBody()).getData();
}
return new ArrayList<>();
} catch (RestClientException e) {

View File

@ -8,8 +8,8 @@ api.version = ${project.version}
stats-tool.rfo.publications=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.project.funder.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.project.funder.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D
stats-tool.rpo.publications=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.organization.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.organization.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D
stats-tool.rfo.publicationsPR=%7B"orderBy"%3A"yAxis"%2C"verbose"%3Afalse%2C"series"%3A%5B%7B"query"%3A%7B"parameters"%3A%5B%5D%2C"select"%3A%5B%7B"field"%3A"publication"%2C"aggregate"%3A"count"%7D%2C%7B"field"%3A"publication.project.funder.id"%2C"aggregate"%3Anull%7D%5D%2C"filters"%3A%5B%7B"groupFilters"%3A%5B%7B"field"%3A"publication.project.funder.country"%2C"type"%3A"%3D"%2C"values"%3A%5B"IE"%5D%7D%2C%7B"field"%3A"publication.result_refereed.refereed"%2C"type"%3A"%3D"%2C"values"%3A%5B"peerReviewed"%5D%7D%5D%2C"op"%3A"AND"%7D%5D%2C"entity"%3A"publication"%2C"profile"%3A"ie_monitor"%2C"useCache"%3Afalse%7D%7D%5D%7D
stats-tool.rpo.publicationsPR=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.organization.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.organization.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%2C%7B%22field%22%3A%22publication.result_refereed.refereed%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22peerReviewed%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D
stats-tool.rfo.publicationsPR=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.project.funder.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.project.funder.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%2C%7B%22field%22%3A%22publication.result_refereed.refereed%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22peerReviewed%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%20%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3E%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3C%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D
stats-tool.rpo.publicationsPR=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.organization.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.organization.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%2C%7B%22field%22%3A%22publication.result_refereed.refereed%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22peerReviewed%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%20%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3E%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3C%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D
stats-tool.rfo.publicationsPROA=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.project.funder.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.project.funder.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%2C%7B%22field%22%3A%22publication.result_refereed.refereed%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22peerReviewed%22%5D%7D%2C%7B%22field%22%3A%22publication.indi_result_oa_with_license.oa_with_license%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%221%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D%0A
stats-tool.rpo.publicationsPROA=%7B"orderBy"%3A"yAxis"%2C"verbose"%3Afalse%2C"series"%3A%5B%7B"query"%3A%7B"parameters"%3A%5B%5D%2C"select"%3A%5B%7B"field"%3A"publication"%2C"aggregate"%3A"count"%7D%2C%7B"field"%3A"publication.organization.id"%2C"aggregate"%3Anull%7D%5D%2C"filters"%3A%5B%7B"groupFilters"%3A%5B%7B"field"%3A"publication.organization.country"%2C"type"%3A"%3D"%2C"values"%3A%5B"IE"%5D%7D%2C%7B"field"%3A"publication.result_refereed.refereed"%2C"type"%3A"%3D"%2C"values"%3A%5B"peerReviewed"%5D%7D%2C%7B"field"%3A"publication.indi_result_oa_with_license.oa_with_license"%2C"type"%3A"%3D"%2C"values"%3A%5B"1"%5D%7D%5D%2C"op"%3A"AND"%7D%5D%2C"entity"%3A"publication"%2C"profile"%3A"ie_monitor"%2C"useCache"%3Afalse%7D%7D%5D%7D
stats-tool.rfo.publicationsPROA=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.project.funder.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.project.funder.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%2C%7B%22field%22%3A%22publication.result_refereed.refereed%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22peerReviewed%22%5D%7D%2C%7B%22field%22%3A%22publication.indi_result_oa_with_license.oa_with_license%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%221%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%20%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3E%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3C%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D
stats-tool.rpo.publicationsPROA=%7B%22orderBy%22%3A%22yAxis%22%2C%22verbose%22%3Afalse%2C%22series%22%3A%5B%7B%22query%22%3A%7B%22parameters%22%3A%5B%5D%2C%22select%22%3A%5B%7B%22field%22%3A%22publication%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22publication.organization.id%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.organization.country%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22IE%22%5D%7D%2C%7B%22field%22%3A%22publication.result_refereed.refereed%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22peerReviewed%22%5D%7D%2C%7B%22field%22%3A%22publication.indi_result_oa_with_license.oa_with_license%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%221%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%20%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3E%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22publication.year%22%2C%22type%22%3A%22%3C%3D%22%2C%22values%22%3A%5B%22%28%28__year__%29%29%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22publication%22%2C%22profile%22%3A%22ie_monitor%22%2C%22useCache%22%3Afalse%7D%7D%5D%7D