partial migration to new openAPI

This commit is contained in:
Michele Artini 2022-08-19 15:21:40 +02:00
parent e037cd0b41
commit 9b9d37624c
47 changed files with 996 additions and 1003 deletions

View File

@ -1,10 +1,6 @@
package eu.dnetlib;
import static springfox.documentation.builders.RequestHandlerSelectors.basePackage;
import java.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -21,16 +17,13 @@ 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;
@EnableCaching
@EnableScheduling
@EnableSwagger2
@SpringBootApplication
@EnableAutoConfiguration(exclude = {
SolrAutoConfiguration.class
@ -43,67 +36,51 @@ public class DNetOpenaireExporterApplication extends AbstractDnetApp {
SpringApplication.run(DNetOpenaireExporterApplication.class, args);
}
@Autowired
private DnetOpenaireExporterProperties config;
@Bean
public Docket dsm() {
return _docket("Datasource Manager", DsmApiController.class.getPackage().getName(), config.getSwaggerDsm(), V1);
}
@Bean
public Docket projects() {
return _docket("OpenAIRE Projects", ProjectsController.class.getPackage().getName(), config.getSwaggerProjects(), V1);
}
@Bean
public Docket funders() {
return _docket("OpenAIRE Funders", FundersApiController.class.getPackage().getName(), config.getSwaggerFunders(), V1);
}
@Bean
public Docket communities() {
return _docket("OpenAIRE Communities", CommunityApiController.class.getPackage().getName(), config.getSwaggerCommunities(), V1);
}
@Bean
public Docket contexts() {
return _docket("OpenAIRE Contexts", ContextApiController.class.getPackage().getName(), config.getSwaggerCommunities(), V1);
}
private Docket _docket(final String groupName, final String controllerPackage, final Swagger swag, final String version) {
final Docket d = new Docket(DocumentationType.SWAGGER_2);
configSwagger(d, groupName, controllerPackage, swag, version);
return d;
}
@Override
protected void configSwagger(final Docket docket) {
configSwagger(docket, "OpenAIRE Info", InfoController.class.getPackage().getName(), config.getSwaggerInfo(), V1);
protected void configSwagger(final OpenAPI openApi) {
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"));
}
private void configSwagger(final Docket docket, final String groupName, final String controllerPackage, final Swagger swag, final String version) {
docket
.groupName(groupName)
.select()
.apis(basePackage(controllerPackage))
.build()
.directModelSubstitute(LocalDate.class, java.sql.Date.class)
.apiInfo(apiInfo(swag, version));
@Bean
public GroupedOpenApi dsm() {
return newGroupedOpenApi("Datasource Manager", DsmApiController.class.getPackage().getName());
}
private ApiInfo apiInfo(final Swagger swag, final String version) {
return new ApiInfoBuilder()
.title(swag.getApiTitle())
.description(swag.getApiDescription())
.license(swag.getApiLicense())
.licenseUrl(swag.getApiLicenseUrl())
.termsOfServiceUrl("")
.version(version)
.contact(new Contact(
swag.getApiContactName(),
swag.getApiContactUrl(),
swag.getApiContactEmail()))
@Bean
public GroupedOpenApi projects() {
return newGroupedOpenApi("OpenAIRE Projects", ProjectsController.class.getPackage().getName());
}
@Bean
public GroupedOpenApi funders() {
return newGroupedOpenApi("OpenAIRE Funders", FundersApiController.class.getPackage().getName());
}
@Bean
public GroupedOpenApi communities() {
return newGroupedOpenApi("OpenAIRE Communities", CommunityApiController.class.getPackage().getName());
}
@Bean
public GroupedOpenApi contexts() {
return newGroupedOpenApi("OpenAIRE Contexts", ContextApiController.class.getPackage().getName());
}
@Bean
public GroupedOpenApi info() {
return newGroupedOpenApi("OpenAIRE Info", InfoController.class.getPackage().getName());
}
private GroupedOpenApi newGroupedOpenApi(final String groupName, final String controllerPackage, final Swagger swag, final String version) {
return GroupedOpenApi.builder()
.group(groupName)
.packagesToScan(controllerPackage)
.build();
}

View File

@ -40,12 +40,6 @@ public class DnetOpenaireExporterProperties {
private Datasource datasource;
private Project project;
private Jdbc jdbc;
private Swagger swaggerDsm;
private Swagger swaggerProjects;
private Swagger swaggerFunders;
private Swagger swaggerCommunities;
private Swagger swaggerContexts;
private Swagger swaggerInfo;
private Vocabularies vocabularies;
@ -485,54 +479,6 @@ public class DnetOpenaireExporterProperties {
this.jdbc = jdbc;
}
public Swagger getSwaggerDsm() {
return swaggerDsm;
}
public void setSwaggerDsm(final Swagger swaggerDsm) {
this.swaggerDsm = swaggerDsm;
}
public Swagger getSwaggerProjects() {
return swaggerProjects;
}
public void setSwaggerProjects(final Swagger swaggerProjects) {
this.swaggerProjects = swaggerProjects;
}
public Swagger getSwaggerFunders() {
return swaggerFunders;
}
public void setSwaggerFunders(final Swagger swaggerFunders) {
this.swaggerFunders = swaggerFunders;
}
public Swagger getSwaggerCommunities() {
return swaggerCommunities;
}
public void setSwaggerCommunities(final Swagger swaggerCommunities) {
this.swaggerCommunities = swaggerCommunities;
}
public Swagger getSwaggerContexts() {
return swaggerContexts;
}
public void setSwaggerContexts(final Swagger swaggerContexts) {
this.swaggerContexts = swaggerContexts;
}
public Swagger getSwaggerInfo() {
return swaggerInfo;
}
public void setSwaggerInfo(final Swagger swaggerInfo) {
this.swaggerInfo = swaggerInfo;
}
public Vocabularies getVocabularies() {
return vocabularies;
}

View File

@ -1,92 +1,113 @@
package eu.dnetlib.openaire.community;
import static eu.dnetlib.openaire.common.ExporterConstants.C;
import static eu.dnetlib.openaire.common.ExporterConstants.C_CP;
import static eu.dnetlib.openaire.common.ExporterConstants.C_O;
import static eu.dnetlib.openaire.common.ExporterConstants.C_PJ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_ZC;
import static eu.dnetlib.openaire.common.ExporterConstants.R;
import static eu.dnetlib.openaire.common.ExporterConstants.W;
import java.util.List;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import static eu.dnetlib.openaire.common.ExporterConstants.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController
@CrossOrigin(origins = { "*" })
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
@io.swagger.annotations.Api(tags = "OpenAIRE Communities API", description = "the OpenAIRE Community API")
@Tag(name = "OpenAIRE Communities API", description = "the OpenAIRE Community API")
public class CommunityApiController {
@Autowired
private CommunityApiCore communityApiCore;
@RequestMapping(value = "/community/communities", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get all community profiles",
notes = "get all community profiles",
tags = { C, R },
response = CommunitySummary[].class)
@RequestMapping(value = "/community/communities", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get all community profiles", description = "get all community profiles", tags = {
C, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunitySummary[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunitySummary> listCommunities() throws CommunityException {
return communityApiCore.listCommunities();
}
@RequestMapping(value = "/community/{id}", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get community profile",
notes = "get community profile",
tags = { C, R },
response = CommunityDetails.class)
@RequestMapping(value = "/community/{id}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get community profile", description = "get community profile", tags = {
C, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityDetails.class),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails getCommunity(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunity(id);
}
@RequestMapping(value = "/community/{id}", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
value = "update community details",
notes = "update community details",
tags = { C, R })
@RequestMapping(value = "/community/{id}", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "update community details", description = "update community details", tags = {
C, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void setCommunity(
@PathVariable final String id,
@RequestBody CommunityWritableProperties properties) throws CommunityException, CommunityNotFoundException {
@RequestBody final CommunityWritableProperties properties) throws CommunityException, CommunityNotFoundException {
communityApiCore.setCommunity(id, properties);
}
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get community projects",
notes = "get community projects",
tags = { C_PJ, R },
response = CommunityProject[].class)
@RequestMapping(value = "/community/{id}/projects", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get community projects", description = "get community projects", tags = {
C_PJ, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityProject[].class),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityProject> getCommunityProjects(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityProjects(id);
}
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
value = "associate a project to the community",
notes = "associate a project to the community",
tags = { C_PJ, W })
@RequestMapping(value = "/community/{id}/projects", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a project to the community", description = "associate a project to the community", tags = {
C_PJ, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityProject addCommunityProject(
@PathVariable final String id,
@RequestBody final CommunityProject project) throws CommunityException, CommunityNotFoundException {
@ -94,15 +115,17 @@ public class CommunityApiController {
return communityApiCore.addCommunityProject(id, project);
}
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
value = "remove a project from the community",
notes = "remove a project from the community",
tags = { C_PJ, W })
@RequestMapping(value = "/community/{id}/projects", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove a project from the community", description = "remove a project from the community", tags = {
C_PJ, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void deleteCommunityProject(
@PathVariable final String id,
@RequestBody final Integer projectId) throws CommunityException, CommunityNotFoundException {
@ -110,29 +133,32 @@ public class CommunityApiController {
communityApiCore.removeCommunityProject(id, projectId);
}
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get the list of content providers associated to a given community",
notes = "get the list of content providers associated to a given community",
tags = { C_CP, R },
response = CommunityContentprovider[].class)
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the list of content providers associated to a given community", description = "get the list of content providers associated to a given community", tags = {
C_CP, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityContentprovider[].class),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityContentprovider> getCommunityContentproviders(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityContentproviders(id);
}
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
value = "associate a content provider to the community",
notes = "associate a content provider to the community",
tags = { C_CP, W })
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a content provider to the community", description = "associate a content provider to the community", tags = {
C_CP, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityContentprovider addCommunityContentprovider(
@PathVariable final String id,
@RequestBody final CommunityContentprovider contentprovider) throws CommunityException, CommunityNotFoundException {
@ -140,15 +166,17 @@ public class CommunityApiController {
return communityApiCore.addCommunityContentprovider(id, contentprovider);
}
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
value = "remove the association between a content provider and the community",
notes = "remove the association between a content provider and the community",
tags = { C_CP, W })
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove the association between a content provider and the community", description = "remove the association between a content provider and the community", tags = {
C_CP, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void removeCommunityContentprovider(
@PathVariable final String id,
@RequestBody final Integer contentproviderId) throws CommunityException, CommunityNotFoundException {
@ -158,29 +186,32 @@ public class CommunityApiController {
// ADDING CODE FOR COMMUNITY ORGANIZATIONS
@RequestMapping(value = "/community/{id}/organizations", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get the list of organizations for a given community",
notes = "get the list of organizations for a given community",
tags = { C_O, R },
response = CommunityOrganization[].class)
@RequestMapping(value = "/community/{id}/organizations", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the list of organizations for a given community", description = "get the list of organizations for a given community", tags = {
C_O, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityContentprovider[].class),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityOrganization> getCommunityOrganizations(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityOrganizations(id);
}
@RequestMapping(value = "/community/{id}/organizations", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
value = "associate an organization to the community",
notes = "associate an organization to the community",
tags = { C_O, W })
@RequestMapping(value = "/community/{id}/organizations", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate an organization to the community", description = "associate an organization to the community", tags = {
C_O, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityOrganization addCommunityOrganization(
@PathVariable final String id,
@RequestBody final CommunityOrganization organization) throws CommunityException, CommunityNotFoundException {
@ -188,15 +219,17 @@ public class CommunityApiController {
return communityApiCore.addCommunityOrganization(id, organization);
}
@RequestMapping(value = "/community/{id}/organizations", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
value = "remove the association between an organization and the community",
notes = "remove the association between an organization and the community",
tags = { C_O, W })
@RequestMapping(value = "/community/{id}/organizations", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove the association between an organization and the community", description = "remove the association between an organization and the community", tags = {
C_O, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void removeCommunityOrganization(
@PathVariable final String id,
@RequestBody final Integer organizationId) throws CommunityException, CommunityNotFoundException {
@ -205,15 +238,17 @@ public class CommunityApiController {
}
// **********************
@RequestMapping(value = "/community/{id}/subjects", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
value = "associate a subject to the community",
notes = "associate a subject to the community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/subjects", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a subject to the community", description = "associate a subject to the community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails addCommunitySubjects(
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, CommunityNotFoundException {
@ -221,15 +256,17 @@ public class CommunityApiController {
return communityApiCore.addCommunitySubjects(id, subjects);
}
@RequestMapping(value = "/community/{id}/subjects", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
value = "remove subjects from a community",
notes = "remove subjects from a community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/subjects", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove subjects from a community", description = "remove subjects from a community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails removeCommunitySubjects(
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, CommunityNotFoundException {
@ -237,29 +274,32 @@ public class CommunityApiController {
return communityApiCore.removeCommunitySubjects(id, subjects);
}
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get the list of Zenodo communities associated to a given community",
notes = "get the list of Zenodo communities associated to a given community",
tags = { C_ZC, R },
response = CommunityZenodoCommunity[].class)
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the list of Zenodo communities associated to a given community", description = "get the list of Zenodo communities associated to a given community", tags = {
C_ZC, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityZenodoCommunity[].class),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityZenodoCommunity> getCommunityZenodoCommunities(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityZenodoCommunities(id);
}
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
value = "associate a Zenodo community to the community",
notes = "associate a Zenodo community to the community",
tags = { C_ZC, W })
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a Zenodo community to the community", description = "associate a Zenodo community to the community", tags = {
C_ZC, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityZenodoCommunity addCommunityZenodoCommunity(
@PathVariable final String id,
@RequestBody final CommunityZenodoCommunity zenodocommunity) throws CommunityException, CommunityNotFoundException {
@ -268,15 +308,17 @@ public class CommunityApiController {
}
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
value = "remove a Zenodo community from a community",
notes = "remove a Zenodo community from a community",
tags = { C_ZC, W })
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove a Zenodo community from a community", description = "remove a Zenodo community from a community", tags = {
C_ZC, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void removeCommunityZenodoCommunity(
@PathVariable final String id,
@RequestBody final Integer zenodoCommId) throws CommunityException, CommunityNotFoundException {
@ -285,16 +327,17 @@ public class CommunityApiController {
}
@RequestMapping(value = "/community/{zenodoId}/openairecommunities", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get the list of OpenAIRE communities associated to a given Zenodo community",
notes = "get the list of OpenAIRE communities associated to a given Zenodo community",
tags = { C_ZC, R })
@RequestMapping(value = "/community/{zenodoId}/openairecommunities", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the list of OpenAIRE communities associated to a given Zenodo community", description = "get the list of OpenAIRE communities associated to a given Zenodo community", tags = {
C_ZC, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) })
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityOpenAIRECommunities getOpenAireCommunities(
@PathVariable final String zenodoId) throws CommunityException, CommunityNotFoundException {

View File

@ -6,31 +6,31 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.google.gson.Gson;
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunityContentprovider {
@Schema(value = "OpenAIRE identifier for this content provider, if available", required = false)
@Schema(description = "OpenAIRE identifier for this content provider, if available", required = false)
private String openaireId;
@NotNull
@Schema(value = "the community identifier this content provider belongs to", required = true)
@Schema(description = "the community identifier this content provider belongs to", required = true)
private String communityId;
@NotNull
@Schema(value = "identifies this content provider within the context it belongs to", required = true)
@Schema(description = "identifies this content provider within the context it belongs to", required = true)
private String id;
@Schema(value = "content provider name", required = false)
@Schema(description = "content provider name", required = false)
private String name;
@NotNull
@Schema(value = "content provider official name", required = true)
@Schema(description = "content provider official name", required = true)
private String officialname;
// @NotNull
@Schema(value = "content provider selection criteria", required = false)
@Schema(description = "content provider selection criteria", required = false)
private SelectionCriteria selectioncriteria;
public String getOpenaireId() {

View File

@ -4,31 +4,33 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunityDetails extends CommunitySummary {
@Schema("date of creation for this community")
@Schema(description = "date of creation for this community")
private Date creationDate;
@Schema("date of the last update for this communityu")
@Schema(description = "date of the last update for this communityu")
private Date lastUpdateDate;
@Schema("list of subjects (keywords) that characterise this community")
@Schema(description = "list of subjects (keywords) that characterise this community")
private List<String> subjects;
public CommunityDetails() {
}
public CommunityDetails() {}
public CommunityDetails(final CommunitySummary summary) {
super(summary);
}
@Override
public Date getCreationDate() {
return creationDate;
}
@Override
public void setCreationDate(final Date creationDate) {
this.creationDate = creationDate;
}
@ -41,11 +43,13 @@ public class CommunityDetails extends CommunitySummary {
this.subjects = subjects;
}
@Override
public Date getLastUpdateDate() {
return lastUpdateDate;
}
public void setLastUpdateDate(Date lastUpdateDate) {
@Override
public void setLastUpdateDate(final Date lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}
}

View File

@ -1,19 +1,20 @@
package eu.dnetlib.openaire.community;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
import io.swagger.v3.oas.annotations.media.Schema;
public class CommunityOpenAIRECommunities {
@NotNull
@Schema(value = "the zenodo community identifier", required = true)
@Schema(description = "the zenodo community identifier", required = true)
private String zenodoid;
@NotNull
@Schema(value = "identifies this zenodo community within the context it belongs to", required = true)
@Schema(description = "identifies this zenodo community within the context it belongs to", required = true)
private List<String> openAirecommunitylist;
public CommunityOpenAIRECommunities() {
@ -25,7 +26,7 @@ public class CommunityOpenAIRECommunities {
return openAirecommunitylist;
}
public CommunityOpenAIRECommunities setOpenAirecommunitylist(List<String> openAirecommunitylist) {
public CommunityOpenAIRECommunities setOpenAirecommunitylist(final List<String> openAirecommunitylist) {
this.openAirecommunitylist = openAirecommunitylist;
return this;
}
@ -34,7 +35,7 @@ public class CommunityOpenAIRECommunities {
return zenodoid;
}
public CommunityOpenAIRECommunities setZenodoid(String zenodoid) {
public CommunityOpenAIRECommunities setZenodoid(final String zenodoid) {
this.zenodoid = zenodoid;
return this;
}

View File

@ -1,38 +1,39 @@
package eu.dnetlib.openaire.community;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunityOrganization {
@NotNull
@Schema(value = "the community identifier this organization belongs to", required = true)
@Schema(description = "the community identifier this organization belongs to", required = true)
private String communityId;
@NotNull
@Schema(value = "name of the organization", required = true)
@Schema(description = "name of the organization", required = true)
private String name;
@NotNull
@Schema(value = "identifies this organization within the context it belongs to", required = true)
@Schema(description = "identifies this organization within the context it belongs to", required = true)
private String id;
@NotNull
@Schema(value="url of the logo for this organization", required = true)
@Schema(description = "url of the logo for this organization", required = true)
private String logo_url;
@NotNull
@Schema(value="website url for this organization", required = true)
@Schema(description = "website url for this organization", required = true)
private String website_url;
public String getCommunityId() {
return communityId;
}
public CommunityOrganization setCommunityId(String communityId) {
public CommunityOrganization setCommunityId(final String communityId) {
this.communityId = communityId;
return this;
}
@ -41,7 +42,7 @@ public class CommunityOrganization {
return name;
}
public CommunityOrganization setName(String name) {
public CommunityOrganization setName(final String name) {
this.name = name;
return this;
}
@ -50,7 +51,7 @@ public class CommunityOrganization {
return id;
}
public CommunityOrganization setId(String id) {
public CommunityOrganization setId(final String id) {
this.id = id;
return this;
}
@ -59,7 +60,7 @@ public class CommunityOrganization {
return logo_url;
}
public CommunityOrganization setLogo_url(String logo_url) {
public CommunityOrganization setLogo_url(final String logo_url) {
this.logo_url = logo_url;
return this;
}
@ -68,7 +69,7 @@ public class CommunityOrganization {
return website_url;
}
public CommunityOrganization setWebsite_url(String website_url) {
public CommunityOrganization setWebsite_url(final String website_url) {
this.website_url = website_url;
return this;
}

View File

@ -1,30 +1,31 @@
package eu.dnetlib.openaire.community;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunityProject {
@Schema(value = "OpenAIRE identifier for this project, if available", required = false)
@Schema(description = "OpenAIRE identifier for this project, if available", required = false)
private String openaireId;
@Schema(value = "the community identifier this project belongs to", required = true)
@Schema(description = "the community identifier this project belongs to", required = true)
private String communityId;
@Schema(value = "identifies this project within the context it belongs to", required = true)
@Schema(description = "identifies this project within the context it belongs to", required = true)
private String id;
@Schema(value = "project name", required = true)
@Schema(description = "project name", required = true)
private String name;
@Schema(value = "project acronym", required = false)
@Schema(description = "project acronym", required = false)
private String acronym;
@Schema(value = "project funder", required = true)
@Schema(description = "project funder", required = true)
private String funder;
@Schema(value = "project grant id", required = true)
@Schema(description = "project grant id", required = true)
private String grantId;
public String getOpenaireId() {

View File

@ -1,17 +1,18 @@
package eu.dnetlib.openaire.community;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public enum CommunityStatus {
@Schema("restricted visibility")
@Schema(description = "restricted visibility")
hidden,
@Schema("visible only to RCD managers")
@Schema(description = "visible only to RCD managers")
manager,
@Schema("visible to RCD managers and to the community users")
@Schema(description = "visible to RCD managers and to the community users")
all
}

View File

@ -4,42 +4,42 @@ import java.util.Date;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunitySummary {
@Schema("identifies the community")
@Schema(description = "identifies the community")
protected String id;
@Schema("values for this field reflect the index field _community_ in the index, e.g. 'egi||EGI Federation'")
@Schema(description = "values for this field reflect the index field _community_ in the index, e.g. 'egi||EGI Federation'")
protected String queryId;
@Schema("community type")
@Schema(description = "community type")
protected String type;
@Schema("community name")
@Schema(description = "community name")
protected String name;
@Schema("community short name")
@Schema(description = "community short name")
protected String shortName;
@Schema("community creation date")
@Schema(description = "community creation date")
protected Date creationDate;
@Schema("community last update date")
@Schema(description = "community last update date")
protected Date lastUpdateDate;
@Schema("community description")
@Schema(description = "community description")
protected String description;
@Schema("http url for the community logo")
@Schema(description = "http url for the community logo")
protected String logoUrl;
@Schema("status of the community, drives its visibility")
@Schema(description = "status of the community, drives its visibility")
protected CommunityStatus status;
@Schema("Zenodo community associated to this community")
@Schema(description = "Zenodo community associated to this community")
protected String zenodoCommunity;
public CommunitySummary() {}

View File

@ -3,35 +3,35 @@ package eu.dnetlib.openaire.community;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunityWritableProperties {
@Schema("community name")
@Schema(description = "community name")
private String name;
@Schema("community short name")
@Schema(description = "community short name")
private String shortName;
@Schema("community description")
@Schema(description = "community description")
private String description;
@Schema("http url for the community logo")
@Schema(description = "http url for the community logo")
private String logoUrl;
@Schema("list of subjects (keywords) that characterise this community")
@Schema(description = "list of subjects (keywords) that characterise this community")
private List<String> subjects;
@Schema("status of the community, drives its visibility")
@Schema(description = "status of the community, drives its visibility")
private CommunityStatus status;
@Schema("id of the main Zenodo community")
@Schema(description = "id of the main Zenodo community")
private String mainZenodoCommunity;
public static CommunityWritableProperties fromDetails(final CommunityDetails details) {
CommunityWritableProperties p = new CommunityWritableProperties();
final CommunityWritableProperties p = new CommunityWritableProperties();
p.setName(details.getName());
p.setShortName(details.getShortName());
p.setDescription(details.getDescription());
@ -90,7 +90,11 @@ public class CommunityWritableProperties {
this.status = status;
}
public String getMainZenodoCommunity() { return mainZenodoCommunity; }
public void setMainZenodoCommunity(String mainZenodoCommunity) { this.mainZenodoCommunity = mainZenodoCommunity; }
public String getMainZenodoCommunity() {
return mainZenodoCommunity;
}
public void setMainZenodoCommunity(final String mainZenodoCommunity) {
this.mainZenodoCommunity = mainZenodoCommunity;
}
}

View File

@ -3,28 +3,29 @@ package eu.dnetlib.openaire.community;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
public class CommunityZenodoCommunity {
@NotNull
@Schema(value = "the community identifier this zenodo Community belongs to", required = true)
@Schema(description = "the community identifier this zenodo Community belongs to", required = true)
private String communityId;
@NotNull
@Schema(value = "Zenodo identifier for this community", required = true)
@Schema(description = "Zenodo identifier for this community", required = true)
private String zenodoid;
@NotNull
@Schema(value = "identifies this zenodo community within the context it belongs to", required = true)
@Schema(description = "identifies this zenodo community within the context it belongs to", required = true)
private String id;
public String getZenodoid() {
return zenodoid;
}
public void setZenodoid(String zenodoid) {
public void setZenodoid(final String zenodoid) {
this.zenodoid = zenodoid;
}
@ -40,7 +41,7 @@ public class CommunityZenodoCommunity {
return communityId;
}
public void setCommunityId(String communityId) {
public void setCommunityId(final String communityId) {
this.communityId = communityId;
}

View File

@ -3,83 +3,88 @@ package eu.dnetlib.openaire.context;
import java.util.List;
import java.util.Optional;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController
@CrossOrigin(origins = { "*" })
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.context", havingValue = "true")
@io.swagger.annotations.Api(tags = "OpenAIRE Context API", description = "the OpenAIRE Context API")
@Tag(name = "OpenAIRE Context API", description = "the OpenAIRE Context API")
public class ContextApiController {
@Autowired
private ContextApiCore contextApiCore;
@RequestMapping(value = "/contexts", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "list brief information about all the context profiles",
notes = "list brief information about all the context profiles.",
tags = { },
response = ContextSummary[].class)
@RequestMapping(value = "/contexts", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "list brief information about all the context profiles", description = "list brief information about all the context profiles")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ContextSummary[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) })
public List<ContextSummary> listContexts(@RequestParam(required = false, defaultValue = "") List<String> type) throws ContextException {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<ContextSummary> listContexts(@RequestParam(required = false, defaultValue = "") final List<String> type) throws ContextException {
return contextApiCore.listContexts(type);
}
@RequestMapping(value = "/context/{contextId}", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "list the categories defined within a context",
notes = "list the categories defined within a context",
tags = { },
response = CategorySummary[].class)
@RequestMapping(value = "/context/{contextId}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "list the categories defined within a context", description = "list the categories defined within a context")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CategorySummary[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CategorySummary> listCategories(
@PathVariable final String contextId,
@RequestParam(required = false, defaultValue = "false") final Boolean all) throws ContextException {
Boolean allFilter = Optional.ofNullable(all).orElse(false);
final Boolean allFilter = Optional.ofNullable(all).orElse(false);
return contextApiCore.listCategories(contextId, allFilter);
}
@RequestMapping(value = "/context/category/{categoryId}", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "list the concepts defined within a category",
notes = "list the concepts defined within a category",
tags = { },
response = ConceptSummary[].class)
@RequestMapping(value = "/context/category/{categoryId}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "list the concepts defined within a category", description = "list the concepts defined within a category")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ConceptSummary[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<ConceptSummary> listConcepts(
@PathVariable final String categoryId,
@RequestParam(required = false, defaultValue = "false") final Boolean all) throws ContextException {
Boolean allFilter = Optional.ofNullable(all).orElse(false);
final Boolean allFilter = Optional.ofNullable(all).orElse(false);
return contextApiCore.listConcepts(categoryId, allFilter);
}
@RequestMapping(value = "/context/category/concept/{conceptId}", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "list the concepts defined within a category",
notes = "list the concepts defined within a category",
tags = { },
response = ConceptSummary[].class)
@RequestMapping(value = "/context/category/concept/{conceptId}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "list the concepts defined within a category", description = "list the concepts defined within a category")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ConceptSummary[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<ConceptSummary> listSubConcepts(
@PathVariable final String conceptId,
@RequestParam(required = false, defaultValue = "false") final Boolean all) throws ContextException {
Boolean allFilter = Optional.ofNullable(all).orElse(false);
final Boolean allFilter = Optional.ofNullable(all).orElse(false);
return contextApiCore.listSubConcepts(conceptId, allFilter);
}

View File

@ -35,7 +35,6 @@ import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis;
import eu.dnetlib.openaire.dsm.domain.DatasourceResponse;
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse;
import eu.dnetlib.openaire.dsm.domain.RequestFilter;
import eu.dnetlib.openaire.dsm.domain.RequestSort;
@ -43,16 +42,17 @@ import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
import eu.dnetlib.openaire.dsm.domain.Response;
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
import eu.dnetlib.openaire.vocabularies.Country;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
@io.swagger.annotations.Api(tags = "OpenAIRE DSM API", description = "the OpenAIRE Datasource Manager API")
@Tag(name = "OpenAIRE DSM API", description = "the OpenAIRE Datasource Manager API")
public class DsmApiController extends AbstractExporterController {
@Autowired
@ -61,12 +61,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/countries", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "list the datasource countries", notes = "list the datasource countries", tags = {
@Operation(summary = "list the datasource countries", description = "list the datasource countries", tags = {
DS, R
}, response = Country[].class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = Country[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<Country> listCountries() throws DsmException {
return dsmCore.listCountries();
@ -75,12 +75,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/searchdetails/{page}/{size}", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "search datasources", notes = "Returns list of Datasource details.", tags = {
@Operation(summary = "search datasources", description = "Returns list of Datasource details.", tags = {
DS, R
}, response = DatasourceDetailResponse.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceDetailResponse.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public DatasourceDetailResponse searchDsDetails(
@RequestParam final RequestSort requestSortBy,
@ -96,12 +96,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/aggregationhistory/{dsId}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "search datasources", notes = "Returns list of Datasource details.", tags = {
@Operation(summary = "search datasources", description = "Returns list of Datasource details.", tags = {
DS, R
}, response = AggregationHistoryResponse.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = AggregationHistoryResponse.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public AggregationHistoryResponse aggregationHistory(@PathVariable final String dsId) throws DsmException {
final StopWatch stop = StopWatch.createStarted();
@ -112,12 +112,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/searchsnippet/{page}/{size}", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "search datasources", notes = "Returns list of Datasource basic info.", tags = {
@Operation(summary = "search datasources", description = "Returns list of Datasource basic info.", tags = {
DS, R
}, response = DatasourceSnippetResponse.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceSnippetResponse.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public DatasourceSnippetResponse searchSnippet(
@RequestParam final RequestSort requestSortBy,
@ -133,13 +133,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/searchregistered/{page}/{size}", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "search among registered datasources", notes = "Returns list of Datasource basic info.", tags = {
@Operation(summary = "search among registered datasources", description = "Returns list of Datasource basic info.", tags = {
DS,
R
}, response = DatasourceSnippetResponse.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceSnippetResponse.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public DatasourceSnippetResponse searchRegistered(
@RequestParam final RequestSort requestSortBy,
@ -155,13 +155,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/recentregistered/{size}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "return the latest datasources that were registered through Provide", notes = "Returns list of Datasource basic info.", tags = {
@Operation(summary = "return the latest datasources that were registered through Provide", description = "Returns list of Datasource basic info.", tags = {
DS,
R
}, response = SimpleResponse.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceResponse.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public SimpleResponse<?> recentRegistered(@PathVariable final int size) throws Throwable {
final StopWatch stop = StopWatch.createStarted();
@ -172,13 +172,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/countregistered", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "return the number of datasources registered after the given date", notes = "Returns a number.", tags = {
@Operation(summary = "return the number of datasources registered after the given date", description = "Returns a number.", tags = {
DS,
R
}, response = Long.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = Long.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public Long countRegistered(@RequestParam final String fromDate,
@RequestParam(required = false) final String typologyFilter) throws Throwable {
@ -188,13 +188,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/api/{dsId}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the list of API for a given datasource", notes = "Returns the list of API for a given datasource.", tags = {
@Operation(summary = "get the list of API for a given datasource", description = "Returns the list of API for a given datasource.", tags = {
API,
R
}, response = ApiDetailsResponse.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ApiDetailsResponse.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public ApiDetailsResponse getApi(
@PathVariable final String dsId) throws DsmException {
@ -207,12 +207,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/api/baseurl/{page}/{size}", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "search for the list of base URLs of Datasource APIs managed by a user", notes = "Returns the list of base URLs of Datasource APIs managed by a user", tags = {
@Operation(summary = "search for the list of base URLs of Datasource APIs managed by a user", description = "Returns the list of base URLs of Datasource APIs managed by a user", tags = {
DS, API, R
}, response = String[].class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<String> searchBaseUrls(
@RequestBody final RequestFilter requestFilter,
@ -223,26 +223,26 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/api/{apiId}", method = RequestMethod.DELETE)
@Operation(summary = "delete an API", notes = "delete an API, if removable", tags = {
@Operation(summary = "delete an API", description = "delete an API, if removable", tags = {
API, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Api not found", response = ErrorMessage.class),
@ApiResponse(responseCode = "403", description = "Api not removable", response = ErrorMessage.class),
@ApiResponse(responseCode = "500", description = "DSM Server error", response = ErrorMessage.class)
@ApiResponse(responseCode = "400", description = "Api not found"),
@ApiResponse(responseCode = "403", description = "Api not removable"),
@ApiResponse(responseCode = "500", description = "DSM Server error")
})
public void deleteApi(@PathVariable final String apiId) throws DsmForbiddenException, DsmNotFoundException {
dsmCore.deleteApi(apiId);
}
@RequestMapping(value = "/ds/manage", method = RequestMethod.POST)
@Operation(summary = "set the managed status for a given datasource", notes = "set the managed status for a given datasource", tags = {
@Operation(summary = "set the managed status for a given datasource", description = "set the managed status for a given datasource", tags = {
DS, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void setManaged(
@RequestParam final String id,
@ -252,25 +252,25 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/managed/{id}", method = RequestMethod.GET)
@Operation(summary = "get the datasource managed status", notes = "get the datasource managed status", tags = {
@Operation(summary = "get the datasource managed status", description = "get the datasource managed status", tags = {
DS, R
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public boolean isManaged(@PathVariable final String id) throws DsmException {
return dsmCore.isManaged(id);
}
@RequestMapping(value = "/ds/add", method = RequestMethod.POST)
@Operation(summary = "add a new Datasource", notes = "add a new Datasource", tags = {
@Operation(summary = "add a new Datasource", description = "add a new Datasource", tags = {
DS, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Malformed request", response = ErrorMessage[].class),
@ApiResponse(responseCode = "500", description = "Unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "400", description = "Malformed request"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException {
@ -281,13 +281,13 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/addWithApis", method = RequestMethod.POST)
@Operation(summary = "add a new Datasource and its apis", notes = "add a new Datasource and its apis", tags = {
@Operation(summary = "add a new Datasource and its apis", description = "add a new Datasource and its apis", tags = {
DS, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Malformed request", response = ErrorMessage[].class),
@ApiResponse(responseCode = "500", description = "Unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "400", description = "Malformed request"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmException {
if (d.getDatasource() == null) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "Datasource field is null"); }
@ -298,12 +298,12 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/update", method = RequestMethod.POST)
@Operation(summary = "update Datasource details", notes = "update Datasource details", tags = {
@Operation(summary = "update Datasource details", description = "update Datasource details", tags = {
DS, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void updateDatasource(
@RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException {
@ -312,12 +312,12 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/api/baseurl", method = RequestMethod.POST)
@Operation(summary = "update the base URL of a datasource interface", notes = "update the base URL of a datasource interface", tags = {
@Operation(summary = "update the base URL of a datasource interface", description = "update the base URL of a datasource interface", tags = {
API, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void updateBaseUrl(
@RequestParam final String dsId,
@ -328,12 +328,12 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/api/compliance", method = RequestMethod.POST)
@Operation(summary = "update the compatibility of a datasource interface", notes = "update the compatibility of a datasource interface", tags = {
@Operation(summary = "update the compatibility of a datasource interface", description = "update the compatibility of a datasource interface", tags = {
API, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void updateCompliance(
@RequestParam final String dsId,
@ -345,12 +345,12 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/api/oaiset", method = RequestMethod.POST)
@Operation(summary = "update the OAI set of a datasource interface", notes = "update the OAI set of a datasource interface", tags = {
@Operation(summary = "update the OAI set of a datasource interface", description = "update the OAI set of a datasource interface", tags = {
API, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void updateOaiSetl(
@RequestParam final String dsId,
@ -361,12 +361,12 @@ public class DsmApiController extends AbstractExporterController {
}
@RequestMapping(value = "/ds/api/add", method = RequestMethod.POST)
@Operation(summary = "adds a new Interface to one Datasource", notes = "adds an Interface to one Datasource", tags = {
@Operation(summary = "adds a new Interface to one Datasource", description = "adds an Interface to one Datasource", tags = {
API, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void addApi(@RequestBody final ApiDetails api) throws DsmException {
if (StringUtils.isBlank(api.getDatasource())) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); }
@ -379,36 +379,36 @@ public class DsmApiController extends AbstractExporterController {
private OperationManager operationManager;
@RequestMapping(value = "/dsm/ops", method = RequestMethod.GET)
@Operation(summary = "get the number of pending operations", notes = "get the number of pending operations", tags = {
@Operation(summary = "get the number of pending operations", description = "get the number of pending operations", tags = {
R, M
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public int getOps() throws DsmException {
return operationManager.getOpSize();
}
@RequestMapping(value = "/dsm/killops", method = RequestMethod.POST)
@Operation(summary = "interrupts the pending operations", notes = "return the number of interrupted operations", tags = {
@Operation(summary = "interrupts the pending operations", description = "return the number of interrupted operations", tags = {
W, M
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public int killOps() throws DsmException {
return operationManager.dropAll();
}
@RequestMapping(value = "/dsm/dropcache", method = RequestMethod.POST)
@Operation(summary = "drop the caches", notes = "drop the internal caches", tags = {
@Operation(summary = "drop the caches", description = "drop the internal caches", tags = {
W, M
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void dropCache() throws DsmException {
dsmCore.dropCaches();

View File

@ -1,20 +1,20 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class AggregationHistoryResponse extends Response {
@Schema(position = 1)
@Schema
private List<AggregationInfo> aggregationInfo;
public AggregationHistoryResponse(List<AggregationInfo> aggregationInfo) {
public AggregationHistoryResponse(final List<AggregationInfo> aggregationInfo) {
super();
this.aggregationInfo = aggregationInfo;
}
@ -23,7 +23,7 @@ public class AggregationHistoryResponse extends Response {
return aggregationInfo;
}
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
public void setAggregationInfo(final List<AggregationInfo> aggregationInfo) {
this.aggregationInfo = aggregationInfo;
}
}

View File

@ -5,65 +5,64 @@ import java.util.Set;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Api model", description = "provides information about the datasource API")
@Schema(name = "Api model", description = "provides information about the datasource API")
public class ApiDetails extends ApiIgnoredProperties {
@Schema(position = 0)
@Schema
private String id = null;
@Schema(position = 1)
@Schema
private String protocol = null;
@Schema(position = 2)
@Schema
private String datasource = null;
@Schema(position = 3)
@Schema
private String contentdescription = null;
@Schema(position = 4)
@Schema
private String eoscDatasourceType = null;
@Schema(position = 5)
@Schema
private String compatibility;
@Schema(position = 7)
@Schema
private String compatibilityOverride;
@Schema(position = 8)
@Schema
private Integer lastCollectionTotal;
@Schema(position = 9)
@Schema
private Date lastCollectionDate;
@Schema(position = 10)
@Schema
private Integer lastAggregationTotal;
@Schema(position = 11)
@Schema
private Date lastAggregationDate;
@Schema(position = 12)
@Schema
private Integer lastDownloadTotal;
@Schema(position = 13)
@Schema
private Date lastDownloadDate;
@Schema(position = 14)
@Schema
private String baseurl;
@Schema(position = 15)
@Schema
protected Boolean removable = false;
@Schema(position = 16)
@Schema
private Set<ApiParamDetails> apiParams;
@Schema(position = 17)
@Schema
private String metadataIdentifierPath = "";
@Schema(position = 18)
@Schema
private String typology = null;
public String getId() {

View File

@ -3,14 +3,14 @@ package eu.dnetlib.openaire.dsm.domain;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class ApiDetailsResponse extends Response {
@Schema(position = 1)
@Schema
private List<ApiDetails> api;
public List<ApiDetails> getApi() {

View File

@ -3,7 +3,7 @@ package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 29/11/2016.

View File

@ -1,7 +1,8 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 12/09/16.
@ -9,5 +10,6 @@ import io.swagger.annotations.ApiModel;
@Schema
@JsonAutoDetect
public enum CollectionMode {
REFRESH, INCREMENTAL
REFRESH,
INCREMENTAL
}

View File

@ -1,19 +1,19 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class DatasourceDetailResponse extends Response {
@Schema(position = 1)
@Schema
private List<DatasourceDetails> datasourceInfo;
public DatasourceDetailResponse(List<DatasourceDetails> datasourceInfo) {
public DatasourceDetailResponse(final List<DatasourceDetails> datasourceInfo) {
super();
this.datasourceInfo = datasourceInfo;
}
@ -22,7 +22,7 @@ public class DatasourceDetailResponse extends Response {
return datasourceInfo;
}
public void setDatasourceInfo(List<DatasourceDetails> datasourceInfo) {
public void setDatasourceInfo(final List<DatasourceDetails> datasourceInfo) {
this.datasourceInfo = datasourceInfo;
}
}

View File

@ -9,128 +9,127 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 12/09/16.
*/
@JsonAutoDetect
@Schema(value = "Datasource model", description = "provides information about the datasource")
@Schema(name = "Datasource model", description = "provides information about the datasource")
public class DatasourceDetails extends DatasourceIgnoredProperties {
@NotBlank
@Schema(position = 0)
@Schema
private String id;
@Transient
@Schema(position = 1)
@Schema
private String openaireId;
@NotBlank
@Schema(position = 2)
@Schema
private String officialname;
@NotBlank
@Schema(position = 3)
@Schema
private String englishname;
@Schema(position = 4)
@Schema
private String websiteurl;
@Schema(position = 5)
@Schema
private String logourl;
@Email
@Schema(position = 6)
@Schema
private String contactemail;
@Schema(position = 7)
@Schema
private Double latitude;
@Schema(position = 8)
@Schema
private Double longitude;
@Schema(position = 9)
@Schema
private String timezone;
@NotBlank
@Schema(position = 10)
@Schema
private String namespaceprefix;
@Schema(position = 11)
@Schema
private String languages;
@Schema(position = 12)
@Schema
private Date dateofvalidation;
@NotBlank
@Schema(position = 13)
@Schema
private String eoscDatasourceType;
@Schema(position = 14)
@Schema
private Date dateofcollection;
@Schema(position = 15)
@Schema
private String platform;
@Schema(position = 16)
@Schema
private String activationId;
@Schema(position = 17)
@Schema
private String description;
@Schema(position = 18)
@Schema
private String issn;
@Schema(position = 19)
@Schema
private String eissn;
@Schema(position = 20)
@Schema
private String lissn;
@Email
@Schema(position = 21)
@Schema
private String registeredby;
@Schema(position = 22)
@Schema
private String subjects;
@Schema(position = 23)
@Schema
protected String aggregator = "OPENAIRE";
@Schema(position = 24)
@Schema
protected String collectedfrom;
@Schema(position = 25)
@Schema
private Boolean managed;
@Schema(position = 28)
@Schema
private Boolean consentTermsOfUse;
@Schema(position = 29)
@Schema
private Boolean fullTextDownload;
@Schema(position = 30)
@Schema
private Date consentTermsOfUseDate;
@Schema(position = 31)
@Schema
private Date lastConsentTermsOfUseDate;
@Schema(position = 26)
@Schema
private Set<OrganizationDetails> organizations;
@Schema(position = 27)
@Schema
private Set<IdentitiesDetails> identities;
@Schema(position = 32)
@Schema
private String status;
@Deprecated
@Schema(position = 33)
@Schema
private String typology;
@Schema(position = 34)
@Schema
private Date registrationdate;
public String getId() {

View File

@ -8,80 +8,79 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 12/09/16.
*/
@JsonAutoDetect
@Schema(value = "Datasource updatable fields model", description = "provides information about the datasource field that can be updated")
@Schema(name = "Datasource updatable fields model", description = "provides information about the datasource field that can be updated")
public class DatasourceDetailsUpdate {
@NotBlank
@Schema(position = 0)
@Schema
private String id;
@NotBlank
@Schema(position = 2)
@Schema
private String officialname;
@NotBlank
@Schema(position = 3)
@Schema
private String englishname;
@Schema(position = 4)
@Schema
private String websiteurl;
@Schema(position = 5)
@Schema
private String logourl;
@Email
@Schema(position = 6)
@Schema
private String contactemail;
@Schema(position = 7)
@Schema
private Double latitude;
@Schema(position = 8)
@Schema
private Double longitude;
@Schema(position = 9)
@Schema
private String timezone;
@Deprecated
@Schema(position = 12)
@Schema
private String typology;
@Schema(position = 13)
@Schema
private String eoscDatasourceType;
@Schema(position = 15)
@Schema
private String platform;
@Schema(position = 17)
@Schema
private String description;
@Email
@Schema(position = 21)
@Schema
private String registeredby;
@Schema(position = 25)
@Schema
private Boolean managed;
@Schema(position = 27)
@Schema
private Set<IdentitiesDetails> identities;
@Schema(position = 28)
@Schema
private Boolean consentTermsOfUse;
@Schema(position = 29)
@Schema
private Date consentTermsOfUseDate;
@Schema(position = 29)
@Schema
private Date lastConsentTermsOfUseDate;
@Schema(position = 31)
@Schema
private Boolean fullTextDownload;
public String getId() {

View File

@ -5,19 +5,21 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 12/09/16.
*/
@JsonAutoDetect
@Schema(value = "Datasource model with apis", description = "provides information about the datasource and its apis")
@Schema(name = "Datasource model with apis", description = "provides information about the datasource and its apis")
public class DatasourceDetailsWithApis {
@Schema(position = 1)
@Schema
private DatasourceDetails datasource;
@Schema
private List<ApiDetails> apis = new ArrayList<>();
public DatasourceDetails getDatasource() {
return datasource;
}
@ -26,9 +28,6 @@ public class DatasourceDetailsWithApis {
this.datasource = datasource;
}
@Schema(position = 2)
private List<ApiDetails> apis = new ArrayList<>();
public List<ApiDetails> getApis() {
return apis;
}

View File

@ -3,39 +3,39 @@ package eu.dnetlib.openaire.dsm.domain;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Datasource info model", description = "provides information about the datasource and its aggregation status")
@Schema(name = "Datasource info model", description = "provides information about the datasource and its aggregation status")
public class DatasourceInfo {
@Schema(position = 0)
@Schema
private long indexRecords;
@Schema(position = 1)
@Schema
private long fundedContent;
@Schema(position = 2)
@Schema
private long fulltexts;
@Schema(position = 3)
@Schema
private String lastIndexingDate;
@Schema(position = 4)
@Schema
private String firstHarvestDate;
@Schema(position = 5)
@Schema
private DatasourceDetails datasource;
@Schema(position = 6)
@Schema
private AggregationInfo lastCollection;
@Schema(position = 7)
@Schema
private AggregationInfo lastTransformation;
@Schema(position = 8)
@Schema
private List<AggregationInfo> aggregationHistory;
public DatasourceInfo() {

View File

@ -4,7 +4,8 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect

View File

@ -1,19 +1,19 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class DatasourceSearchResponse extends Response {
@Schema(position = 1)
@Schema
private List<DatasourceInfo> datasourceInfo;
public DatasourceSearchResponse(List<DatasourceInfo> datasourceInfo) {
public DatasourceSearchResponse(final List<DatasourceInfo> datasourceInfo) {
super();
this.datasourceInfo = datasourceInfo;
}
@ -22,7 +22,7 @@ public class DatasourceSearchResponse extends Response {
return datasourceInfo;
}
public void setDatasourceInfo(List<DatasourceInfo> datasourceInfo) {
public void setDatasourceInfo(final List<DatasourceInfo> datasourceInfo) {
this.datasourceInfo = datasourceInfo;
}
}

View File

@ -4,23 +4,22 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Datasource model", description = "provides information about the datasource")
@Schema(name = "Datasource model", description = "provides information about the datasource")
public class DatasourceSnippet {
@NotBlank
@Schema(position = 0)
@Schema
private String id;
@NotBlank
@Schema(position = 2)
@Schema
private String officialname;
@NotBlank
@Schema(position = 3)
@Schema
private String englishname;
public String getId() {

View File

@ -8,61 +8,60 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Datasource model", description = "provides extended information about the datasource")
@Schema(name = "Datasource model", description = "provides extended information about the datasource")
public class DatasourceSnippetExtended {
@NotBlank
@Schema(position = 0)
@Schema
private String id;
@NotBlank
@Schema(position = 2)
@Schema
private String officialname;
@NotBlank
@Schema(position = 3)
@Schema
private String englishname;
@Schema(position = 4)
@Schema
private String websiteurl;
@Email
@Schema(position = 5)
@Schema
private String registeredby;
@Schema(position = 6)
@Schema
private Date registrationdate;
@Schema(position = 7)
@Schema
private String eoscDatasourceType;
@Schema(position = 8)
@Schema
private String logoUrl;
@Schema(position = 9)
@Schema
private String description;
@Schema(position = 10)
@Schema
private Boolean consentTermsOfUse;
@Schema(position = 11)
@Schema
private Date consentTermsOfUseDate;
@Schema(position = 12)
@Schema
private Date lastConsentTermsOfUseDate;
@Schema(position = 13)
@Schema
private Boolean fullTextDownload;
@Schema(position = 14)
@Schema
private Set<OrganizationDetails> organizations;
@Deprecated
@Schema(position = 15)
@Schema
private String typology;
public String getId() {

View File

@ -1,19 +1,19 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class DatasourceSnippetResponse extends Response {
@Schema(position = 1)
@Schema
private List<DatasourceSnippetExtended> datasourceInfo;
public DatasourceSnippetResponse(List<DatasourceSnippetExtended> datasourceInfo) {
public DatasourceSnippetResponse(final List<DatasourceSnippetExtended> datasourceInfo) {
super();
this.datasourceInfo = datasourceInfo;
}
@ -22,7 +22,7 @@ public class DatasourceSnippetResponse extends Response {
return datasourceInfo;
}
public void setDatasourceInfo(List<DatasourceSnippetExtended> datasourceInfo) {
public void setDatasourceInfo(final List<DatasourceSnippetExtended> datasourceInfo) {
this.datasourceInfo = datasourceInfo;
}
}

View File

@ -2,10 +2,10 @@ package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Filter name", description = "List of the field names used to filter datasources")
@Schema(name = "Filter name", description = "List of the field names used to filter datasources")
public enum FilterName {
id,

View File

@ -8,29 +8,29 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.google.gson.GsonBuilder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class Header {
@Schema(position = 0)
@Schema
private long total;
@Schema(position = 1)
@Schema
private int page;
@Schema(position = 2)
@Schema
private int size;
@Schema(position = 3)
@Schema
private long time;
@Schema(position = 4)
@Schema
private int statusCode;
@Schema(position = 5)
@Schema
private List<String> errors = Lists.newArrayList();
@JsonIgnore
@ -40,8 +40,7 @@ public class Header {
return new Header();
}
public Header() {
}
public Header() {}
public long getTime() {
return time;

View File

@ -1,7 +1,8 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect

View File

@ -4,28 +4,27 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Organization info model", description = "provides information about the organization")
@Schema(name = "Organization info model", description = "provides information about the organization")
public class OrganizationDetails extends OrganizationIgnoredProperties {
@Schema(position = 0)
@Schema
private String legalshortname;
@NotBlank
@Schema(position = 1)
@Schema
private String legalname;
@Schema(position = 2)
@Schema
private String websiteurl;
@Schema(position = 3)
@Schema
private String logourl;
@NotBlank
@Schema(position = 4)
@Schema
private String country;
public String getLegalshortname() {

View File

@ -4,10 +4,10 @@ import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(value = "Request filter", description = "field name and value pairs")
@Schema(name = "Request filter", description = "field name and value pairs")
public class RequestFilter extends HashMap<FilterName, Object> {
/**

View File

@ -1,16 +1,14 @@
package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect
@Schema(
value = "Api response model",
description = "Api response model, provides a response header")
@Schema(name = "Api response model", description = "Api response model, provides a response header")
public class Response {
@Schema(position = 0)
@Schema
private Header header;
public Response() {

View File

@ -4,14 +4,13 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@Schema
@JsonAutoDetect
public class SimpleResponse<T> extends Response {
@Schema(position = 1)
@Schema
private List<T> response;
public List<T> getResponse() {

View File

@ -3,7 +3,7 @@ package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 29/11/2016.

View File

@ -6,8 +6,9 @@ import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.dnetlib.enabling.datasources.common.ApiParam;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 13/04/2017.
@ -15,7 +16,7 @@ import io.swagger.annotations.ApiModel;
@Entity
@Table(name = "dsm_apiparams")
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(value = "Datasource Api params model", description = "describes the datasource api params")
@Schema(name = "Datasource Api params model", description = "describes the datasource api params")
public class ApiParamDbEntry implements ApiParam {
@EmbeddedId
@ -35,10 +36,12 @@ public class ApiParamDbEntry implements ApiParam {
return id;
}
@Override
public String getValue() {
return value;
}
@Override
public void setValue(final String value) {
this.value = value;
}

View File

@ -7,7 +7,7 @@ import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.BrowseTerm;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 20/04/2017.
@ -27,6 +27,7 @@ public class CountryTerm implements Comparable<CountryTerm>, BrowseTerm {
return term;
}
@Override
public void setTerm(final String term) {
this.term = term;
}
@ -36,6 +37,7 @@ public class CountryTerm implements Comparable<CountryTerm>, BrowseTerm {
return total;
}
@Override
public void setTotal(final long total) {
this.total = total;
}

View File

@ -8,12 +8,12 @@ import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
@Entity
@JsonAutoDetect
@Table(name = "dsm_datasource_api")
@Schema(value = "DatasourceApi model", description = "describes a joint view between datasources and their API (1:N)")
@Schema(name = "DatasourceApi model", description = "describes a joint view between datasources and their API (1:N)")
public class DatasourceApiDbEntry {
@Id

View File

@ -2,23 +2,31 @@ package eu.dnetlib.openaire.funders;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails;
import eu.dnetlib.openaire.funders.domain.FunderDetails;
import eu.dnetlib.openaire.funders.domain.db.FunderDbEntry;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController
@CrossOrigin(origins = { "*" })
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.funders", havingValue = "true")
@io.swagger.annotations.Api(tags = "OpenAIRE funders API", description = "the OpenAIRE funders API")
@Tag(name = "OpenAIRE funders API", description = "the OpenAIRE funders API")
public class FundersApiController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(FundersApiController.class);
@ -26,14 +34,14 @@ public class FundersApiController extends AbstractExporterController {
@Autowired
private FunderDao fDao;
@RequestMapping(value = "/funders", produces = { "application/json" }, method = RequestMethod.GET)
@Operation(
value = "get basic information about funders",
notes = "basic information about funders: id, name, shortname, last update date, registration date",
response = FunderDetails[].class)
@RequestMapping(value = "/funders", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(value = "get basic information about funders", notes = "basic information about funders: id, name, shortname, last update date, registration date", response = FunderDetails[].class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = FunderDetails[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public List<FunderDetails> getFunders(
@PathVariable final int page,
@PathVariable final int size) throws FundersApiException {
@ -41,26 +49,31 @@ public class FundersApiController extends AbstractExporterController {
return fDao.listFunderDetails(page, size);
}
@RequestMapping(value = "/funder/{id}", produces = { "application/json" }, method = RequestMethod.GET)
@RequestMapping(value = "/funder/{id}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the funder details", notes = "complete funder information", response = FunderDbEntry.class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = FunderDbEntry.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public ExtendedFunderDetails getFunderDetails(
@PathVariable final String id) throws FundersApiException {
return fDao.getExtendedFunderDetails(id);
}
@RequestMapping(value = "/funder/ids", produces = { "application/json" }, method = RequestMethod.GET)
@RequestMapping(value = "/funder/ids", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the list of funder ids", notes = "get the list of funder ids", response = String[].class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public List<String> getFunderIds(
@PathVariable final int page,
@PathVariable final int size
) throws FundersApiException {
@PathVariable final int size) throws FundersApiException {
return fDao.listFunderIds(page, size);
}

View File

@ -19,16 +19,17 @@ import com.google.common.collect.Maps;
import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.common.ExporterConstants;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.info", havingValue = "true")
@io.swagger.annotations.Api(tags = "OpenAIRE Info API", description = "the OpenAIRE info API")
@Tag(name = "OpenAIRE Info API", description = "the OpenAIRE info API")
public class InfoController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(InfoController.class); // NOPMD by marko on 11/24/08 5:02 PM
@ -41,12 +42,12 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info/{infoKey}", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get info date", notes = "get info date", tags = {
@Operation(summary = "get info date", description = "get info date", tags = {
ExporterConstants.R
}, response = LocalDate.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = LocalDate.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public LocalDate getDate(@PathVariable final String infoKey) {
final JdbcInfoDao.DATE_INFO info = JdbcInfoDao.DATE_INFO.valueOf(infoKey);
@ -57,12 +58,12 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get all the info date", notes = "get all the info date", tags = {
@Operation(summary = "get all the info date", description = "get all the info date", tags = {
ExporterConstants.R
}, response = Map.class)
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = LocalDate.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public Map<String, LocalDate> listInfo() {
final Map<String, LocalDate> map = Maps.newHashMap();
@ -75,12 +76,12 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info/keys", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "get the available keys", notes = "get the available keys", tags = {
@Operation(summary = "get the available keys", description = "get the available keys", tags = {
ExporterConstants.R
}, response = String.class, responseContainer = "List")
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = LocalDate.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<String> listInfoKeys() {
final List<String> keys = Lists.newArrayList();
@ -93,7 +94,7 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info/dropCache", produces = {
"application/json"
}, method = RequestMethod.GET)
@Operation(summary = "Drops the info cache", notes = "Drops the info cache", tags = {
@Operation(summary = "Drops the info cache", description = "Drops the info cache", tags = {
ExporterConstants.R
})
public void dropCache() {

View File

@ -8,22 +8,11 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.zip.ZipOutputStream;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.common.xml.XmlEscapers;
import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.DnetOpenaireExporterProperties.Project;
import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.common.ExporterConstants;
import eu.dnetlib.openaire.project.domain.db.ProjectTsv;
import eu.dnetlib.openaire.project.domain.db.ProjectDetails;
import eu.dnetlib.openaire.project.dao.JdbcApiDao;
import eu.dnetlib.openaire.project.dao.ValueCleaner;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.antlr.stringtemplate.StringTemplate;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@ -38,10 +27,27 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.google.common.xml.XmlEscapers;
import eu.dnetlib.DnetOpenaireExporterProperties;
import eu.dnetlib.DnetOpenaireExporterProperties.Project;
import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.common.ExporterConstants;
import eu.dnetlib.openaire.project.dao.JdbcApiDao;
import eu.dnetlib.openaire.project.dao.ValueCleaner;
import eu.dnetlib.openaire.project.domain.db.ProjectDetails;
import eu.dnetlib.openaire.project.domain.db.ProjectTsv;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@Controller
@CrossOrigin(origins = { "*" })
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.project", havingValue = "true")
@io.swagger.annotations.Api(tags = "OpenAIRE projects API", description = "the OpenAIRE projects API")
@Tag(name = "OpenAIRE projects API", description = "the OpenAIRE projects API")
public class ProjectsController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(ProjectsController.class); // NOPMD by marko on 11/24/08 5:02 PM
@ -58,15 +64,15 @@ public class ProjectsController extends AbstractExporterController {
private ProjectQueryParamsFactory projectQueryParamsFactory;
@RequestMapping(value = "/export/**/project/dspace.do", method = RequestMethod.GET)
@Operation(
value = "DSpace",
notes = "return project information in compatible with the OpenAIRE plugin for DSpace",
tags = { ExporterConstants.DSPACE },
response = String.class)
@Operation(value = "DSpace", notes = "return project information in compatible with the OpenAIRE plugin for DSpace", tags = {
ExporterConstants.DSPACE
}, response = String.class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
public void processDspace(final HttpServletRequest request, final ServletResponse response,
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public void processDspace(final HttpServletRequest request,
final ServletResponse response,
@RequestParam(value = "startFrom", required = false) final String startFrom,
@RequestParam(value = "startUntil", required = false) final String startUntil,
@RequestParam(value = "endFrom", required = false) final String endFrom,
@ -86,15 +92,15 @@ public class ProjectsController extends AbstractExporterController {
}
@RequestMapping(value = "/export/**/project/eprints.do", method = RequestMethod.GET)
@Operation(
value = "EPrints",
notes = "return project information in compatible with the OpenAIRE plugin for Eprints",
tags = { ExporterConstants.EPRINT },
response = String.class)
@Operation(value = "EPrints", notes = "return project information in compatible with the OpenAIRE plugin for Eprints", tags = {
ExporterConstants.EPRINT
}, response = String.class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String.class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
public void processEprints(final HttpServletRequest request, final ServletResponse response,
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public void processEprints(final HttpServletRequest request,
final ServletResponse response,
@RequestParam(value = "startFrom", required = false) final String startFrom,
@RequestParam(value = "startUntil", required = false) final String startUntil,
@RequestParam(value = "endFrom", required = false) final String endFrom,
@ -112,7 +118,9 @@ public class ProjectsController extends AbstractExporterController {
private void doProcess(
final ServletResponse response,
final ProjectQueryParams params,
final String head, final Resource projectTemplate, final String tail,
final String head,
final Resource projectTemplate,
final String tail,
final ValueCleaner cleaner) throws IOException, SQLException {
final StringTemplate st = new StringTemplate(IOUtils.toString(projectTemplate.getInputStream(), UTF8));
@ -122,14 +130,13 @@ public class ProjectsController extends AbstractExporterController {
}
@RequestMapping(value = "/noads/project2tsv.do", method = RequestMethod.GET)
@Operation(
value = "TSV",
notes = "download project information in TSV format",
tags = { ExporterConstants.TSV },
response = ProjectTsv[].class)
@Operation(value = "TSV", notes = "download project information in TSV format", tags = {
ExporterConstants.TSV
}, response = ProjectTsv[].class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ProjectTsv[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public void processTsv(final HttpServletResponse response,
@RequestParam(value = "funding", required = true) final String funding,
@RequestParam(value = "article293", required = false) final Boolean article293) throws Exception {
@ -142,20 +149,19 @@ public class ProjectsController extends AbstractExporterController {
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + ".zip\"");
try (final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()))) {
dao.processTsvRequest(out, article293, fundingPrefix, filename);
} catch (Throwable e) {
} catch (final Throwable e) {
throw new RuntimeException("Error processing the request", e);
}
}
@RequestMapping(value = "/export/streamProjectDetails.do", method = RequestMethod.GET)
@Operation(
value = "Stream projects",
notes = "stream project information",
tags = { ExporterConstants.STREAMING },
response = ProjectDetails[].class)
@Operation(value = "Stream projects", notes = "stream project information", tags = {
ExporterConstants.STREAMING
}, response = ProjectDetails[].class)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ProjectDetails[].class),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) })
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class)
})
public void streamProjectDetails(final HttpServletResponse response,
@RequestParam(value = "format", required = true) final String format,
@RequestParam(value = "compress", required = false) final Boolean compress) throws IOException, SQLException {
@ -170,7 +176,8 @@ public class ProjectsController extends AbstractExporterController {
case "json":
response.setContentType("text/plain");
break;
default: throw new IllegalArgumentException("unsupported format: " + format);
default:
throw new IllegalArgumentException("unsupported format: " + format);
}
dao.processProjectDetails(response.getOutputStream(), format, compress);
@ -190,22 +197,20 @@ public class ProjectsController extends AbstractExporterController {
* if the funding program is not recognized
*/
protected String obtainQuery(final ProjectQueryParams params) throws IllegalArgumentException, IOException {
String funding = params.getFundingProgramme();
String suffix = params.getFundingPath();
final String funding = params.getFundingProgramme();
final String suffix = params.getFundingPath();
final StringTemplate st = new StringTemplate(IOUtils.toString(config.getProject().getProjectsFundingQueryTemplate().getInputStream(), UTF8));
st.setAttribute("fundingprefix", getFundingPrefix(funding, suffix));
String theQuery = setDateParameters(st.toString(), params);
final String theQuery = setDateParameters(st.toString(), params);
log.debug("Generated query: " + theQuery);
return theQuery;
}
private String getFundingPrefix(final String funding, final String suffix) {
final Map<String, String> fundingIds = dao.readFundingpathIds();
if (!fundingIds.containsKey(funding.toUpperCase())) {
throw new IllegalArgumentException("invalid funding " + funding);
}
String fundingPrefix = fundingIds.get(funding.toUpperCase());
if (!fundingIds.containsKey(funding.toUpperCase())) { throw new IllegalArgumentException("invalid funding " + funding); }
final String fundingPrefix = fundingIds.get(funding.toUpperCase());
return StringUtils.isBlank(suffix) ? fundingPrefix : fundingPrefix + "::" + suffix.toUpperCase();
}

View File

@ -2,22 +2,25 @@ package eu.dnetlib.openaire.project.domain.db;
import java.sql.Date;
import java.util.ArrayList;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import org.apache.commons.lang3.StringUtils;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 20/09/16.
*/
@Entity
@Table(name = "projects_api")
@Schema(value = "Project api model", description = "Project api model used by DSpace and Eprints exporter")
@Schema(name = "Project api model", description = "Project api model used by DSpace and Eprints exporter")
public class ProjectApi {
public static final String INFO_EU_REPO_GRANT_AGREEMENT = "info:eu-repo/grantAgreement/";
@ -69,9 +72,12 @@ public class ProjectApi {
private String asFundingProgram(final String fundingpathid) {
final ArrayList<String> strings = Lists.newArrayList(Splitter.on("::").split(fundingpathid));
if(strings.size() <= 1) throw new IllegalStateException("Unexpected funding id: "+fundingpathid);
if(strings.size() == 2) return "";
else return replaceSlash(strings.get(2));
if (strings.size() <= 1) { throw new IllegalStateException("Unexpected funding id: " + fundingpathid); }
if (strings.size() == 2) {
return "";
} else {
return replaceSlash(strings.get(2));
}
}
private String replaceSlash(final String s) {

View File

@ -6,28 +6,33 @@ import java.io.StringWriter;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.Gson;
import io.swagger.annotations.ApiModel;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.cellprocessor.ift.StringCellProcessor;
import org.supercsv.io.CsvBeanReader;
import org.supercsv.io.CsvBeanWriter;
import org.supercsv.io.ICsvBeanReader;
import org.supercsv.io.ICsvBeanWriter;
import org.supercsv.prefs.CsvPreference;
import org.supercsv.util.CsvContext;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.Gson;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 04/07/2017.
*/
@Entity
@Table(name = "project_details")
@Schema(value = "Project details model", description = "provides project details")
@Schema(name = "Project details model", description = "provides project details")
public class ProjectDetails {
@Transient
@ -50,8 +55,7 @@ public class ProjectDetails {
@Column(name = "fundingpath", columnDefinition = "text[]")
private String[] fundingPath;
public ProjectDetails() {
}
public ProjectDetails() {}
public String getProjectId() {
return projectId;
@ -85,18 +89,13 @@ public class ProjectDetails {
public static ProjectDetails fromCSV(final String csv) throws IOException {
try (ICsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), CsvPreference.STANDARD_PREFERENCE)) {
return beanReader.read(ProjectDetails.class, FIELDS, getProcessors(new StringCellProcessor() {
@Override
public Object execute(final Object value, final CsvContext context) {
return new Gson().fromJson(value.toString(), List.class);
}
}));
return beanReader.read(ProjectDetails.class, FIELDS, getProcessors((value, context) -> new Gson().fromJson(value.toString(), List.class)));
}
}
/**
* Sets up the processors used for the examples. There are 10 CSV columns, so 10 processors are defined. Empty
* columns are read as null (hence the NotNull() for mandatory columns).
* Sets up the processors used for the examples. There are 10 CSV columns, so 10 processors are defined. Empty columns are read as null
* (hence the NotNull() for mandatory columns).
*
* @return the cell processors
*/
@ -117,12 +116,7 @@ public class ProjectDetails {
public String asCSV() throws IOException {
final StringWriter sb = new StringWriter();
try (ICsvBeanWriter beanWriter = new CsvBeanWriter(sb, CsvPreference.STANDARD_PREFERENCE)) {
beanWriter.write(this, FIELDS, getProcessors(new StringCellProcessor() {
@Override
public Object execute(final Object value, final CsvContext context) {
return new Gson().toJson(value);
}
}));
beanWriter.write(this, FIELDS, getProcessors((value, context) -> new Gson().toJson(value)));
beanWriter.flush();
}

View File

@ -2,22 +2,25 @@ package eu.dnetlib.openaire.project.domain.db;
import java.sql.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import org.apache.commons.lang3.StringUtils;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Created by claudio on 05/07/2017.
*/
@Entity
@Table(name = "projects_tsv")
@Schema(value = "Project TSV model", description = "project TSV model description")
@Schema(name = "Project TSV model", description = "project TSV model description")
public class ProjectTsv {
@Id
@ -51,21 +54,10 @@ public class ProjectTsv {
public ProjectTsv() {}
public List<String> asList() {
return Lists.newArrayList(
clean(getCode()),
clean(getAcronym()),
clean(getTitle()),
clean(getCallIdentifier()),
clean(getStartdate() != null ? getStartdate().toString() : ""),
clean(getEnddate() != null ? getEnddate().toString() : ""),
clean(String.valueOf(isOaMandateForPublications())),
clean(String.valueOf(isOaMandateForDatasets())),
clean(getDescription()),
clean(getOrgLegalname()),
clean(getOrgCountry()),
clean(getOrgRole()),
clean(getContactfullname()),
clean(getContactemail()));
return Lists.newArrayList(clean(getCode()), clean(getAcronym()), clean(getTitle()), clean(getCallIdentifier()), clean(getStartdate() != null
? getStartdate().toString()
: ""), clean(getEnddate() != null ? getEnddate().toString() : ""), clean(String.valueOf(isOaMandateForPublications())), clean(String
.valueOf(isOaMandateForDatasets())), clean(getDescription()), clean(getOrgLegalname()), clean(getOrgCountry()), clean(getOrgRole()), clean(getContactfullname()), clean(getContactemail()));
}
private String clean(final String s) {

View File

@ -34,7 +34,7 @@ public class MainApplication extends AbstractDnetApp {
@Override
protected void configSwagger(final OpenAPI openApi) {
openApi.info(new Info().title("D-Net Organizations Service APIs\"")
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")))