dnet-applications/apps/dnet-exporter-api/src/main/java/eu/dnetlib/openaire/funders/FundersApiController.java

81 lines
3.0 KiB
Java
Raw Normal View History

2022-02-04 10:12:15 +01:00
package eu.dnetlib.openaire.funders;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2022-08-19 15:21:40 +02:00
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.openaire.common.AbstractExporterController;
import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails;
import eu.dnetlib.openaire.funders.domain.FunderDetails;
import 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;
2022-02-04 10:12:15 +01:00
@RestController
2022-08-19 15:21:40 +02:00
@CrossOrigin(origins = {
"*"
})
2022-02-04 10:12:15 +01:00
@ConditionalOnProperty(value = "openaire.exporter.enable.funders", havingValue = "true")
2022-08-19 15:21:40 +02:00
@Tag(name = "OpenAIRE funders API", description = "the OpenAIRE funders API")
2022-02-04 10:12:15 +01:00
public class FundersApiController extends AbstractExporterController {
private static final Log log = LogFactory.getLog(FundersApiController.class);
@Autowired
private FunderDao fDao;
2022-08-19 15:21:40 +02:00
@RequestMapping(value = "/funders", produces = {
"application/json"
}, method = RequestMethod.GET)
2022-08-22 13:03:46 +02:00
@Operation(summary = "get basic information about funders", description = "basic information about funders: id, name, shortname, last update date, registration date")
2022-02-04 10:12:15 +01:00
@ApiResponses(value = {
2022-08-22 13:03:46 +02:00
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
2022-08-19 15:21:40 +02:00
})
2022-02-04 10:12:15 +01:00
public List<FunderDetails> getFunders(
2022-08-19 15:21:40 +02:00
@PathVariable final int page,
@PathVariable final int size) throws FundersApiException {
2022-02-04 10:12:15 +01:00
return fDao.listFunderDetails(page, size);
}
2022-08-19 15:21:40 +02:00
@RequestMapping(value = "/funder/{id}", produces = {
"application/json"
}, method = RequestMethod.GET)
2022-08-22 13:03:46 +02:00
@Operation(summary = "get the funder details", description = "complete funder information")
2022-02-04 10:12:15 +01:00
@ApiResponses(value = {
2022-08-22 13:03:46 +02:00
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
2022-08-19 15:21:40 +02:00
})
2022-02-04 10:12:15 +01:00
public ExtendedFunderDetails getFunderDetails(
2022-08-19 15:21:40 +02:00
@PathVariable final String id) throws FundersApiException {
2022-02-04 10:12:15 +01:00
return fDao.getExtendedFunderDetails(id);
}
2022-08-19 15:21:40 +02:00
@RequestMapping(value = "/funder/ids", produces = {
"application/json"
}, method = RequestMethod.GET)
2022-08-22 13:03:46 +02:00
@Operation(summary = "get the list of funder ids", description = "get the list of funder ids")
2022-02-04 10:12:15 +01:00
@ApiResponses(value = {
2022-08-22 13:03:46 +02:00
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "500", description = "unexpected error")
2022-08-19 15:21:40 +02:00
})
2022-02-04 10:12:15 +01:00
public List<String> getFunderIds(
2022-08-19 15:21:40 +02:00
@PathVariable final int page,
@PathVariable final int size) throws FundersApiException {
2022-02-04 10:12:15 +01:00
return fDao.listFunderIds(page, size);
}
}