Merge from master
This commit is contained in:
commit
fa38a520a2
2
LICENSE
2
LICENSE
|
@ -58,7 +58,7 @@ APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright 2024 National Open Access Monitor, Ireland
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|
112
README.md
112
README.md
|
@ -1,2 +1,112 @@
|
||||||
# irish-monitor-service
|
# Irish Monitor Service
|
||||||
|
|
||||||
|
Irish Monitor Service is a service that integrates both OpenAIRE Login API and
|
||||||
|
OpenAIRE Monitor API and provide all functionalities for National Open Access Monitor, Ireland.
|
||||||
|
|
||||||
|
## Maven
|
||||||
|
|
||||||
|
Java Version: 1.8, Sprint boot Version: 1.5.8.RELEASE
|
||||||
|
|
||||||
|
This service has dependencies downloaded from [D4Science Nexus repository](https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-releases),
|
||||||
|
so there is a definition of this repository inside [pom.xml](pom.xml).
|
||||||
|
|
||||||
|
### Install
|
||||||
|
|
||||||
|
mvn clean install -DskipTests -Dmaven.javadoc.skip=true;
|
||||||
|
|
||||||
|
#### Standalone (Recommended)
|
||||||
|
|
||||||
|
1. Create a new system service and enable in order to start up at boot.
|
||||||
|
|
||||||
|
cd /etc/systemd/system
|
||||||
|
sudo vim service-name.service
|
||||||
|
|
||||||
|
2. Add the following content by replacing () accordingly.
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=service-name
|
||||||
|
After=syslog.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
ExecStart=(/home/user/spring-boot/)irish-monitor-service.war (--spring.profiles.active=swagger) --server.port=(port) (--server.context-path=/irish-monitor-service) --spring.config.location=file:///(home/user/spring-boot/config/application.properties)
|
||||||
|
SuccessExitStatus=143
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
3. Configure the service.
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable service-name
|
||||||
|
|
||||||
|
4. Handle service.
|
||||||
|
|
||||||
|
sudo systemctl start service-name
|
||||||
|
sudo systemctl stop service-name
|
||||||
|
sudo systemctl restart service-name
|
||||||
|
sudo systemctl status service-name
|
||||||
|
|
||||||
|
#### Container (eg Tomcat)
|
||||||
|
|
||||||
|
1. Add the war in the _webapps_ folder.
|
||||||
|
2. Create application.properties file in _lib_ folder.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
In order to configure this service you have to set the following properties:
|
||||||
|
|
||||||
|
stats-tool.rfo=<StatsToolURL>?json=<JsonQuery>
|
||||||
|
stats-tool.rpo=<StatsToolURL>?json=<JsonQuery>
|
||||||
|
stats-tool.repository=<StatsToolURL>?json=<JsonQuery>
|
||||||
|
|
||||||
|
|
||||||
|
## Login core
|
||||||
|
|
||||||
|
This dependency provides the Authentication and Authorization functionality.
|
||||||
|
In order to configure it you have to set the following properties:
|
||||||
|
|
||||||
|
authentication.domain=<Domain>
|
||||||
|
authentication.oidc.home=<API_URL>/openid_connect_login
|
||||||
|
authentication.oidc.scope=openid,profile,email,eduperson_entitlement,orcid
|
||||||
|
authentication.oidc.id=<ProviderClientId>
|
||||||
|
authentication.oidc.secret=<ProviderClientSecret>
|
||||||
|
authentication.oidc.issuer=https://aai.openaire.eu/auth/realms/openaire
|
||||||
|
authentication.oidc.redirect=<API_URL>/redirect
|
||||||
|
authentication.session=irishSession
|
||||||
|
authentication.redirect=<DefaultRedirectURL>
|
||||||
|
authentication.redis.host=<RedisHost>
|
||||||
|
authentication.redis.port=<RedisPort>
|
||||||
|
authentication.redis.passwork=<RedisPassword>
|
||||||
|
authentication.authorities-mapper=irish.eduperson_entitlement // DO NOT CHANGE
|
||||||
|
authentication.keycloak=true
|
||||||
|
|
||||||
|
## Monitor Service
|
||||||
|
|
||||||
|
This dependency provides the main service functionality
|
||||||
|
in order to create/edit/delete monitor profiles and their content.
|
||||||
|
In order to configure it you have to set the following properties:
|
||||||
|
|
||||||
|
monitorservice.mongodb.host=<MongoHost>
|
||||||
|
monitorservice.mongodb.port=<MongoPort>
|
||||||
|
monitorservice.mongodb.database=<DatabaseName>
|
||||||
|
monitorservice.mongodb.username=<MongoUser>
|
||||||
|
monitorservice.mongodb.password=<MongoPassword>
|
||||||
|
|
||||||
|
## Admin Tools Library (integrated in Monitor Service)
|
||||||
|
|
||||||
|
This dependency provides utilities to store dynamic HTML content,
|
||||||
|
send Email and verify Google recaptcha. In order to configure it
|
||||||
|
you have to set the following properties:
|
||||||
|
|
||||||
|
admintoolslibrary.mail.from = <Email>
|
||||||
|
admintoolslibrary.mail.username = <Email>
|
||||||
|
admintoolslibrary.mail.password = <EmailPassword>
|
||||||
|
admintoolslibrary.mail.host = <EmailHost>
|
||||||
|
admintoolslibrary.mail.port = <EmailPort>
|
||||||
|
admintoolslibrary.mail.auth = true
|
||||||
|
admintoolslibrary.mail.sslProtocols = TLSv1.2
|
||||||
|
admintoolslibrary.mail.defaultEncoding=UTF-8
|
||||||
|
admintoolslibrary.mail.protocol=<EmailProtocol>
|
||||||
|
admintoolslibrary.mail.testConnection=false
|
||||||
|
admintoolslibrary.google.secret = <GoogleSecret>
|
||||||
|
|
21
pom.xml
21
pom.xml
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>irish-monitor-service</artifactId>
|
<artifactId>irish-monitor-service</artifactId>
|
||||||
<version>1.0.7-SNAPSHOT</version>
|
<version>1.0.7-SNAPSHOT</version>
|
||||||
|
@ -21,11 +22,10 @@
|
||||||
<maven.build.timestamp.format>E MMM dd HH:mm:ss z yyyy</maven.build.timestamp.format>
|
<maven.build.timestamp.format>E MMM dd HH:mm:ss z yyyy</maven.build.timestamp.format>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency> <!-- this dependency includes dependency to uoa-monitor-service-library -->
|
<dependency> <!-- this dependency includes dependency to uoa-monitor-service-library -->
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>uoa-monitor-service</artifactId>
|
<artifactId>uoa-monitor-service</artifactId>
|
||||||
<version>1.1.13</version>
|
<version>1.1.15</version>
|
||||||
<classifier>library</classifier>
|
<classifier>library</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -48,7 +48,20 @@
|
||||||
<version>${swagger-version}</version>
|
<version>${swagger-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>dnet45-releases</id>
|
||||||
|
<name>D-Net 45 Releases</name>
|
||||||
|
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-releases/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<layout>default</layout>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.dnetlib.irishmonitorservice.configuration.properties;
|
||||||
|
|
||||||
|
public class Indicators {
|
||||||
|
String publications;
|
||||||
|
String publicationsPR;
|
||||||
|
String publicationsPROA;
|
||||||
|
|
||||||
|
public String getPublications() {
|
||||||
|
return publications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublications(String publications) {
|
||||||
|
this.publications = publications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicationsPR() {
|
||||||
|
return publicationsPR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationsPR(String publicationsPR) {
|
||||||
|
this.publicationsPR = publicationsPR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicationsPROA() {
|
||||||
|
return publicationsPROA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationsPROA(String publicationsPROA) {
|
||||||
|
this.publicationsPROA = publicationsPROA;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,34 +4,43 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
@ConfigurationProperties("stats-tool")
|
@ConfigurationProperties("stats-tool")
|
||||||
public class StatsToolProperties {
|
public class StatsToolProperties {
|
||||||
private String rpo;
|
private String host;
|
||||||
private String rfo;
|
private Indicators rpo;
|
||||||
private String repository;
|
private Indicators rfo;
|
||||||
|
private Indicators repository;
|
||||||
|
|
||||||
public StatsToolProperties() {
|
public StatsToolProperties() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRpo() {
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Indicators getRpo() {
|
||||||
return rpo;
|
return rpo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRpo(String rpo) {
|
public void setRpo(Indicators rpo) {
|
||||||
this.rpo = rpo;
|
this.rpo = rpo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRfo() {
|
public Indicators getRfo() {
|
||||||
return rfo;
|
return rfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRfo(String rfo) {
|
public void setRfo(Indicators rfo) {
|
||||||
this.rfo = rfo;
|
this.rfo = rfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRepository() {
|
public Indicators getRepository() {
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRepository(String repository) {
|
public void setRepository(Indicators repository) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package eu.dnetlib.irishmonitorservice.controllers;
|
||||||
|
|
||||||
|
import eu.dnetlib.irishmonitorservice.entities.SortBy;
|
||||||
|
import eu.dnetlib.irishmonitorservice.entities.StakeholderExtended;
|
||||||
|
import eu.dnetlib.irishmonitorservice.services.StakeholderExtendedService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RequestMapping("extended")
|
||||||
|
public class StakeholderExtendedController {
|
||||||
|
private final StakeholderExtendedService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public StakeholderExtendedController(StakeholderExtendedService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||||
|
public List<StakeholderExtended> getStakeholders(@RequestParam("type") String type, @RequestParam(value = "sort", required = false) SortBy sort) throws UnsupportedEncodingException {
|
||||||
|
return this.service.sortBy(this.service.getVisibleStakeholdersExtended(type), sort);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{stakeholderId}", method = RequestMethod.GET)
|
||||||
|
public StakeholderExtended getStakeholder(@PathVariable String stakeholderId) throws UnsupportedEncodingException {
|
||||||
|
return this.service.getStakeholderExtended(stakeholderId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,48 +0,0 @@
|
||||||
package eu.dnetlib.irishmonitorservice.controllers;
|
|
||||||
|
|
||||||
import eu.dnetlib.irishmonitorservice.entities.StakeholderPublications;
|
|
||||||
import eu.dnetlib.irishmonitorservice.services.CacheService;
|
|
||||||
import eu.dnetlib.irishmonitorservice.services.StatsToolService;
|
|
||||||
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
|
||||||
import eu.dnetlib.uoamonitorservice.service.StakeholderService;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
@RequestMapping("publications")
|
|
||||||
public class StakeholderPublicationsController {
|
|
||||||
private final StakeholderService service;
|
|
||||||
private final CacheService cacheService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public StakeholderPublicationsController(StakeholderService service, CacheService cacheService) {
|
|
||||||
this.service = service;
|
|
||||||
this.cacheService = cacheService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/{type}", method = RequestMethod.GET)
|
|
||||||
public List<StakeholderPublications> getStakeholders(@PathVariable String type) throws UnsupportedEncodingException, InterruptedException {
|
|
||||||
List<Stakeholder> stakeholders = this.service.getStakeholdersByTypeAndRole(type, null, false);
|
|
||||||
List<StakeholderPublications> stakeholderPublications = new ArrayList<>();
|
|
||||||
List<List<String>> data = this.cacheService.getResponse(type);
|
|
||||||
List<Stakeholder> remain = new ArrayList<>(stakeholders);
|
|
||||||
if (data != null) {
|
|
||||||
data.forEach(entity -> {
|
|
||||||
String id = entity.get(1);
|
|
||||||
stakeholders.stream().filter(stakeholder -> stakeholder.getIndex_id().equals(id)).findFirst().ifPresent(stakeholder -> {
|
|
||||||
remain.remove(stakeholder);
|
|
||||||
stakeholderPublications.add(new StakeholderPublications(stakeholder, Integer.parseInt(entity.get(0))));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
remain.forEach(stakeholder -> stakeholderPublications.add(new StakeholderPublications(stakeholder, 0)));
|
|
||||||
return stakeholderPublications;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +1,16 @@
|
||||||
package eu.dnetlib.irishmonitorservice.entities;
|
package eu.dnetlib.irishmonitorservice.entities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Data {
|
public class Data {
|
||||||
List<List<List<String>>> data;
|
List<List<List<String>>> data;
|
||||||
|
|
||||||
public Data() {}
|
|
||||||
|
|
||||||
public List<List<String>> getData() {
|
public List<List<String>> getData() {
|
||||||
|
if(data.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
return data.get(0);
|
return data.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package eu.dnetlib.irishmonitorservice.entities;
|
||||||
|
|
||||||
|
public enum SortBy {
|
||||||
|
OPEN_ACCESS,
|
||||||
|
PUBLICATIONS
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.dnetlib.irishmonitorservice.entities;
|
||||||
|
|
||||||
|
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
||||||
|
|
||||||
|
public class StakeholderExtended extends Stakeholder {
|
||||||
|
private final Integer publications;
|
||||||
|
private final Float publicationPR;
|
||||||
|
private final Float publicationPROA;
|
||||||
|
|
||||||
|
public StakeholderExtended(Stakeholder stakeholder, String publications, String publicationPR, String publicationPROA) {
|
||||||
|
super(stakeholder);
|
||||||
|
this.publications = publications != null ? Integer.parseInt(publications) : null;
|
||||||
|
this.publicationPR = publicationPR != null ? Float.parseFloat(publicationPR) : null;
|
||||||
|
this.publicationPROA = publicationPROA != null ? Float.parseFloat(publicationPROA) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPublications() {
|
||||||
|
return publications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Number getOpenAccess() {
|
||||||
|
if( publicationPR != null && publicationPROA != null && publicationPR > 0) {
|
||||||
|
return (publicationPROA / publicationPR) * 100;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package eu.dnetlib.irishmonitorservice.entities;
|
|
||||||
|
|
||||||
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
|
||||||
|
|
||||||
public class StakeholderPublications extends Stakeholder {
|
|
||||||
private Number publications;
|
|
||||||
|
|
||||||
public StakeholderPublications(Stakeholder stakeholder, Number publications) {
|
|
||||||
super(stakeholder);
|
|
||||||
this.publications = publications;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Number getPublications() {
|
|
||||||
return publications;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublications(Number publications) {
|
|
||||||
this.publications = publications;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.dnetlib.irishmonitorservice.services;
|
package eu.dnetlib.irishmonitorservice.services;
|
||||||
|
|
||||||
|
import eu.dnetlib.irishmonitorservice.entities.Data;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -18,15 +19,16 @@ public class CacheService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private StatsToolService statsToolService;
|
private StatsToolService statsToolService;
|
||||||
|
|
||||||
public List<List<String>> getResponse(String type) throws UnsupportedEncodingException {
|
public List<List<List<String>>> getResponse(String type) throws UnsupportedEncodingException {
|
||||||
if (type.equals("funder")) {
|
switch (type) {
|
||||||
return this.statsToolService.getFunders();
|
case "funder":
|
||||||
} else if (type.equals("organization")) {
|
return this.statsToolService.getFunders();
|
||||||
return this.statsToolService.getOrganizations();
|
case "organization":
|
||||||
} else if (type.equals("datasource")) {
|
return this.statsToolService.getOrganizations();
|
||||||
return this.statsToolService.getDataSources();
|
case "datasource":
|
||||||
} else {
|
return this.statsToolService.getDataSources();
|
||||||
return null;
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package eu.dnetlib.irishmonitorservice.services;
|
||||||
|
|
||||||
|
import eu.dnetlib.irishmonitorservice.entities.SortBy;
|
||||||
|
import eu.dnetlib.irishmonitorservice.entities.StakeholderExtended;
|
||||||
|
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
||||||
|
import eu.dnetlib.uoamonitorservice.service.StakeholderService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class StakeholderExtendedService {
|
||||||
|
private final StakeholderService service;
|
||||||
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public StakeholderExtendedService(StakeholderService service, CacheService cacheService) {
|
||||||
|
this.service = service;
|
||||||
|
this.cacheService = cacheService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StakeholderExtended getStakeholderExtended(String stakeholderId) throws UnsupportedEncodingException {
|
||||||
|
Stakeholder stakeholder = this.service.findByPath(stakeholderId);
|
||||||
|
List<List<List<String>>> results = this.cacheService.getResponse(stakeholder.getType());
|
||||||
|
if(results != null) {
|
||||||
|
return new StakeholderExtended(stakeholder,
|
||||||
|
getNumber(results, 0, stakeholder.getIndex_id()),
|
||||||
|
getNumber(results, 1, stakeholder.getIndex_id()),
|
||||||
|
getNumber(results, 2, stakeholder.getIndex_id()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new StakeholderExtended(stakeholder, "0", "0", "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StakeholderExtended> getVisibleStakeholdersExtended(String type) throws UnsupportedEncodingException {
|
||||||
|
List<Stakeholder> stakeholders = this.service.getVisibleStakeholders(type, null);
|
||||||
|
List<List<List<String>>> results = this.cacheService.getResponse(type);
|
||||||
|
if(results != null) {
|
||||||
|
return stakeholders.stream().map(stakeholder ->
|
||||||
|
new StakeholderExtended(stakeholder,
|
||||||
|
getNumber(results, 0, stakeholder.getIndex_id()),
|
||||||
|
getNumber(results, 1, stakeholder.getIndex_id()),
|
||||||
|
getNumber(results, 2, stakeholder.getIndex_id()))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return stakeholders.stream().map(stakeholder -> new StakeholderExtended(stakeholder, "0", "0", "0")).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumber(List<List<List<String>>> results, int index, String id) {
|
||||||
|
if(results != null && index < results.size()) {
|
||||||
|
return results.get(index).stream().filter(list -> list.get(1).equals(id)).findFirst().orElse(Collections.singletonList("0")).get(0);
|
||||||
|
}
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StakeholderExtended> sortBy(List<StakeholderExtended> stakeholders, SortBy sort) {
|
||||||
|
stakeholders.sort(Comparator.comparingInt(StakeholderExtended::getPublications).reversed());
|
||||||
|
if(sort == SortBy.OPEN_ACCESS) {
|
||||||
|
stakeholders.sort(Comparator.comparingDouble((StakeholderExtended a) -> a.getOpenAccess().doubleValue()).reversed());
|
||||||
|
}
|
||||||
|
return stakeholders;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.dnetlib.irishmonitorservice.services;
|
package eu.dnetlib.irishmonitorservice.services;
|
||||||
|
|
||||||
|
import eu.dnetlib.irishmonitorservice.configuration.properties.Indicators;
|
||||||
import eu.dnetlib.irishmonitorservice.configuration.properties.StatsToolProperties;
|
import eu.dnetlib.irishmonitorservice.configuration.properties.StatsToolProperties;
|
||||||
import eu.dnetlib.irishmonitorservice.entities.Data;
|
import eu.dnetlib.irishmonitorservice.entities.Data;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -14,6 +15,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -26,37 +28,45 @@ public class StatsToolService {
|
||||||
private RestTemplate restTemplate;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
@Cacheable(value = "funders")
|
@Cacheable(value = "funders")
|
||||||
public List<List<String>> getFunders() throws UnsupportedEncodingException {
|
public List<List<List<String>>> getFunders() throws UnsupportedEncodingException {
|
||||||
String url = this.properties.getRfo();
|
return this.getData(this.properties.getRfo());
|
||||||
return this.getData(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "organizations")
|
@Cacheable(value = "organizations")
|
||||||
public List<List<String>> getOrganizations() throws UnsupportedEncodingException {
|
public List<List<List<String>>> getOrganizations() throws UnsupportedEncodingException {
|
||||||
String url = this.properties.getRpo();
|
return this.getData(this.properties.getRpo());
|
||||||
return this.getData(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "datasources")
|
@Cacheable(value = "datasources")
|
||||||
public List<List<String>> getDataSources() throws UnsupportedEncodingException {
|
public List<List<List<String>>> getDataSources() throws UnsupportedEncodingException {
|
||||||
String url = this.properties.getRepository();
|
return this.getData(this.properties.getRepository());
|
||||||
return this.getData(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<List<String>> getData(String url) throws UnsupportedEncodingException {
|
public List<List<List<String>>> getData(Indicators indicators) throws UnsupportedEncodingException {
|
||||||
if(url != null) {
|
if(indicators != null) {
|
||||||
String service = url.substring(0, url.indexOf('=') + 1);
|
List<List<List<String>>> data = new ArrayList<>();
|
||||||
String json = URLDecoder.decode(url.substring(url.indexOf('=') + 1), "UTF-8");
|
data.add(this.getData(properties.getHost(), indicators.getPublications()));
|
||||||
URI uri = UriComponentsBuilder.fromUriString(service + json).build().encode().toUri();
|
data.add(this.getData(properties.getHost(), indicators.getPublicationsPR()));
|
||||||
try {
|
data.add(this.getData(properties.getHost(), indicators.getPublicationsPROA()));
|
||||||
ResponseEntity<Data> data = restTemplate.getForEntity(uri, Data.class);
|
return data;
|
||||||
if(data.getStatusCode() == HttpStatus.OK) {
|
|
||||||
return data.getBody().getData();
|
|
||||||
}
|
|
||||||
} catch (RestClientException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<List<String>> getData(String service, String json) throws UnsupportedEncodingException {
|
||||||
|
if(service == null || json == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
} else {
|
||||||
|
URI uri = UriComponentsBuilder.fromUriString(service + URLDecoder.decode(json, "UTF-8")).build().encode().toUri();
|
||||||
|
try {
|
||||||
|
ResponseEntity<Data> response = restTemplate.getForEntity(uri, Data.class);
|
||||||
|
if(response.getStatusCode() == HttpStatus.OK) {
|
||||||
|
return response.getBody().getData();
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#static properties
|
#static properties
|
||||||
api.title = Irish Monitor Service Documentation Swagger
|
api.title = Irish Monitor Service Documentation Swagger
|
||||||
api.description = Irish Monitor Service is a service which ...
|
api.description = Irish Monitor Service is a service that integrates both OpenAIRE login and OpenAIRE Monitor API and provide all functionalities for National Open Access Monitor, Ireland
|
||||||
api.version = ${project.version}
|
api.version = ${project.version}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
irishmonitorservice.globalVars.buildDate=@timestamp@
|
irishmonitorservice.globalVars.buildDate=@timestamp@
|
||||||
irishmonitorservice.globalVars.version=@version@
|
irishmonitorservice.globalVars.version=@version@
|
||||||
|
|
||||||
stats-tool.rfo=https://stats.madgik.di.uoa.gr/stats-api/raw?json=%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.host=https://stats.madgik.di.uoa.gr/stats-api/raw?json=
|
||||||
stats-tool.rpo=https://stats.madgik.di.uoa.gr/stats-api/raw?json=%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.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.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
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Configuration status="WARN" monitorInterval="30">
|
|
||||||
<Properties>
|
|
||||||
<Property name="LOG_PATTERN">
|
|
||||||
%d %p %t [%c] - %m%n
|
|
||||||
</Property>
|
|
||||||
</Properties>
|
|
||||||
<Appenders>
|
|
||||||
<!-- Rolling File Appender -->
|
|
||||||
<RollingFile name="R" fileName="/var/log/dnet/irish-monitor-service/irish-monitor-service.log"
|
|
||||||
filePattern="/var/log/dnet/irish-monitor-service/irish-monitor-service-%d{yyyy-MM-dd}-%i.log">
|
|
||||||
<PatternLayout>
|
|
||||||
<Pattern>${LOG_PATTERN}</Pattern>
|
|
||||||
</PatternLayout>
|
|
||||||
<Policies>
|
|
||||||
<SizeBasedTriggeringPolicy size="10MB" />
|
|
||||||
</Policies>
|
|
||||||
<DefaultRolloverStrategy max="10"/>
|
|
||||||
</RollingFile>
|
|
||||||
<RollingFile name="S" fileName="/var/log/dnet/irish-monitor-service/irish-monitor-service-spring.log"
|
|
||||||
filePattern="/var/log/dnet/irish-monitor-service/irish-monitor-service-spring-%d{yyyy-MM-dd}-%i.log">
|
|
||||||
<PatternLayout>
|
|
||||||
<Pattern>${LOG_PATTERN}</Pattern>
|
|
||||||
</PatternLayout>
|
|
||||||
<Policies>
|
|
||||||
<SizeBasedTriggeringPolicy size="10MB" />
|
|
||||||
</Policies>
|
|
||||||
<DefaultRolloverStrategy max="10"/>
|
|
||||||
</RollingFile>
|
|
||||||
</Appenders>
|
|
||||||
<Loggers>
|
|
||||||
<Logger name="eu.dnetlib" level="debug" additivity="false">
|
|
||||||
<AppenderRef ref="R"/>
|
|
||||||
</Logger>
|
|
||||||
<Root level="info">
|
|
||||||
<AppenderRef ref="S"/>
|
|
||||||
</Root>
|
|
||||||
</Loggers>
|
|
||||||
</Configuration>
|
|
Loading…
Reference in New Issue