partial migration to new openAPI
This commit is contained in:
parent
c3d2187257
commit
fb08b4a4c2
|
@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
@ -50,9 +49,6 @@ public class LiteratureBrokerServiceApplication extends AbstractDnetApp {
|
|||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"))
|
||||
.tags(tags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
@ -41,9 +40,6 @@ public class BrokerPublicApplication extends AbstractDnetApp {
|
|||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"))
|
||||
.tags(tags);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
@ -37,10 +36,7 @@ public class MainApplication extends AbstractDnetApp {
|
|||
openApi.info(new Info().title("MDStore Manager APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import eu.dnetlib.openaire.dsm.DsmApiController;
|
|||
import eu.dnetlib.openaire.funders.FundersApiController;
|
||||
import eu.dnetlib.openaire.info.InfoController;
|
||||
import eu.dnetlib.openaire.project.ProjectsController;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
@ -40,10 +39,7 @@ public class DNetOpenaireExporterApplication extends AbstractDnetApp {
|
|||
openApi.info(new Info().title("D-Net Exporter APIs")
|
||||
.description("APIs documentation")
|
||||
.version(V1)
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
@ -37,10 +36,7 @@ public class MainApplication extends AbstractDnetApp {
|
|||
openApi.info(new Info().title("D-Net Organizations Service APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package eu.dnetlib.scholix.api;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import io.micrometer.core.aop.TimedAspect;
|
||||
import io.micrometer.core.instrument.*;
|
||||
import io.micrometer.core.instrument.config.MeterFilter;
|
||||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
||||
import org.springdoc.core.GroupedOpenApi;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
@ -13,28 +9,27 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import io.micrometer.core.aop.TimedAspect;
|
||||
import io.micrometer.core.instrument.Meter;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.config.MeterFilter;
|
||||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
@ComponentScan(basePackages = "eu.dnetlib")
|
||||
public class MainApplication extends AbstractDnetApp {
|
||||
|
||||
private double scale = 1000000000;
|
||||
|
||||
private double[] histogramValues =new double[]{.005 * scale, .01 * scale, .25 * scale, .5 * scale, .75 * scale, scale, 2.5 * scale, 5.0 * scale, 7.5 * scale, 10.0 * scale};
|
||||
|
||||
private final double scale = 1000000000;
|
||||
|
||||
private final double[] histogramValues = new double[] {
|
||||
.005 * scale, .01 * scale, .25 * scale, .5 * scale, .75 * scale, scale, 2.5 * scale, 5.0 * scale, 7.5 * scale, 10.0 * scale
|
||||
};
|
||||
|
||||
@Value("${dhp.swagger.api.host}")
|
||||
private String swaggetHost;
|
||||
|
@ -42,31 +37,29 @@ public class MainApplication extends AbstractDnetApp {
|
|||
@Value("${dhp.swagger.api.basePath}")
|
||||
private String swaggerPath;
|
||||
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public TaggedCounter myCounter(MeterRegistry meterRegistry) {
|
||||
public TaggedCounter myCounter(final MeterRegistry meterRegistry) {
|
||||
|
||||
return new TaggedCounter(ScholixAPIConstants.SCHOLIX_MANAGER_COUNTER_NAME, ScholixAPIConstants.SCHOLIX_MANAGER_TAG_NAME,meterRegistry);
|
||||
return new TaggedCounter(ScholixAPIConstants.SCHOLIX_MANAGER_COUNTER_NAME, ScholixAPIConstants.SCHOLIX_MANAGER_TAG_NAME, meterRegistry);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TimedAspect timedAspect(MeterRegistry meterRegistry) {
|
||||
MeterFilter mf = new MeterFilter() {
|
||||
public TimedAspect timedAspect(final MeterRegistry meterRegistry) {
|
||||
final MeterFilter mf = new MeterFilter() {
|
||||
|
||||
@Override
|
||||
public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
|
||||
public DistributionStatisticConfig configure(final Meter.Id id, final DistributionStatisticConfig config) {
|
||||
if (id.getName().startsWith(ScholixAPIConstants.SCHOLIX_COUNTER_PREFIX)) {
|
||||
|
||||
return DistributionStatisticConfig.builder()
|
||||
.percentilesHistogram(false)
|
||||
.serviceLevelObjectives( histogramValues)
|
||||
.build()
|
||||
.merge(config);
|
||||
.percentilesHistogram(false)
|
||||
.serviceLevelObjectives(histogramValues)
|
||||
.build()
|
||||
.merge(config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
@ -75,50 +68,28 @@ public class MainApplication extends AbstractDnetApp {
|
|||
return new TimedAspect(meterRegistry);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket
|
||||
.host(swaggetHost)
|
||||
.pathMapping(swaggerPath)
|
||||
.groupName(ScholixAPIConstants.API_V1_NAME)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/v1"))
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title(ScholixAPIConstants.API_V1_NAME)
|
||||
.description(ScholixAPIConstants.API_DESCRIPTION)
|
||||
.version("1.0")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
@Bean
|
||||
public GroupedOpenApi publicApiV1() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group(ScholixAPIConstants.API_V1_NAME)
|
||||
.pathsToMatch("/v1/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi publicApiV2() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group(ScholixAPIConstants.API_V1_NAME)
|
||||
.pathsToMatch("/v2/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Bean (name = "SpringDocketv2")
|
||||
public Docket v2Docket() {
|
||||
final Docket docket = new Docket(DocumentationType.SWAGGER_2);
|
||||
docket
|
||||
.host(swaggetHost)
|
||||
.pathMapping(swaggerPath)
|
||||
.groupName(ScholixAPIConstants.API_V2_NAME)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/v2"))
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title(ScholixAPIConstants.API_V2_NAME)
|
||||
.description(ScholixAPIConstants.API_DESCRIPTION)
|
||||
.version("2.0")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
|
||||
return docket;
|
||||
@Override
|
||||
protected void configSwagger(final OpenAPI openApi) {
|
||||
openApi.info(new Info().title("ScholeExplorer APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,50 +1,41 @@
|
|||
package eu.dnetlib.scholix.api.controller;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v1.LinkPublisher;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v1.LinkPublisher;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1")
|
||||
@Tag(tags = {
|
||||
"Datasources"
|
||||
})
|
||||
public class DatasourceV1 extends AbstractDnetController {
|
||||
@Tag(name = "Datasources")
|
||||
public class DatasourceV1 extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private ScholixIndexManager manager;
|
||||
@Autowired
|
||||
private ScholixIndexManager manager;
|
||||
|
||||
@Timed(value = "scholix.v1.datasources", description = "Time taken to return all datasources on Version 1.0 of Scholix")
|
||||
@Operation(
|
||||
summary = "Get all Datasources",
|
||||
description = "returns a list of all datasources")
|
||||
@GetMapping("/listDatasources")
|
||||
public List<LinkPublisher> getDatasources() throws ScholixException {
|
||||
@Timed(value = "scholix.v1.datasources", description = "Time taken to return all datasources on Version 1.0 of Scholix")
|
||||
@Operation(summary = "Get all Datasources", description = "returns a list of all datasources")
|
||||
@GetMapping("/listDatasources")
|
||||
public List<LinkPublisher> getDatasources() throws ScholixException {
|
||||
|
||||
final List<Pair<String, Long>> result = manager.totalLinksByProvider(null);
|
||||
|
||||
final List<Pair<String, Long>> result = manager.totalLinksByProvider(null);
|
||||
if (result == null) { return new ArrayList<>(); }
|
||||
|
||||
if (result == null)
|
||||
return new ArrayList<>();
|
||||
return result.stream().map(p -> new LinkPublisher().name(p.getKey()).totalRelationships(p.getValue().intValue())).collect(Collectors.toList());
|
||||
|
||||
return result.stream().map(p -> new LinkPublisher().name(p.getKey()).totalRelationships(p.getValue().intValue())).collect(Collectors.toList());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package eu.dnetlib.scholix.api.controller;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v2.LinkProviderType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -13,36 +11,33 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v2.LinkProviderType;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v2")
|
||||
@Tag(tags = {
|
||||
"LinkProvider : Operation related to the Link Provider"
|
||||
})
|
||||
@Tag(name = "LinkProvider : Operation related to the Link Provider")
|
||||
public class LinkProviderV2 {
|
||||
|
||||
@Autowired
|
||||
ScholixIndexManager manager;
|
||||
@Autowired
|
||||
ScholixIndexManager manager;
|
||||
|
||||
@Operation(
|
||||
summary = "Get all Link Providers",
|
||||
description = "Return a list of link provider and relative number of relations")
|
||||
@GetMapping("/LinkProvider")
|
||||
public List<LinkProviderType> getLinkProviders(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter the link provider name") @RequestParam(required = false) String name
|
||||
) throws ScholixException {
|
||||
@Operation(summary = "Get all Link Providers", description = "Return a list of link provider and relative number of relations")
|
||||
@GetMapping("/LinkProvider")
|
||||
public List<LinkProviderType> getLinkProviders(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter the link provider name") @RequestParam(required = false) final String name)
|
||||
throws ScholixException {
|
||||
|
||||
List<Pair<String, Long>> result = manager.totalLinksByProvider(name);
|
||||
final List<Pair<String, Long>> result = manager.totalLinksByProvider(name);
|
||||
|
||||
if (result==null)
|
||||
return new ArrayList<>();
|
||||
if (result == null) { return new ArrayList<>(); }
|
||||
|
||||
return result.stream().map(s -> new LinkProviderType().name(s.getLeft()).totalRelationships(s.getValue().intValue())).collect(Collectors.toList());
|
||||
return result.stream().map(s -> new LinkProviderType().name(s.getLeft()).totalRelationships(s.getValue().intValue())).collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package eu.dnetlib.scholix.api.controller;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v2.LinkProviderType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -13,49 +11,47 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v2.LinkProviderType;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v2/LinkPublisher")
|
||||
@Tag(tags = {
|
||||
"LinkPublisher : Operation related to the Link Publisher"
|
||||
})
|
||||
@Tag(name = "LinkPublisher : Operation related to the Link Publisher")
|
||||
public class LinkPublisherV2 {
|
||||
|
||||
@Autowired
|
||||
ScholixIndexManager manager;
|
||||
@Autowired
|
||||
ScholixIndexManager manager;
|
||||
|
||||
@Operation(
|
||||
summary = "Get All Publishers that provide source object",
|
||||
description = "Return a List of all Publishers that provide source objects in Scholix " +
|
||||
"links and the total number of links where the source object comes from this publisher")
|
||||
@GetMapping("/inSource")
|
||||
public List<LinkProviderType> getInSource(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter the link publisher name") @RequestParam(required = false) String name
|
||||
) throws ScholixException {
|
||||
List<Pair<String, Long>> result = manager.totalLinksPublisher(ScholixIndexManager.RelationPrefix.source,name);
|
||||
@Operation(summary = "Get All Publishers that provide source object", description = "Return a List of all Publishers that provide source objects in Scholix "
|
||||
+
|
||||
"links and the total number of links where the source object comes from this publisher")
|
||||
@GetMapping("/inSource")
|
||||
public List<LinkProviderType> getInSource(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter the link publisher name") @RequestParam(required = false) final String name)
|
||||
throws ScholixException {
|
||||
final List<Pair<String, Long>> result = manager.totalLinksPublisher(ScholixIndexManager.RelationPrefix.source, name);
|
||||
|
||||
if (result==null)
|
||||
return new ArrayList<>();
|
||||
if (result == null) { return new ArrayList<>(); }
|
||||
|
||||
return result.stream().map(s -> new LinkProviderType().name(s.getLeft()).totalRelationships(s.getValue().intValue())).collect(Collectors.toList());
|
||||
}
|
||||
return result.stream().map(s -> new LinkProviderType().name(s.getLeft()).totalRelationships(s.getValue().intValue())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Get All Publishers that provide target object",
|
||||
description = "Return a List of all Publishers that provide source objects in Scholix " +
|
||||
"links and the total number of links where the target object comes from this publisher")
|
||||
@GetMapping("/inTarget")
|
||||
public List<LinkProviderType> getInTarget(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter the link publisher name") @RequestParam(required = false) String name
|
||||
) throws ScholixException {
|
||||
List<Pair<String, Long>> result = manager.totalLinksPublisher(ScholixIndexManager.RelationPrefix.target,name);
|
||||
@Operation(summary = "Get All Publishers that provide target object", description = "Return a List of all Publishers that provide source objects in Scholix "
|
||||
+
|
||||
"links and the total number of links where the target object comes from this publisher")
|
||||
@GetMapping("/inTarget")
|
||||
public List<LinkProviderType> getInTarget(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter the link publisher name") @RequestParam(required = false) final String name)
|
||||
throws ScholixException {
|
||||
final List<Pair<String, Long>> result = manager.totalLinksPublisher(ScholixIndexManager.RelationPrefix.target, name);
|
||||
|
||||
if (result==null)
|
||||
return new ArrayList<>();
|
||||
if (result == null) { return new ArrayList<>(); }
|
||||
|
||||
return result.stream().map(s -> new LinkProviderType().name(s.getLeft()).totalRelationships(s.getValue().intValue())).collect(Collectors.toList());
|
||||
}
|
||||
return result.stream().map(s -> new LinkProviderType().name(s.getLeft()).totalRelationships(s.getValue().intValue())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,114 +1,82 @@
|
|||
package eu.dnetlib.scholix.api.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.dhp.schema.sx.scholix.Scholix;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v1.ScholixV1;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v1.ScholixV1;
|
||||
import eu.dnetlib.dhp.schema.sx.scholix.Scholix;
|
||||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1")
|
||||
@Tag(tags = {"Scholix"})
|
||||
@Tag(name = "Scholix")
|
||||
public class ScholixControllerV1 extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
ScholixIndexManager manager;
|
||||
@Autowired
|
||||
ScholixIndexManager manager;
|
||||
|
||||
@Operation(
|
||||
summary = "Get all Scholix relation collected from a publisher",
|
||||
description = "return a list of scholix object published from a specific publisher"
|
||||
)
|
||||
@GetMapping("/linksFromPublisher")
|
||||
@Timed(value = "scholix.v1.linksFromPublisher", description = "Time taken to return links on Version 1.0 of Scholix collected from a publisher")
|
||||
public List<ScholixV1> linksFromPublisher(
|
||||
@Parameter(
|
||||
in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships collected from a publisher",
|
||||
schema = @Schema(), required = true) String publisher,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "The page number") @RequestParam(required = false) Integer page
|
||||
) throws ScholixException {
|
||||
@Operation(summary = "Get all Scholix relation collected from a publisher", description = "return a list of scholix object published from a specific publisher")
|
||||
@GetMapping("/linksFromPublisher")
|
||||
@Timed(value = "scholix.v1.linksFromPublisher", description = "Time taken to return links on Version 1.0 of Scholix collected from a publisher")
|
||||
public List<ScholixV1> linksFromPublisher(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships collected from a publisher", schema = @Schema(), required = true) final String publisher,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "The page number") @RequestParam(required = false) final Integer page) throws ScholixException {
|
||||
|
||||
final int currentPage = page != null ? page : 0;
|
||||
final int currentPage = page != null ? page : 0;
|
||||
|
||||
Pair<Long, List<Scholix>> scholixResult =manager.linksFromPid(null,null,null,publisher,
|
||||
null,null,null,null,null, currentPage
|
||||
);
|
||||
List<Scholix> scholixData = scholixResult.getValue();
|
||||
if (scholixData== null)
|
||||
return null;
|
||||
return scholixData.stream().map(ScholixV1::fromScholix).collect(Collectors.toList());
|
||||
}
|
||||
final Pair<Long, List<Scholix>> scholixResult = manager.linksFromPid(null, null, null, publisher, null, null, null, null, null, currentPage);
|
||||
final List<Scholix> scholixData = scholixResult.getValue();
|
||||
if (scholixData == null) { return null; }
|
||||
return scholixData.stream().map(ScholixV1::fromScholix).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Get all Scholix relation collected from a datasource",
|
||||
description = "return a list of scholix object collected from a specific datasource"
|
||||
)
|
||||
@GetMapping("/linksFromDatasource")
|
||||
@Timed(value = "scholix.v1.linksFromDatasource", description = "Time taken to return links on Version 1.0 of Scholix collected from a LinkProvider")
|
||||
public List<ScholixV1> linksFromDatasource(
|
||||
@Parameter(
|
||||
in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships collected from a LinkProvider",
|
||||
schema = @Schema()) @NotNull String datasource,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "The page number") @RequestParam(required = false) Integer page
|
||||
) throws ScholixException {
|
||||
@Operation(summary = "Get all Scholix relation collected from a datasource", description = "return a list of scholix object collected from a specific datasource")
|
||||
@GetMapping("/linksFromDatasource")
|
||||
@Timed(value = "scholix.v1.linksFromDatasource", description = "Time taken to return links on Version 1.0 of Scholix collected from a LinkProvider")
|
||||
public List<ScholixV1> linksFromDatasource(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships collected from a LinkProvider", schema = @Schema()) @NotNull final String datasource,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "The page number") @RequestParam(required = false) final Integer page) throws ScholixException {
|
||||
|
||||
final int currentPage = page != null ? page : 0;
|
||||
Pair<Long, List<Scholix>> scholixResult =manager.linksFromPid(datasource,null,null,null,
|
||||
null,null,null,null,null, currentPage
|
||||
);
|
||||
List<Scholix> scholixData = scholixResult.getValue();
|
||||
if (scholixData== null)
|
||||
return null;
|
||||
return scholixData.stream().map(ScholixV1::fromScholix).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "Retrieve all scholix links from a persistent identifier",
|
||||
description = "The linksFromPid endpoint returns a list of scholix object related from a specific persistent identifier"
|
||||
)
|
||||
@GetMapping("/linksFromPid")
|
||||
@Timed(value = "scholix.v1.linksFromPid", description = "Time taken to return links on Version 1.0 of Scholix related from a specific persistent identifier")
|
||||
public List<ScholixV1> linksFromPid(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "persistent Identifier") @NotNull String pid,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Persistent Identifier Type") @RequestParam(required = false) String pidType,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "typology target filter should be publication, dataset or unknown") @RequestParam(required = false) String typologyTarget,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "a datasource provenance filter of the target relation") @RequestParam(required = false) String datasourceTarget,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "The page number") @RequestParam(required = false) Integer page
|
||||
) throws ScholixException {
|
||||
|
||||
final int currentPage = page != null ? page : 0;
|
||||
Pair<Long, List<Scholix>> scholixResult =manager.linksFromPid(datasourceTarget,null,null,null,
|
||||
typologyTarget,pid,pidType,null,null, currentPage
|
||||
);
|
||||
List<Scholix> scholixData = scholixResult.getValue();
|
||||
if (scholixData== null)
|
||||
return null;
|
||||
return scholixData.stream().map(ScholixV1::fromScholix).collect(Collectors.toList());
|
||||
}
|
||||
final int currentPage = page != null ? page : 0;
|
||||
final Pair<Long, List<Scholix>> scholixResult = manager.linksFromPid(datasource, null, null, null, null, null, null, null, null, currentPage);
|
||||
final List<Scholix> scholixData = scholixResult.getValue();
|
||||
if (scholixData == null) { return null; }
|
||||
return scholixData.stream().map(ScholixV1::fromScholix).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Operation(summary = "Retrieve all scholix links from a persistent identifier", description = "The linksFromPid endpoint returns a list of scholix object related from a specific persistent identifier")
|
||||
@GetMapping("/linksFromPid")
|
||||
@Timed(value = "scholix.v1.linksFromPid", description = "Time taken to return links on Version 1.0 of Scholix related from a specific persistent identifier")
|
||||
public List<ScholixV1> linksFromPid(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "persistent Identifier") @NotNull final String pid,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Persistent Identifier Type") @RequestParam(required = false) final String pidType,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "typology target filter should be publication, dataset or unknown") @RequestParam(required = false) final String typologyTarget,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "a datasource provenance filter of the target relation") @RequestParam(required = false) final String datasourceTarget,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "The page number") @RequestParam(required = false) final Integer page) throws ScholixException {
|
||||
|
||||
final int currentPage = page != null ? page : 0;
|
||||
final Pair<Long, List<Scholix>> scholixResult =
|
||||
manager.linksFromPid(datasourceTarget, null, null, null, typologyTarget, pid, pidType, null, null, currentPage);
|
||||
final List<Scholix> scholixData = scholixResult.getValue();
|
||||
if (scholixData == null) { return null; }
|
||||
return scholixData.stream().map(ScholixV1::fromScholix).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
package eu.dnetlib.scholix.api.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.dhp.schema.sx.api.model.v2.PageResultType;
|
||||
|
@ -8,70 +17,53 @@ import eu.dnetlib.dhp.schema.sx.scholix.Scholix;
|
|||
import eu.dnetlib.scholix.api.ScholixException;
|
||||
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v2")
|
||||
@Tag(tags = {
|
||||
"Links : Operation related to the Scholix Links"
|
||||
})
|
||||
@Tag(name = "Links : Operation related to the Scholix Links")
|
||||
public class ScholixControllerV2 extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private ScholixIndexManager manager;
|
||||
@Autowired
|
||||
private ScholixIndexManager manager;
|
||||
|
||||
@Timed(value = "scholix.v2.links", description = "Time taken to return links on Version 2.0 of Scholix")
|
||||
@Operation(summary = "Get Scholix Links")
|
||||
@GetMapping("/Links")
|
||||
public PageResultType links(
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships collected from a LinkProvider") String linkProvider,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a target pid") String targetPid,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a target pid type") String targetPidType,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a target published in a Publisher named targetPublisher") String targetPublisher,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a target type (literature, dataset, unknown)") String targetType,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a source pid") String sourcePid,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a source pid type") String sourcePidType,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a source published in a Publisher named sourcePublisher") String sourcePublisher,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "Filter Scholix relationships having a source type (literature, dataset, unknown)") String sourceType,
|
||||
// @Parameter(in = ParameterIn.QUERY,
|
||||
// description = "Filter scholix Links having collected after this date") String harvestedAfter,
|
||||
@Parameter(in = ParameterIn.QUERY,
|
||||
description = "select page of result") Integer page) throws Exception {
|
||||
@Timed(value = "scholix.v2.links", description = "Time taken to return links on Version 2.0 of Scholix")
|
||||
@Operation(summary = "Get Scholix Links")
|
||||
@GetMapping("/Links")
|
||||
public PageResultType links(
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships collected from a LinkProvider") final String linkProvider,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a target pid") final String targetPid,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a target pid type") final String targetPidType,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a target published in a Publisher named targetPublisher") final String targetPublisher,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a target type (literature, dataset, unknown)") final String targetType,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a source pid") final String sourcePid,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a source pid type") final String sourcePidType,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a source published in a Publisher named sourcePublisher") final String sourcePublisher,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "Filter Scholix relationships having a source type (literature, dataset, unknown)") final String sourceType,
|
||||
// @Parameter(in = ParameterIn.QUERY,
|
||||
// description = "Filter scholix Links having collected after this date") String harvestedAfter,
|
||||
@Parameter(in = ParameterIn.QUERY, description = "select page of result") final Integer page) throws Exception {
|
||||
|
||||
if (StringUtils.isEmpty(sourcePid) && StringUtils.isEmpty(targetPid) && StringUtils.isEmpty(sourcePublisher)&& StringUtils.isEmpty(targetPublisher)&& StringUtils.isEmpty(linkProvider))
|
||||
throw new ScholixException("The method requires one of the following parameters: sourcePid, targetPid, sourcePublisher, targetPublisher, linkProvider");
|
||||
if (StringUtils.isEmpty(sourcePid) && StringUtils.isEmpty(targetPid) && StringUtils.isEmpty(sourcePublisher) && StringUtils.isEmpty(targetPublisher)
|
||||
&& StringUtils.isEmpty(linkProvider)) {
|
||||
throw new ScholixException(
|
||||
"The method requires one of the following parameters: sourcePid, targetPid, sourcePublisher, targetPublisher, linkProvider");
|
||||
}
|
||||
|
||||
try {
|
||||
final int currentPage = page != null ? page : 0;
|
||||
Pair<Long, List<Scholix>> scholixResult = manager.linksFromPid( linkProvider, targetPid, targetPidType, targetPublisher, targetType, sourcePid, sourcePidType, sourcePublisher, sourceType, currentPage);
|
||||
final PageResultType pageResult = new PageResultType();
|
||||
pageResult.setTotalPages(scholixResult.getLeft().intValue() / 10);
|
||||
pageResult.setTotalLinks(scholixResult.getLeft().intValue());
|
||||
pageResult.setResult(scholixResult.getRight().stream().map(ScholixType::fromScholix).collect(Collectors.toList()));
|
||||
return pageResult;
|
||||
} catch (Throwable e) {
|
||||
throw new ScholixException("Error on requesting url ", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
final int currentPage = page != null ? page : 0;
|
||||
final Pair<Long, List<Scholix>> scholixResult = manager
|
||||
.linksFromPid(linkProvider, targetPid, targetPidType, targetPublisher, targetType, sourcePid, sourcePidType, sourcePublisher, sourceType, currentPage);
|
||||
final PageResultType pageResult = new PageResultType();
|
||||
pageResult.setTotalPages(scholixResult.getLeft().intValue() / 10);
|
||||
pageResult.setTotalLinks(scholixResult.getLeft().intValue());
|
||||
pageResult.setResult(scholixResult.getRight().stream().map(ScholixType::fromScholix).collect(Collectors.toList()));
|
||||
return pageResult;
|
||||
} catch (final Throwable e) {
|
||||
throw new ScholixException("Error on requesting url ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue