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