75 lines
2.8 KiB
Java
75 lines
2.8 KiB
Java
package eu.dnetlib.openaire.funders;
|
|
|
|
import java.util.List;
|
|
|
|
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.exporter.exceptions.FundersApiException;
|
|
import eu.dnetlib.openaire.funders.domain.db.FunderDbEntry;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
@RestController
|
|
@CrossOrigin(origins = {
|
|
"*"
|
|
})
|
|
@ConditionalOnProperty(value = "openaire.exporter.enable.funders", havingValue = "true")
|
|
@Tag(name = "OpenAIRE funders API", description = "the OpenAIRE funders API")
|
|
public class FundersApiController extends AbstractExporterController {
|
|
|
|
@Autowired
|
|
private FunderDao fDao;
|
|
|
|
@RequestMapping(value = "/funders/{page}/{size}", produces = {
|
|
"application/json"
|
|
}, method = RequestMethod.GET)
|
|
@Operation(summary = "get basic information about funders", description = "basic information about funders: id, name, shortname, registration date")
|
|
@ApiResponses(value = {
|
|
@ApiResponse(responseCode = "200", description = "OK"),
|
|
@ApiResponse(responseCode = "500", description = "unexpected error")
|
|
})
|
|
public List<FunderDbEntry> getFunders(
|
|
@PathVariable final int page,
|
|
@PathVariable final int size) throws FundersApiException {
|
|
|
|
return fDao.listFunders(page, size);
|
|
}
|
|
|
|
@RequestMapping(value = "/funder/{id}", produces = {
|
|
"application/json"
|
|
}, method = RequestMethod.GET)
|
|
@Operation(summary = "get the funder details", description = "complete funder information")
|
|
@ApiResponses(value = {
|
|
@ApiResponse(responseCode = "200", description = "OK"),
|
|
@ApiResponse(responseCode = "500", description = "unexpected error")
|
|
})
|
|
public FunderDbEntry getFunderDetails(@PathVariable final String id) throws FundersApiException {
|
|
return fDao.findFunder(id);
|
|
}
|
|
|
|
@RequestMapping(value = "/funders/{page}/{size}/ids", produces = {
|
|
"application/json"
|
|
}, method = RequestMethod.GET)
|
|
@Operation(summary = "get the list of funder ids", description = "get the list of funder ids")
|
|
@ApiResponses(value = {
|
|
@ApiResponse(responseCode = "200", description = "OK"),
|
|
@ApiResponse(responseCode = "500", description = "unexpected error")
|
|
})
|
|
public List<String> listFunderIds(
|
|
@PathVariable final int page,
|
|
@PathVariable final int size) throws FundersApiException {
|
|
|
|
return fDao.listFunderIds(page, size);
|
|
}
|
|
|
|
}
|