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; package eu.dnetlib;
import static springfox.documentation.builders.RequestHandlerSelectors.basePackage; import org.springdoc.core.GroupedOpenApi;
import java.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; 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.funders.FundersApiController;
import eu.dnetlib.openaire.info.InfoController; import eu.dnetlib.openaire.info.InfoController;
import eu.dnetlib.openaire.project.ProjectsController; import eu.dnetlib.openaire.project.ProjectsController;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
@EnableCaching @EnableCaching
@EnableScheduling @EnableScheduling
@EnableSwagger2
@SpringBootApplication @SpringBootApplication
@EnableAutoConfiguration(exclude = { @EnableAutoConfiguration(exclude = {
SolrAutoConfiguration.class SolrAutoConfiguration.class
@ -43,67 +36,51 @@ public class DNetOpenaireExporterApplication extends AbstractDnetApp {
SpringApplication.run(DNetOpenaireExporterApplication.class, args); 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 @Override
protected void configSwagger(final Docket docket) { protected void configSwagger(final OpenAPI openApi) {
configSwagger(docket, "OpenAIRE Info", InfoController.class.getPackage().getName(), config.getSwaggerInfo(), V1); 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) { @Bean
docket public GroupedOpenApi dsm() {
.groupName(groupName) return newGroupedOpenApi("Datasource Manager", DsmApiController.class.getPackage().getName());
.select()
.apis(basePackage(controllerPackage))
.build()
.directModelSubstitute(LocalDate.class, java.sql.Date.class)
.apiInfo(apiInfo(swag, version));
} }
private ApiInfo apiInfo(final Swagger swag, final String version) { @Bean
return new ApiInfoBuilder() public GroupedOpenApi projects() {
.title(swag.getApiTitle()) return newGroupedOpenApi("OpenAIRE Projects", ProjectsController.class.getPackage().getName());
.description(swag.getApiDescription()) }
.license(swag.getApiLicense())
.licenseUrl(swag.getApiLicenseUrl()) @Bean
.termsOfServiceUrl("") public GroupedOpenApi funders() {
.version(version) return newGroupedOpenApi("OpenAIRE Funders", FundersApiController.class.getPackage().getName());
.contact(new Contact( }
swag.getApiContactName(),
swag.getApiContactUrl(), @Bean
swag.getApiContactEmail())) 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(); .build();
} }

View File

@ -40,12 +40,6 @@ public class DnetOpenaireExporterProperties {
private Datasource datasource; private Datasource datasource;
private Project project; private Project project;
private Jdbc jdbc; private Jdbc jdbc;
private Swagger swaggerDsm;
private Swagger swaggerProjects;
private Swagger swaggerFunders;
private Swagger swaggerCommunities;
private Swagger swaggerContexts;
private Swagger swaggerInfo;
private Vocabularies vocabularies; private Vocabularies vocabularies;
@ -485,54 +479,6 @@ public class DnetOpenaireExporterProperties {
this.jdbc = jdbc; 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() { public Vocabularies getVocabularies() {
return vocabularies; return vocabularies;
} }

View File

@ -1,302 +1,345 @@
package eu.dnetlib.openaire.community; 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 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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 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 @RestController
@CrossOrigin(origins = { "*" }) @CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true") @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 { public class CommunityApiController {
@Autowired @Autowired
private CommunityApiCore communityApiCore; private CommunityApiCore communityApiCore;
@RequestMapping(value = "/community/communities", produces = {
@RequestMapping(value = "/community/communities", produces = { "application/json" }, method = RequestMethod.GET) "application/json"
@Operation( }, method = RequestMethod.GET)
value = "get all community profiles", @Operation(summary = "get all community profiles", description = "get all community profiles", tags = {
notes = "get all community profiles", C, R
tags = { C, R }, })
response = CommunitySummary[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunitySummary[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunitySummary> listCommunities() throws CommunityException { public List<CommunitySummary> listCommunities() throws CommunityException {
return communityApiCore.listCommunities(); return communityApiCore.listCommunities();
} }
@RequestMapping(value = "/community/{id}", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/community/{id}", produces = {
@Operation( "application/json"
value = "get community profile", }, method = RequestMethod.GET)
notes = "get community profile", @Operation(summary = "get community profile", description = "get community profile", tags = {
tags = { C, R }, C, R
response = CommunityDetails.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityDetails.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails getCommunity(@PathVariable final String id) throws CommunityException, CommunityNotFoundException { public CommunityDetails getCommunity(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunity(id); return communityApiCore.getCommunity(id);
} }
@RequestMapping(value = "/community/{id}", produces = { "application/json" }, method = RequestMethod.POST) @RequestMapping(value = "/community/{id}", produces = {
@Operation( "application/json"
value = "update community details", }, method = RequestMethod.POST)
notes = "update community details", @Operation(summary = "update community details", description = "update community details", tags = {
tags = { C, R }) C, R
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public void setCommunity( public void setCommunity(
@PathVariable final String id, @PathVariable final String id,
@RequestBody CommunityWritableProperties properties) throws CommunityException, CommunityNotFoundException { @RequestBody final CommunityWritableProperties properties) throws CommunityException, CommunityNotFoundException {
communityApiCore.setCommunity(id, properties); communityApiCore.setCommunity(id, properties);
} }
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/community/{id}/projects", produces = {
@Operation( "application/json"
value = "get community projects", }, method = RequestMethod.GET)
notes = "get community projects", @Operation(summary = "get community projects", description = "get community projects", tags = {
tags = { C_PJ, R }, C_PJ, R
response = CommunityProject[].class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityProject[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityProject> getCommunityProjects(@PathVariable final String id) throws CommunityException, CommunityNotFoundException { public List<CommunityProject> getCommunityProjects(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityProjects(id); return communityApiCore.getCommunityProjects(id);
} }
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.POST) @RequestMapping(value = "/community/{id}/projects", produces = {
@Operation( "application/json"
value = "associate a project to the community", }, method = RequestMethod.POST)
notes = "associate a project to the community", @Operation(summary = "associate a project to the community", description = "associate a project to the community", tags = {
tags = { C_PJ, W }) C_PJ, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityProject addCommunityProject( public CommunityProject addCommunityProject(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final CommunityProject project) throws CommunityException, CommunityNotFoundException { @RequestBody final CommunityProject project) throws CommunityException, CommunityNotFoundException {
return communityApiCore.addCommunityProject(id, project); return communityApiCore.addCommunityProject(id, project);
} }
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.DELETE) @RequestMapping(value = "/community/{id}/projects", produces = {
@Operation( "application/json"
value = "remove a project from the community", }, method = RequestMethod.DELETE)
notes = "remove a project from the community", @Operation(summary = "remove a project from the community", description = "remove a project from the community", tags = {
tags = { C_PJ, W }) C_PJ, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public void deleteCommunityProject( public void deleteCommunityProject(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final Integer projectId) throws CommunityException, CommunityNotFoundException { @RequestBody final Integer projectId) throws CommunityException, CommunityNotFoundException {
communityApiCore.removeCommunityProject(id, projectId); communityApiCore.removeCommunityProject(id, projectId);
} }
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/community/{id}/contentproviders", produces = {
@Operation( "application/json"
value = "get the list of content providers associated to a given community", }, method = RequestMethod.GET)
notes = "get the list of content providers associated to a given community", @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 = {
tags = { C_CP, R }, C_CP, R
response = CommunityContentprovider[].class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityContentprovider[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityContentprovider> getCommunityContentproviders(@PathVariable final String id) throws CommunityException, CommunityNotFoundException { public List<CommunityContentprovider> getCommunityContentproviders(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityContentproviders(id); return communityApiCore.getCommunityContentproviders(id);
} }
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.POST) @RequestMapping(value = "/community/{id}/contentproviders", produces = {
@Operation( "application/json"
value = "associate a content provider to the community", }, method = RequestMethod.POST)
notes = "associate a content provider to the community", @Operation(summary = "associate a content provider to the community", description = "associate a content provider to the community", tags = {
tags = { C_CP, W }) C_CP, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityContentprovider addCommunityContentprovider( public CommunityContentprovider addCommunityContentprovider(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final CommunityContentprovider contentprovider) throws CommunityException, CommunityNotFoundException { @RequestBody final CommunityContentprovider contentprovider) throws CommunityException, CommunityNotFoundException {
return communityApiCore.addCommunityContentprovider(id, contentprovider); return communityApiCore.addCommunityContentprovider(id, contentprovider);
} }
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.DELETE) @RequestMapping(value = "/community/{id}/contentproviders", produces = {
@Operation( "application/json"
value = "remove the association between a content provider and the community", }, method = RequestMethod.DELETE)
notes = "remove the association between a content provider and the community", @Operation(summary = "remove the association between a content provider and the community", description = "remove the association between a content provider and the community", tags = {
tags = { C_CP, W }) C_CP, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public void removeCommunityContentprovider( public void removeCommunityContentprovider(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final Integer contentproviderId) throws CommunityException, CommunityNotFoundException { @RequestBody final Integer contentproviderId) throws CommunityException, CommunityNotFoundException {
communityApiCore.removeCommunityContentProvider(id, contentproviderId); communityApiCore.removeCommunityContentProvider(id, contentproviderId);
} }
//ADDING CODE FOR COMMUNITY ORGANIZATIONS // ADDING CODE FOR COMMUNITY ORGANIZATIONS
@RequestMapping(value = "/community/{id}/organizations", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/community/{id}/organizations", produces = {
@Operation( "application/json"
value = "get the list of organizations for a given community", }, method = RequestMethod.GET)
notes = "get the list of organizations for a given community", @Operation(summary = "get the list of organizations for a given community", description = "get the list of organizations for a given community", tags = {
tags = { C_O, R }, C_O, R
response = CommunityOrganization[].class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityContentprovider[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityOrganization> getCommunityOrganizations(@PathVariable final String id) throws CommunityException, CommunityNotFoundException { public List<CommunityOrganization> getCommunityOrganizations(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityOrganizations(id); return communityApiCore.getCommunityOrganizations(id);
} }
@RequestMapping(value = "/community/{id}/organizations", produces = { "application/json" }, method = RequestMethod.POST) @RequestMapping(value = "/community/{id}/organizations", produces = {
@Operation( "application/json"
value = "associate an organization to the community", }, method = RequestMethod.POST)
notes = "associate an organization to the community", @Operation(summary = "associate an organization to the community", description = "associate an organization to the community", tags = {
tags = { C_O, W }) C_O, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityOrganization addCommunityOrganization( public CommunityOrganization addCommunityOrganization(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final CommunityOrganization organization) throws CommunityException, CommunityNotFoundException { @RequestBody final CommunityOrganization organization) throws CommunityException, CommunityNotFoundException {
return communityApiCore.addCommunityOrganization(id, organization); return communityApiCore.addCommunityOrganization(id, organization);
} }
@RequestMapping(value = "/community/{id}/organizations", produces = { "application/json" }, method = RequestMethod.DELETE) @RequestMapping(value = "/community/{id}/organizations", produces = {
@Operation( "application/json"
value = "remove the association between an organization and the community", }, method = RequestMethod.DELETE)
notes = "remove the association between an organization and the community", @Operation(summary = "remove the association between an organization and the community", description = "remove the association between an organization and the community", tags = {
tags = { C_O, W }) C_O, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public void removeCommunityOrganization( public void removeCommunityOrganization(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final Integer organizationId) throws CommunityException, CommunityNotFoundException { @RequestBody final Integer organizationId) throws CommunityException, CommunityNotFoundException {
communityApiCore.removeCommunityOrganization(id, organizationId); communityApiCore.removeCommunityOrganization(id, organizationId);
} }
//********************** // **********************
@RequestMapping(value = "/community/{id}/subjects", produces = { "application/json" }, method = RequestMethod.POST) @RequestMapping(value = "/community/{id}/subjects", produces = {
@Operation( "application/json"
value = "associate a subject to the community", }, method = RequestMethod.POST)
notes = "associate a subject to the community", @Operation(summary = "associate a subject to the community", description = "associate a subject to the community", tags = {
tags = { C, W }) C, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails addCommunitySubjects( public CommunityDetails addCommunitySubjects(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, CommunityNotFoundException { @RequestBody final List<String> subjects) throws CommunityException, CommunityNotFoundException {
return communityApiCore.addCommunitySubjects(id, subjects); return communityApiCore.addCommunitySubjects(id, subjects);
} }
@RequestMapping(value = "/community/{id}/subjects", produces = { "application/json" }, method = RequestMethod.DELETE) @RequestMapping(value = "/community/{id}/subjects", produces = {
@Operation( "application/json"
value = "remove subjects from a community", }, method = RequestMethod.DELETE)
notes = "remove subjects from a community", @Operation(summary = "remove subjects from a community", description = "remove subjects from a community", tags = {
tags = { C, W }) C, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails removeCommunitySubjects( public CommunityDetails removeCommunitySubjects(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, CommunityNotFoundException { @RequestBody final List<String> subjects) throws CommunityException, CommunityNotFoundException {
return communityApiCore.removeCommunitySubjects(id, subjects); return communityApiCore.removeCommunitySubjects(id, subjects);
} }
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
@Operation( "application/json"
value = "get the list of Zenodo communities associated to a given community", }, method = RequestMethod.GET)
notes = "get the list of Zenodo communities associated to a given community", @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 = {
tags = { C_ZC, R }, C_ZC, R
response = CommunityZenodoCommunity[].class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CommunityZenodoCommunity[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityZenodoCommunity> getCommunityZenodoCommunities(@PathVariable final String id) throws CommunityException, CommunityNotFoundException { public List<CommunityZenodoCommunity> getCommunityZenodoCommunities(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getCommunityZenodoCommunities(id); return communityApiCore.getCommunityZenodoCommunities(id);
} }
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = { "application/json" }, method = RequestMethod.POST) @RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
@Operation( "application/json"
value = "associate a Zenodo community to the community", }, method = RequestMethod.POST)
notes = "associate a Zenodo community to the community", @Operation(summary = "associate a Zenodo community to the community", description = "associate a Zenodo community to the community", tags = {
tags = { C_ZC, W }) C_ZC, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityZenodoCommunity addCommunityZenodoCommunity( public CommunityZenodoCommunity addCommunityZenodoCommunity(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final CommunityZenodoCommunity zenodocommunity) throws CommunityException, CommunityNotFoundException { @RequestBody final CommunityZenodoCommunity zenodocommunity) throws CommunityException, CommunityNotFoundException {
return communityApiCore.addCommunityZenodoCommunity(id, zenodocommunity); return communityApiCore.addCommunityZenodoCommunity(id, zenodocommunity);
} }
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = { "application/json" }, method = RequestMethod.DELETE) @RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
@Operation( "application/json"
value = "remove a Zenodo community from a community", }, method = RequestMethod.DELETE)
notes = "remove a Zenodo community from a community", @Operation(summary = "remove a Zenodo community from a community", description = "remove a Zenodo community from a community", tags = {
tags = { C_ZC, W }) C_ZC, W
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public void removeCommunityZenodoCommunity( public void removeCommunityZenodoCommunity(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final Integer zenodoCommId) throws CommunityException, CommunityNotFoundException { @RequestBody final Integer zenodoCommId) throws CommunityException, CommunityNotFoundException {
communityApiCore.removeCommunityZenodoCommunity(id, zenodoCommId); communityApiCore.removeCommunityZenodoCommunity(id, zenodoCommId);
} }
@RequestMapping(value = "/community/{zenodoId}/openairecommunities", produces = {
@RequestMapping(value = "/community/{zenodoId}/openairecommunities", produces = { "application/json" }, method = RequestMethod.GET) "application/json"
@Operation( }, method = RequestMethod.GET)
value = "get the list of OpenAIRE communities associated to a given Zenodo community", @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 = {
notes = "get the list of OpenAIRE communities associated to a given Zenodo community", C_ZC, R
tags = { C_ZC, R }) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found", response = CommunityNotFoundException.class), @ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = CommunityException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityOpenAIRECommunities getOpenAireCommunities( public CommunityOpenAIRECommunities getOpenAireCommunities(
@PathVariable final String zenodoId) throws CommunityException, CommunityNotFoundException { @PathVariable final String zenodoId) throws CommunityException, CommunityNotFoundException {
return communityApiCore.getOpenAIRECommunities(zenodoId); return communityApiCore.getOpenAIRECommunities(zenodoId);

View File

@ -6,31 +6,31 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.google.gson.Gson; import com.google.gson.Gson;
import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria; import eu.dnetlib.openaire.community.selectioncriteria.SelectionCriteria;
import io.swagger.annotations.ApiModelProperty; import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @JsonAutoDetect
public class CommunityContentprovider { 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; private String openaireId;
@NotNull @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; private String communityId;
@NotNull @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; private String id;
@Schema(value = "content provider name", required = false) @Schema(description = "content provider name", required = false)
private String name; private String name;
@NotNull @NotNull
@Schema(value = "content provider official name", required = true) @Schema(description = "content provider official name", required = true)
private String officialname; private String officialname;
// @NotNull // @NotNull
@Schema(value = "content provider selection criteria", required = false) @Schema(description = "content provider selection criteria", required = false)
private SelectionCriteria selectioncriteria; private SelectionCriteria selectioncriteria;
public String getOpenaireId() { public String getOpenaireId() {

View File

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

View File

@ -1,42 +1,43 @@
package eu.dnetlib.openaire.community; package eu.dnetlib.openaire.community;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotNull;
import io.swagger.v3.oas.annotations.media.Schema;
public class CommunityOpenAIRECommunities { public class CommunityOpenAIRECommunities {
@NotNull @NotNull
@Schema(value = "the zenodo community identifier", required = true) @Schema(description = "the zenodo community identifier", required = true)
private String zenodoid; private String zenodoid;
@NotNull @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; private List<String> openAirecommunitylist;
public CommunityOpenAIRECommunities() { public CommunityOpenAIRECommunities() {
this.zenodoid = ""; this.zenodoid = "";
openAirecommunitylist=new ArrayList<>(); openAirecommunitylist = new ArrayList<>();
} }
public List<String> getOpenAirecommunitylist() { public List<String> getOpenAirecommunitylist() {
return openAirecommunitylist; return openAirecommunitylist;
} }
public CommunityOpenAIRECommunities setOpenAirecommunitylist(List<String> openAirecommunitylist) { public CommunityOpenAIRECommunities setOpenAirecommunitylist(final List<String> openAirecommunitylist) {
this.openAirecommunitylist = openAirecommunitylist; this.openAirecommunitylist = openAirecommunitylist;
return this; return this;
} }
public String getZenodoid() { public String getZenodoid() {
return zenodoid; return zenodoid;
} }
public CommunityOpenAIRECommunities setZenodoid(String zenodoid) { public CommunityOpenAIRECommunities setZenodoid(final String zenodoid) {
this.zenodoid = zenodoid; this.zenodoid = zenodoid;
return this; return this;
} }
} }

View File

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

View File

@ -1,30 +1,31 @@
package eu.dnetlib.openaire.community; package eu.dnetlib.openaire.community;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @JsonAutoDetect
public class CommunityProject { 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; 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; 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; private String id;
@Schema(value = "project name", required = true) @Schema(description = "project name", required = true)
private String name; private String name;
@Schema(value = "project acronym", required = false) @Schema(description = "project acronym", required = false)
private String acronym; private String acronym;
@Schema(value = "project funder", required = true) @Schema(description = "project funder", required = true)
private String funder; private String funder;
@Schema(value = "project grant id", required = true) @Schema(description = "project grant id", required = true)
private String grantId; private String grantId;
public String getOpenaireId() { public String getOpenaireId() {

View File

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

View File

@ -4,42 +4,42 @@ import java.util.Date;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty; import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @JsonAutoDetect
public class CommunitySummary { public class CommunitySummary {
@Schema("identifies the community") @Schema(description = "identifies the community")
protected String id; 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; protected String queryId;
@Schema("community type") @Schema(description = "community type")
protected String type; protected String type;
@Schema("community name") @Schema(description = "community name")
protected String name; protected String name;
@Schema("community short name") @Schema(description = "community short name")
protected String shortName; protected String shortName;
@Schema("community creation date") @Schema(description = "community creation date")
protected Date creationDate; protected Date creationDate;
@Schema("community last update date") @Schema(description = "community last update date")
protected Date lastUpdateDate; protected Date lastUpdateDate;
@Schema("community description") @Schema(description = "community description")
protected String description; protected String description;
@Schema("http url for the community logo") @Schema(description = "http url for the community logo")
protected String logoUrl; protected String logoUrl;
@Schema("status of the community, drives its visibility") @Schema(description = "status of the community, drives its visibility")
protected CommunityStatus status; protected CommunityStatus status;
@Schema("Zenodo community associated to this community") @Schema(description = "Zenodo community associated to this community")
protected String zenodoCommunity; protected String zenodoCommunity;
public CommunitySummary() {} public CommunitySummary() {}

View File

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

View File

@ -3,45 +3,46 @@ package eu.dnetlib.openaire.community;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @JsonAutoDetect
public class CommunityZenodoCommunity { public class CommunityZenodoCommunity {
@NotNull @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; private String communityId;
@NotNull @NotNull
@Schema(value = "Zenodo identifier for this community", required = true) @Schema(description = "Zenodo identifier for this community", required = true)
private String zenodoid; private String zenodoid;
@NotNull @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; private String id;
public String getZenodoid() { public String getZenodoid() {
return zenodoid; return zenodoid;
} }
public void setZenodoid(String zenodoid) { public void setZenodoid(final String zenodoid) {
this.zenodoid = zenodoid; this.zenodoid = zenodoid;
} }
public String getId() { public String getId() {
return id; return id;
} }
public void setId(final String id) { public void setId(final String id) {
this.id = id; this.id = id;
} }
public String getCommunityId() { public String getCommunityId() {
return communityId; return communityId;
} }
public void setCommunityId(String communityId) { public void setCommunityId(final String communityId) {
this.communityId = communityId; this.communityId = communityId;
} }
} }

View File

@ -3,83 +3,88 @@ package eu.dnetlib.openaire.context;
import java.util.List; import java.util.List;
import java.util.Optional; 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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 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 @RestController
@CrossOrigin(origins = { "*" }) @CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.context", havingValue = "true") @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 { public class ContextApiController {
@Autowired @Autowired
private ContextApiCore contextApiCore; private ContextApiCore contextApiCore;
@RequestMapping(value = "/contexts", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/contexts", produces = {
@Operation( "application/json"
value = "list brief information about all the context profiles", }, method = RequestMethod.GET)
notes = "list brief information about all the context profiles.", @Operation(summary = "list brief information about all the context profiles", description = "list brief information about all the context profiles")
tags = { },
response = ContextSummary[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ContextSummary[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
public List<ContextSummary> listContexts(@RequestParam(required = false, defaultValue = "") List<String> type) throws ContextException { })
public List<ContextSummary> listContexts(@RequestParam(required = false, defaultValue = "") final List<String> type) throws ContextException {
return contextApiCore.listContexts(type); return contextApiCore.listContexts(type);
} }
@RequestMapping(value = "/context/{contextId}", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/context/{contextId}", produces = {
@Operation( "application/json"
value = "list the categories defined within a context", }, method = RequestMethod.GET)
notes = "list the categories defined within a context", @Operation(summary = "list the categories defined within a context", description = "list the categories defined within a context")
tags = { },
response = CategorySummary[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = CategorySummary[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CategorySummary> listCategories( public List<CategorySummary> listCategories(
@PathVariable final String contextId, @PathVariable final String contextId,
@RequestParam(required = false, defaultValue = "false") final Boolean all) throws ContextException { @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); return contextApiCore.listCategories(contextId, allFilter);
} }
@RequestMapping(value = "/context/category/{categoryId}", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/context/category/{categoryId}", produces = {
@Operation( "application/json"
value = "list the concepts defined within a category", }, method = RequestMethod.GET)
notes = "list the concepts defined within a category", @Operation(summary = "list the concepts defined within a category", description = "list the concepts defined within a category")
tags = { },
response = ConceptSummary[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ConceptSummary[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<ConceptSummary> listConcepts( public List<ConceptSummary> listConcepts(
@PathVariable final String categoryId, @PathVariable final String categoryId,
@RequestParam(required = false, defaultValue = "false") final Boolean all) throws ContextException { @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); return contextApiCore.listConcepts(categoryId, allFilter);
} }
@RequestMapping(value = "/context/category/concept/{conceptId}", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/context/category/concept/{conceptId}", produces = {
@Operation( "application/json"
value = "list the concepts defined within a category", }, method = RequestMethod.GET)
notes = "list the concepts defined within a category", @Operation(summary = "list the concepts defined within a category", description = "list the concepts defined within a category")
tags = { },
response = ConceptSummary[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ConceptSummary[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ContextException.class) }) @ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<ConceptSummary> listSubConcepts( public List<ConceptSummary> listSubConcepts(
@PathVariable final String conceptId, @PathVariable final String conceptId,
@RequestParam(required = false, defaultValue = "false") final Boolean all) throws ContextException { @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); 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.DatasourceDetails;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate; import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsWithApis; 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.DatasourceSnippetResponse;
import eu.dnetlib.openaire.dsm.domain.RequestFilter; import eu.dnetlib.openaire.dsm.domain.RequestFilter;
import eu.dnetlib.openaire.dsm.domain.RequestSort; 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.Response;
import eu.dnetlib.openaire.dsm.domain.SimpleResponse; import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
import eu.dnetlib.openaire.vocabularies.Country; import eu.dnetlib.openaire.vocabularies.Country;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController @RestController
@CrossOrigin(origins = { @CrossOrigin(origins = {
"*" "*"
}) })
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true") @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 { public class DsmApiController extends AbstractExporterController {
@Autowired @Autowired
@ -61,12 +61,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/countries", produces = { @RequestMapping(value = "/ds/countries", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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 DS, R
}, response = Country[].class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = Country[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public List<Country> listCountries() throws DsmException { public List<Country> listCountries() throws DsmException {
return dsmCore.listCountries(); return dsmCore.listCountries();
@ -75,12 +75,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/searchdetails/{page}/{size}", produces = { @RequestMapping(value = "/ds/searchdetails/{page}/{size}", produces = {
"application/json" "application/json"
}, method = RequestMethod.POST) }, 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 DS, R
}, response = DatasourceDetailResponse.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceDetailResponse.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public DatasourceDetailResponse searchDsDetails( public DatasourceDetailResponse searchDsDetails(
@RequestParam final RequestSort requestSortBy, @RequestParam final RequestSort requestSortBy,
@ -96,12 +96,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/aggregationhistory/{dsId}", produces = { @RequestMapping(value = "/ds/aggregationhistory/{dsId}", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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 DS, R
}, response = AggregationHistoryResponse.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = AggregationHistoryResponse.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public AggregationHistoryResponse aggregationHistory(@PathVariable final String dsId) throws DsmException { public AggregationHistoryResponse aggregationHistory(@PathVariable final String dsId) throws DsmException {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
@ -112,12 +112,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/searchsnippet/{page}/{size}", produces = { @RequestMapping(value = "/ds/searchsnippet/{page}/{size}", produces = {
"application/json" "application/json"
}, method = RequestMethod.POST) }, 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 DS, R
}, response = DatasourceSnippetResponse.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceSnippetResponse.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public DatasourceSnippetResponse searchSnippet( public DatasourceSnippetResponse searchSnippet(
@RequestParam final RequestSort requestSortBy, @RequestParam final RequestSort requestSortBy,
@ -133,13 +133,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/searchregistered/{page}/{size}", produces = { @RequestMapping(value = "/ds/searchregistered/{page}/{size}", produces = {
"application/json" "application/json"
}, method = RequestMethod.POST) }, 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, DS,
R R
}, response = DatasourceSnippetResponse.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceSnippetResponse.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public DatasourceSnippetResponse searchRegistered( public DatasourceSnippetResponse searchRegistered(
@RequestParam final RequestSort requestSortBy, @RequestParam final RequestSort requestSortBy,
@ -155,13 +155,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/recentregistered/{size}", produces = { @RequestMapping(value = "/ds/recentregistered/{size}", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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, DS,
R R
}, response = SimpleResponse.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = DatasourceResponse.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public SimpleResponse<?> recentRegistered(@PathVariable final int size) throws Throwable { public SimpleResponse<?> recentRegistered(@PathVariable final int size) throws Throwable {
final StopWatch stop = StopWatch.createStarted(); final StopWatch stop = StopWatch.createStarted();
@ -172,13 +172,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/countregistered", produces = { @RequestMapping(value = "/ds/countregistered", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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, DS,
R R
}, response = Long.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = Long.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public Long countRegistered(@RequestParam final String fromDate, public Long countRegistered(@RequestParam final String fromDate,
@RequestParam(required = false) final String typologyFilter) throws Throwable { @RequestParam(required = false) final String typologyFilter) throws Throwable {
@ -188,13 +188,13 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/ds/api/{dsId}", produces = { @RequestMapping(value = "/ds/api/{dsId}", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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, API,
R R
}, response = ApiDetailsResponse.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ApiDetailsResponse.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public ApiDetailsResponse getApi( public ApiDetailsResponse getApi(
@PathVariable final String dsId) throws DsmException { @PathVariable final String dsId) throws DsmException {
@ -207,12 +207,12 @@ public class DsmApiController extends AbstractExporterController {
@RequestMapping(value = "/api/baseurl/{page}/{size}", produces = { @RequestMapping(value = "/api/baseurl/{page}/{size}", produces = {
"application/json" "application/json"
}, method = RequestMethod.POST) }, 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 DS, API, R
}, response = String[].class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String[].class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public List<String> searchBaseUrls( public List<String> searchBaseUrls(
@RequestBody final RequestFilter requestFilter, @RequestBody final RequestFilter requestFilter,
@ -223,26 +223,26 @@ public class DsmApiController extends AbstractExporterController {
} }
@RequestMapping(value = "/ds/api/{apiId}", method = RequestMethod.DELETE) @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 API, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Api not found", response = ErrorMessage.class), @ApiResponse(responseCode = "400", description = "Api not found"),
@ApiResponse(responseCode = "403", description = "Api not removable", response = ErrorMessage.class), @ApiResponse(responseCode = "403", description = "Api not removable"),
@ApiResponse(responseCode = "500", description = "DSM Server error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "DSM Server error")
}) })
public void deleteApi(@PathVariable final String apiId) throws DsmForbiddenException, DsmNotFoundException { public void deleteApi(@PathVariable final String apiId) throws DsmForbiddenException, DsmNotFoundException {
dsmCore.deleteApi(apiId); dsmCore.deleteApi(apiId);
} }
@RequestMapping(value = "/ds/manage", method = RequestMethod.POST) @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 DS, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void setManaged( public void setManaged(
@RequestParam final String id, @RequestParam final String id,
@ -252,25 +252,25 @@ public class DsmApiController extends AbstractExporterController {
} }
@RequestMapping(value = "/ds/managed/{id}", method = RequestMethod.GET) @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 DS, R
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @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 { public boolean isManaged(@PathVariable final String id) throws DsmException {
return dsmCore.isManaged(id); return dsmCore.isManaged(id);
} }
@RequestMapping(value = "/ds/add", method = RequestMethod.POST) @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 DS, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Malformed request", response = ErrorMessage[].class), @ApiResponse(responseCode = "400", description = "Malformed request"),
@ApiResponse(responseCode = "500", description = "Unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "Unexpected error")
}) })
public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException { 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) @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 DS, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Malformed request", response = ErrorMessage[].class), @ApiResponse(responseCode = "400", description = "Malformed request"),
@ApiResponse(responseCode = "500", description = "Unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "Unexpected error")
}) })
public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmException { 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"); } 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) @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 DS, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void updateDatasource( public void updateDatasource(
@RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException { @RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException {
@ -312,12 +312,12 @@ public class DsmApiController extends AbstractExporterController {
} }
@RequestMapping(value = "/ds/api/baseurl", method = RequestMethod.POST) @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 API, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void updateBaseUrl( public void updateBaseUrl(
@RequestParam final String dsId, @RequestParam final String dsId,
@ -328,12 +328,12 @@ public class DsmApiController extends AbstractExporterController {
} }
@RequestMapping(value = "/ds/api/compliance", method = RequestMethod.POST) @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 API, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void updateCompliance( public void updateCompliance(
@RequestParam final String dsId, @RequestParam final String dsId,
@ -345,12 +345,12 @@ public class DsmApiController extends AbstractExporterController {
} }
@RequestMapping(value = "/ds/api/oaiset", method = RequestMethod.POST) @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 API, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public void updateOaiSetl( public void updateOaiSetl(
@RequestParam final String dsId, @RequestParam final String dsId,
@ -361,12 +361,12 @@ public class DsmApiController extends AbstractExporterController {
} }
@RequestMapping(value = "/ds/api/add", method = RequestMethod.POST) @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 API, W
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @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 { public void addApi(@RequestBody final ApiDetails api) throws DsmException {
if (StringUtils.isBlank(api.getDatasource())) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); } 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; private OperationManager operationManager;
@RequestMapping(value = "/dsm/ops", method = RequestMethod.GET) @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 R, M
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @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 { public int getOps() throws DsmException {
return operationManager.getOpSize(); return operationManager.getOpSize();
} }
@RequestMapping(value = "/dsm/killops", method = RequestMethod.POST) @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 W, M
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @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 { public int killOps() throws DsmException {
return operationManager.dropAll(); return operationManager.dropAll();
} }
@RequestMapping(value = "/dsm/dropcache", method = RequestMethod.POST) @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 W, M
}) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"), @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 { public void dropCache() throws DsmException {
dsmCore.dropCaches(); dsmCore.dropCaches();

View File

@ -1,29 +1,29 @@
package eu.dnetlib.openaire.dsm.domain; 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 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 @Schema
@JsonAutoDetect @JsonAutoDetect
public class AggregationHistoryResponse extends Response { public class AggregationHistoryResponse extends Response {
@Schema(position = 1) @Schema
private List<AggregationInfo> aggregationInfo; private List<AggregationInfo> aggregationInfo;
public AggregationHistoryResponse(List<AggregationInfo> aggregationInfo) { public AggregationHistoryResponse(final List<AggregationInfo> aggregationInfo) {
super(); super();
this.aggregationInfo = aggregationInfo; this.aggregationInfo = aggregationInfo;
} }
public List<AggregationInfo> getAggregationInfo() { public List<AggregationInfo> getAggregationInfo() {
return aggregationInfo; return aggregationInfo;
} }
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) { public void setAggregationInfo(final List<AggregationInfo> aggregationInfo) {
this.aggregationInfo = aggregationInfo; this.aggregationInfo = aggregationInfo;
} }
} }

View File

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

View File

@ -3,14 +3,14 @@ package eu.dnetlib.openaire.dsm.domain;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect; 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 @Schema
@JsonAutoDetect @JsonAutoDetect
public class ApiDetailsResponse extends Response { public class ApiDetailsResponse extends Response {
@Schema(position = 1) @Schema
private List<ApiDetails> api; private List<ApiDetails> api;
public List<ApiDetails> getApi() { public List<ApiDetails> getApi() {

View File

@ -3,7 +3,7 @@ package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo; 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. * Created by claudio on 29/11/2016.

View File

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

View File

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

View File

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

View File

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

View File

@ -5,19 +5,21 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
/** /**
* Created by claudio on 12/09/16. * Created by claudio on 12/09/16.
*/ */
@JsonAutoDetect @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 { public class DatasourceDetailsWithApis {
@Schema(position = 1) @Schema
private DatasourceDetails datasource; private DatasourceDetails datasource;
@Schema
private List<ApiDetails> apis = new ArrayList<>();
public DatasourceDetails getDatasource() { public DatasourceDetails getDatasource() {
return datasource; return datasource;
} }
@ -26,9 +28,6 @@ public class DatasourceDetailsWithApis {
this.datasource = datasource; this.datasource = datasource;
} }
@Schema(position = 2)
private List<ApiDetails> apis = new ArrayList<>();
public List<ApiDetails> getApis() { public List<ApiDetails> getApis() {
return apis; return apis;
} }

View File

@ -3,39 +3,39 @@ package eu.dnetlib.openaire.dsm.domain;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo; import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import io.swagger.annotations.ApiModel; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
@JsonAutoDetect @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 { public class DatasourceInfo {
@Schema(position = 0) @Schema
private long indexRecords; private long indexRecords;
@Schema(position = 1) @Schema
private long fundedContent; private long fundedContent;
@Schema(position = 2) @Schema
private long fulltexts; private long fulltexts;
@Schema(position = 3) @Schema
private String lastIndexingDate; private String lastIndexingDate;
@Schema(position = 4) @Schema
private String firstHarvestDate; private String firstHarvestDate;
@Schema(position = 5) @Schema
private DatasourceDetails datasource; private DatasourceDetails datasource;
@Schema(position = 6) @Schema
private AggregationInfo lastCollection; private AggregationInfo lastCollection;
@Schema(position = 7) @Schema
private AggregationInfo lastTransformation; private AggregationInfo lastTransformation;
@Schema(position = 8) @Schema
private List<AggregationInfo> aggregationHistory; private List<AggregationInfo> aggregationHistory;
public DatasourceInfo() { public DatasourceInfo() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,10 +2,10 @@ package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel; import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @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 { public enum FilterName {
id, id,

View File

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

View File

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

View File

@ -4,28 +4,27 @@ import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
@JsonAutoDetect @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 { public class OrganizationDetails extends OrganizationIgnoredProperties {
@Schema(position = 0) @Schema
private String legalshortname; private String legalshortname;
@NotBlank @NotBlank
@Schema(position = 1) @Schema
private String legalname; private String legalname;
@Schema(position = 2) @Schema
private String websiteurl; private String websiteurl;
@Schema(position = 3) @Schema
private String logourl; private String logourl;
@NotBlank @NotBlank
@Schema(position = 4) @Schema
private String country; private String country;
public String getLegalshortname() { public String getLegalshortname() {

View File

@ -4,10 +4,10 @@ import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel; import io.swagger.v3.oas.annotations.media.Schema;
@JsonAutoDetect @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> { public class RequestFilter extends HashMap<FilterName, Object> {
/** /**

View File

@ -1,16 +1,14 @@
package eu.dnetlib.openaire.dsm.domain; package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect; 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 @JsonAutoDetect
@Schema( @Schema(name = "Api response model", description = "Api response model, provides a response header")
value = "Api response model",
description = "Api response model, provides a response header")
public class Response { public class Response {
@Schema(position = 0) @Schema
private Header header; private Header header;
public Response() { public Response() {

View File

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

View File

@ -3,7 +3,7 @@ package eu.dnetlib.openaire.dsm.domain;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import eu.dnetlib.enabling.datasources.common.AggregationInfo; 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. * 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.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import eu.dnetlib.enabling.datasources.common.ApiParam; 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. * Created by claudio on 13/04/2017.
@ -15,7 +16,7 @@ import io.swagger.annotations.ApiModel;
@Entity @Entity
@Table(name = "dsm_apiparams") @Table(name = "dsm_apiparams")
@JsonIgnoreProperties(ignoreUnknown = true) @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 { public class ApiParamDbEntry implements ApiParam {
@EmbeddedId @EmbeddedId
@ -35,10 +36,12 @@ public class ApiParamDbEntry implements ApiParam {
return id; return id;
} }
@Override
public String getValue() { public String getValue() {
return value; return value;
} }
@Override
public void setValue(final String value) { public void setValue(final String value) {
this.value = value; this.value = value;
} }

View File

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

View File

@ -2,23 +2,31 @@ package eu.dnetlib.openaire.funders;
import java.util.List; 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.common.AbstractExporterController;
import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails; import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails;
import eu.dnetlib.openaire.funders.domain.FunderDetails; import eu.dnetlib.openaire.funders.domain.FunderDetails;
import eu.dnetlib.openaire.funders.domain.db.FunderDbEntry; import eu.dnetlib.openaire.funders.domain.db.FunderDbEntry;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.apache.commons.logging.Log; import io.swagger.v3.oas.annotations.tags.Tag;
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.*;
@RestController @RestController
@CrossOrigin(origins = { "*" }) @CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.funders", havingValue = "true") @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 { public class FundersApiController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(FundersApiController.class); private static final Log log = LogFactory.getLog(FundersApiController.class);
@ -26,41 +34,46 @@ public class FundersApiController extends AbstractExporterController {
@Autowired @Autowired
private FunderDao fDao; private FunderDao fDao;
@RequestMapping(value = "/funders", produces = { "application/json" }, method = RequestMethod.GET) @RequestMapping(value = "/funders", produces = {
@Operation( "application/json"
value = "get basic information about funders", }, method = RequestMethod.GET)
notes = "basic information about funders: id, name, shortname, last update date, registration date", @Operation(value = "get basic information about funders", notes = "basic information about funders: id, name, shortname, last update date, registration date", response = FunderDetails[].class)
response = FunderDetails[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = FunderDetails[].class), @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( public List<FunderDetails> getFunders(
@PathVariable final int page, @PathVariable final int page,
@PathVariable final int size) throws FundersApiException { @PathVariable final int size) throws FundersApiException {
return fDao.listFunderDetails(page, size); 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) @Operation(summary = "get the funder details", notes = "complete funder information", response = FunderDbEntry.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = FunderDbEntry.class), @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( public ExtendedFunderDetails getFunderDetails(
@PathVariable final String id) throws FundersApiException { @PathVariable final String id) throws FundersApiException {
return fDao.getExtendedFunderDetails(id); 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) @Operation(summary = "get the list of funder ids", notes = "get the list of funder ids", response = String[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String[].class), @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( public List<String> getFunderIds(
@PathVariable final int page, @PathVariable final int page,
@PathVariable final int size @PathVariable final int size) throws FundersApiException {
) throws FundersApiException {
return fDao.listFunderIds(page, size); 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.AbstractExporterController;
import eu.dnetlib.openaire.common.ExporterConstants; import eu.dnetlib.openaire.common.ExporterConstants;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController @RestController
@CrossOrigin(origins = { @CrossOrigin(origins = {
"*" "*"
}) })
@ConditionalOnProperty(value = "openaire.exporter.enable.info", havingValue = "true") @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 { public class InfoController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(InfoController.class); // NOPMD by marko on 11/24/08 5:02 PM 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 = { @RequestMapping(value = "/info/{infoKey}", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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 ExporterConstants.R
}, response = LocalDate.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = LocalDate.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public LocalDate getDate(@PathVariable final String infoKey) { public LocalDate getDate(@PathVariable final String infoKey) {
final JdbcInfoDao.DATE_INFO info = JdbcInfoDao.DATE_INFO.valueOf(infoKey); final JdbcInfoDao.DATE_INFO info = JdbcInfoDao.DATE_INFO.valueOf(infoKey);
@ -57,12 +58,12 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info", produces = { @RequestMapping(value = "/info", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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 ExporterConstants.R
}, response = Map.class) })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = LocalDate.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public Map<String, LocalDate> listInfo() { public Map<String, LocalDate> listInfo() {
final Map<String, LocalDate> map = Maps.newHashMap(); final Map<String, LocalDate> map = Maps.newHashMap();
@ -75,12 +76,12 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info/keys", produces = { @RequestMapping(value = "/info/keys", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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 ExporterConstants.R
}, response = String.class, responseContainer = "List") })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = LocalDate.class), @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error", response = ErrorMessage.class) @ApiResponse(responseCode = "500", description = "unexpected error")
}) })
public List<String> listInfoKeys() { public List<String> listInfoKeys() {
final List<String> keys = Lists.newArrayList(); final List<String> keys = Lists.newArrayList();
@ -93,7 +94,7 @@ public class InfoController extends AbstractExporterController {
@RequestMapping(value = "/info/dropCache", produces = { @RequestMapping(value = "/info/dropCache", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, 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 ExporterConstants.R
}) })
public void dropCache() { public void dropCache() {

View File

@ -8,22 +8,11 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 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.antlr.stringtemplate.StringTemplate;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; 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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; 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 @Controller
@CrossOrigin(origins = { "*" }) @CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.project", havingValue = "true") @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 { public class ProjectsController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(ProjectsController.class); // NOPMD by marko on 11/24/08 5:02 PM private static final Log log = LogFactory.getLog(ProjectsController.class); // NOPMD by marko on 11/24/08 5:02 PM
@ -58,19 +64,19 @@ public class ProjectsController extends AbstractExporterController {
private ProjectQueryParamsFactory projectQueryParamsFactory; private ProjectQueryParamsFactory projectQueryParamsFactory;
@RequestMapping(value = "/export/**/project/dspace.do", method = RequestMethod.GET) @RequestMapping(value = "/export/**/project/dspace.do", method = RequestMethod.GET)
@Operation( @Operation(value = "DSpace", notes = "return project information in compatible with the OpenAIRE plugin for DSpace", tags = {
value = "DSpace", ExporterConstants.DSPACE
notes = "return project information in compatible with the OpenAIRE plugin for DSpace", }, response = String.class)
tags = { ExporterConstants.DSPACE },
response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String.class), @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 void processDspace(final HttpServletRequest request, final ServletResponse response, })
@RequestParam(value = "startFrom", required = false) final String startFrom, public void processDspace(final HttpServletRequest request,
@RequestParam(value = "startUntil", required = false) final String startUntil, final ServletResponse response,
@RequestParam(value = "endFrom", required = false) final String endFrom, @RequestParam(value = "startFrom", required = false) final String startFrom,
@RequestParam(value = "endUntil", required = false) final String endUntil) throws Exception { @RequestParam(value = "startUntil", required = false) final String startUntil,
@RequestParam(value = "endFrom", required = false) final String endFrom,
@RequestParam(value = "endUntil", required = false) final String endUntil) throws Exception {
final Project conf = config.getProject(); final Project conf = config.getProject();
@ -86,19 +92,19 @@ public class ProjectsController extends AbstractExporterController {
} }
@RequestMapping(value = "/export/**/project/eprints.do", method = RequestMethod.GET) @RequestMapping(value = "/export/**/project/eprints.do", method = RequestMethod.GET)
@Operation( @Operation(value = "EPrints", notes = "return project information in compatible with the OpenAIRE plugin for Eprints", tags = {
value = "EPrints", ExporterConstants.EPRINT
notes = "return project information in compatible with the OpenAIRE plugin for Eprints", }, response = String.class)
tags = { ExporterConstants.EPRINT },
response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = String.class), @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 void processEprints(final HttpServletRequest request, final ServletResponse response, })
@RequestParam(value = "startFrom", required = false) final String startFrom, public void processEprints(final HttpServletRequest request,
@RequestParam(value = "startUntil", required = false) final String startUntil, final ServletResponse response,
@RequestParam(value = "endFrom", required = false) final String endFrom, @RequestParam(value = "startFrom", required = false) final String startFrom,
@RequestParam(value = "endUntil", required = false) final String endUntil) throws Exception { @RequestParam(value = "startUntil", required = false) final String startUntil,
@RequestParam(value = "endFrom", required = false) final String endFrom,
@RequestParam(value = "endUntil", required = false) final String endUntil) throws Exception {
final ProjectQueryParams params = projectQueryParamsFactory.generateParams(request, startFrom, startUntil, endFrom, endUntil); final ProjectQueryParams params = projectQueryParamsFactory.generateParams(request, startFrom, startUntil, endFrom, endUntil);
response.setContentType("text/html"); response.setContentType("text/html");
@ -110,29 +116,30 @@ public class ProjectsController extends AbstractExporterController {
} }
private void doProcess( private void doProcess(
final ServletResponse response, final ServletResponse response,
final ProjectQueryParams params, final ProjectQueryParams params,
final String head, final Resource projectTemplate, final String tail, final String head,
final ValueCleaner cleaner) throws IOException, SQLException { final Resource projectTemplate,
final String tail,
final ValueCleaner cleaner) throws IOException, SQLException {
final StringTemplate st = new StringTemplate(IOUtils.toString(projectTemplate.getInputStream(), UTF8)); final StringTemplate st = new StringTemplate(IOUtils.toString(projectTemplate.getInputStream(), UTF8));
try(final OutputStream out = new BufferedOutputStream(response.getOutputStream())) { try (final OutputStream out = new BufferedOutputStream(response.getOutputStream())) {
dao.streamProjects(obtainQuery(params), out, head, st, tail, cleaner); dao.streamProjects(obtainQuery(params), out, head, st, tail, cleaner);
} }
} }
@RequestMapping(value = "/noads/project2tsv.do", method = RequestMethod.GET) @RequestMapping(value = "/noads/project2tsv.do", method = RequestMethod.GET)
@Operation( @Operation(value = "TSV", notes = "download project information in TSV format", tags = {
value = "TSV", ExporterConstants.TSV
notes = "download project information in TSV format", }, response = ProjectTsv[].class)
tags = { ExporterConstants.TSV },
response = ProjectTsv[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ProjectTsv[].class), @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, public void processTsv(final HttpServletResponse response,
@RequestParam(value = "funding", required = true) final String funding, @RequestParam(value = "funding", required = true) final String funding,
@RequestParam(value = "article293", required = false) final Boolean article293) throws Exception { @RequestParam(value = "article293", required = false) final Boolean article293) throws Exception {
final String fundingPrefix = getFundingPrefix(funding, null); final String fundingPrefix = getFundingPrefix(funding, null);
@ -140,37 +147,37 @@ public class ProjectsController extends AbstractExporterController {
final String filename = "projects_" + funding + "_" + date + ".tsv"; final String filename = "projects_" + funding + "_" + date + ".tsv";
response.setContentType("text/tab-separated-values"); response.setContentType("text/tab-separated-values");
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + ".zip\""); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + ".zip\"");
try(final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()))) { try (final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()))) {
dao.processTsvRequest(out, article293, fundingPrefix, filename); dao.processTsvRequest(out, article293, fundingPrefix, filename);
} catch (Throwable e) { } catch (final Throwable e) {
throw new RuntimeException("Error processing the request", e); throw new RuntimeException("Error processing the request", e);
} }
} }
@RequestMapping(value = "/export/streamProjectDetails.do", method = RequestMethod.GET) @RequestMapping(value = "/export/streamProjectDetails.do", method = RequestMethod.GET)
@Operation( @Operation(value = "Stream projects", notes = "stream project information", tags = {
value = "Stream projects", ExporterConstants.STREAMING
notes = "stream project information", }, response = ProjectDetails[].class)
tags = { ExporterConstants.STREAMING },
response = ProjectDetails[].class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK", response = ProjectDetails[].class), @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, public void streamProjectDetails(final HttpServletResponse response,
@RequestParam(value = "format", required = true) final String format, @RequestParam(value = "format", required = true) final String format,
@RequestParam(value = "compress", required = false) final Boolean compress) throws IOException, SQLException { @RequestParam(value = "compress", required = false) final Boolean compress) throws IOException, SQLException {
if (compress != null && compress) { if (compress != null && compress) {
response.setHeader("Content-Encoding", "gzip"); response.setHeader("Content-Encoding", "gzip");
} }
switch (format) { switch (format) {
case "csv": case "csv":
response.setContentType("text/csv"); response.setContentType("text/csv");
break; break;
case "json": case "json":
response.setContentType("text/plain"); response.setContentType("text/plain");
break; break;
default: throw new IllegalArgumentException("unsupported format: " + format); default:
throw new IllegalArgumentException("unsupported format: " + format);
} }
dao.processProjectDetails(response.getOutputStream(), format, compress); dao.processProjectDetails(response.getOutputStream(), format, compress);
@ -190,22 +197,20 @@ public class ProjectsController extends AbstractExporterController {
* if the funding program is not recognized * if the funding program is not recognized
*/ */
protected String obtainQuery(final ProjectQueryParams params) throws IllegalArgumentException, IOException { protected String obtainQuery(final ProjectQueryParams params) throws IllegalArgumentException, IOException {
String funding = params.getFundingProgramme(); final String funding = params.getFundingProgramme();
String suffix = params.getFundingPath(); final String suffix = params.getFundingPath();
final StringTemplate st = new StringTemplate(IOUtils.toString(config.getProject().getProjectsFundingQueryTemplate().getInputStream(), UTF8)); final StringTemplate st = new StringTemplate(IOUtils.toString(config.getProject().getProjectsFundingQueryTemplate().getInputStream(), UTF8));
st.setAttribute("fundingprefix", getFundingPrefix(funding, suffix)); st.setAttribute("fundingprefix", getFundingPrefix(funding, suffix));
String theQuery = setDateParameters(st.toString(), params); final String theQuery = setDateParameters(st.toString(), params);
log.debug("Generated query: " + theQuery); log.debug("Generated query: " + theQuery);
return theQuery; return theQuery;
} }
private String getFundingPrefix(final String funding, final String suffix) { private String getFundingPrefix(final String funding, final String suffix) {
final Map<String, String> fundingIds = dao.readFundingpathIds(); final Map<String, String> fundingIds = dao.readFundingpathIds();
if (!fundingIds.containsKey(funding.toUpperCase())) { if (!fundingIds.containsKey(funding.toUpperCase())) { throw new IllegalArgumentException("invalid funding " + funding); }
throw new IllegalArgumentException("invalid funding " + funding); final String fundingPrefix = fundingIds.get(funding.toUpperCase());
}
String fundingPrefix = fundingIds.get(funding.toUpperCase());
return StringUtils.isBlank(suffix) ? fundingPrefix : fundingPrefix + "::" + suffix.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.sql.Date;
import java.util.ArrayList; import java.util.ArrayList;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.Lists; 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. * Created by claudio on 20/09/16.
*/ */
@Entity @Entity
@Table(name = "projects_api") @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 class ProjectApi {
public static final String INFO_EU_REPO_GRANT_AGREEMENT = "info:eu-repo/grantAgreement/"; public static final String INFO_EU_REPO_GRANT_AGREEMENT = "info:eu-repo/grantAgreement/";
@ -35,10 +38,10 @@ public class ProjectApi {
private Date enddate; private Date enddate;
private String fundingpathid; private String fundingpathid;
public ProjectApi() { } public ProjectApi() {}
public String getIdnamespace() { public String getIdnamespace() {
String res = INFO_EU_REPO_GRANT_AGREEMENT + getFunder()+"/"; String res = INFO_EU_REPO_GRANT_AGREEMENT + getFunder() + "/";
final String fundingProgram = asFundingProgram(getFundingpathid()); final String fundingProgram = asFundingProgram(getFundingpathid());
if (StringUtils.isNotBlank(fundingProgram)) { if (StringUtils.isNotBlank(fundingProgram)) {
res += fundingProgram; res += fundingProgram;
@ -69,9 +72,12 @@ public class ProjectApi {
private String asFundingProgram(final String fundingpathid) { private String asFundingProgram(final String fundingpathid) {
final ArrayList<String> strings = Lists.newArrayList(Splitter.on("::").split(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() <= 1) { throw new IllegalStateException("Unexpected funding id: " + fundingpathid); }
if(strings.size() == 2) return ""; if (strings.size() == 2) {
else return replaceSlash(strings.get(2)); return "";
} else {
return replaceSlash(strings.get(2));
}
} }
private String replaceSlash(final String s) { private String replaceSlash(final String s) {

View File

@ -6,37 +6,42 @@ import java.io.StringWriter;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonIgnore; import javax.persistence.Column;
import com.google.gson.Gson; import javax.persistence.Entity;
import io.swagger.annotations.ApiModel; import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.supercsv.cellprocessor.Optional; import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.ift.CellProcessor; import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.cellprocessor.ift.StringCellProcessor;
import org.supercsv.io.CsvBeanReader; import org.supercsv.io.CsvBeanReader;
import org.supercsv.io.CsvBeanWriter; import org.supercsv.io.CsvBeanWriter;
import org.supercsv.io.ICsvBeanReader; import org.supercsv.io.ICsvBeanReader;
import org.supercsv.io.ICsvBeanWriter; import org.supercsv.io.ICsvBeanWriter;
import org.supercsv.prefs.CsvPreference; 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. * Created by claudio on 04/07/2017.
*/ */
@Entity @Entity
@Table(name = "project_details") @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 { public class ProjectDetails {
@Transient @Transient
@JsonIgnore @JsonIgnore
private transient static final String[] FIELDS = Arrays.stream(ProjectDetails.class.getDeclaredFields()) private transient static final String[] FIELDS = Arrays.stream(ProjectDetails.class.getDeclaredFields())
.map(Field::getName) .map(Field::getName)
.filter(s -> !s.equals("FIELDS")) .filter(s -> !s.equals("FIELDS"))
.filter(s -> !s.startsWith("optional")) .filter(s -> !s.startsWith("optional"))
.toArray(String[]::new); .toArray(String[]::new);
@Id @Id
@Column(name = "projectid") @Column(name = "projectid")
@ -50,8 +55,7 @@ public class ProjectDetails {
@Column(name = "fundingpath", columnDefinition = "text[]") @Column(name = "fundingpath", columnDefinition = "text[]")
private String[] fundingPath; private String[] fundingPath;
public ProjectDetails() { public ProjectDetails() {}
}
public String getProjectId() { public String getProjectId() {
return projectId; return projectId;
@ -74,7 +78,7 @@ public class ProjectDetails {
} }
public void setFundingPath(final List<String> fundingPath) { public void setFundingPath(final List<String> fundingPath) {
if(fundingPath != null && !fundingPath.isEmpty()) { if (fundingPath != null && !fundingPath.isEmpty()) {
this.fundingPath = fundingPath.toArray(new String[fundingPath.size()]); this.fundingPath = fundingPath.toArray(new String[fundingPath.size()]);
} }
} }
@ -85,28 +89,23 @@ public class ProjectDetails {
public static ProjectDetails fromCSV(final String csv) throws IOException { public static ProjectDetails fromCSV(final String csv) throws IOException {
try (ICsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), CsvPreference.STANDARD_PREFERENCE)) { try (ICsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), CsvPreference.STANDARD_PREFERENCE)) {
return beanReader.read(ProjectDetails.class, FIELDS, getProcessors(new StringCellProcessor() { return beanReader.read(ProjectDetails.class, FIELDS, getProcessors((value, context) -> new Gson().fromJson(value.toString(), List.class)));
@Override
public Object execute(final Object value, final CsvContext context) {
return 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 * Sets up the processors used for the examples. There are 10 CSV columns, so 10 processors are defined. Empty columns are read as null
* columns are read as null (hence the NotNull() for mandatory columns). * (hence the NotNull() for mandatory columns).
* *
* @return the cell processors * @return the cell processors
*/ */
private static CellProcessor[] getProcessors(final CellProcessor fundingPathProcessor) { private static CellProcessor[] getProcessors(final CellProcessor fundingPathProcessor) {
return new CellProcessor[] { return new CellProcessor[] {
new Optional(), // projectId new Optional(), // projectId
new Optional(), // acronym new Optional(), // acronym
new Optional(), // code new Optional(), // code
new Optional(), // jsonextrainfo new Optional(), // jsonextrainfo
fundingPathProcessor fundingPathProcessor
}; };
} }
@ -117,12 +116,7 @@ public class ProjectDetails {
public String asCSV() throws IOException { public String asCSV() throws IOException {
final StringWriter sb = new StringWriter(); final StringWriter sb = new StringWriter();
try (ICsvBeanWriter beanWriter = new CsvBeanWriter(sb, CsvPreference.STANDARD_PREFERENCE)) { try (ICsvBeanWriter beanWriter = new CsvBeanWriter(sb, CsvPreference.STANDARD_PREFERENCE)) {
beanWriter.write(this, FIELDS, getProcessors(new StringCellProcessor() { beanWriter.write(this, FIELDS, getProcessors((value, context) -> new Gson().toJson(value)));
@Override
public Object execute(final Object value, final CsvContext context) {
return new Gson().toJson(value);
}
}));
beanWriter.flush(); beanWriter.flush();
} }

View File

@ -2,22 +2,25 @@ package eu.dnetlib.openaire.project.domain.db;
import java.sql.Date; import java.sql.Date;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists; 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. * Created by claudio on 05/07/2017.
*/ */
@Entity @Entity
@Table(name = "projects_tsv") @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 { public class ProjectTsv {
@Id @Id
@ -51,25 +54,14 @@ public class ProjectTsv {
public ProjectTsv() {} public ProjectTsv() {}
public List<String> asList() { public List<String> asList() {
return Lists.newArrayList( return Lists.newArrayList(clean(getCode()), clean(getAcronym()), clean(getTitle()), clean(getCallIdentifier()), clean(getStartdate() != null
clean(getCode()), ? getStartdate().toString()
clean(getAcronym()), : ""), clean(getEnddate() != null ? getEnddate().toString() : ""), clean(String.valueOf(isOaMandateForPublications())), clean(String
clean(getTitle()), .valueOf(isOaMandateForDatasets())), clean(getDescription()), clean(getOrgLegalname()), clean(getOrgCountry()), clean(getOrgRole()), clean(getContactfullname()), clean(getContactemail()));
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) { private String clean(final String s) {
return StringUtils.isNotBlank(s) ? "\"" + s.replaceAll("\\n|\\t|\\s+", " ").replace("\"","\"\"").trim() + "\"" : ""; return StringUtils.isNotBlank(s) ? "\"" + s.replaceAll("\\n|\\t|\\s+", " ").replace("\"", "\"\"").trim() + "\"" : "";
} }
public long getRowid() { public long getRowid() {

View File

@ -34,7 +34,7 @@ public class MainApplication extends AbstractDnetApp {
@Override @Override
protected void configSwagger(final OpenAPI openApi) { 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") .description("APIs documentation")
.version("1.1") .version("1.1")
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0"))) .license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))