Commit c04accde authored by Maud Marty's avatar Maud Marty Committed by Célia Michotey
Browse files

feat: Add Mcdp call for Faidare API

parent 62c8b1b4
......@@ -3,15 +3,21 @@ package fr.inra.urgi.faidare.api.faidare.v1;
import com.google.common.base.Strings;
import fr.inra.urgi.faidare.api.BadRequestException;
import fr.inra.urgi.faidare.api.NotFoundException;
import fr.inra.urgi.faidare.api.brapi.v1.GermplasmController;
import fr.inra.urgi.faidare.domain.brapi.v1.response.BrapiResponse;
import fr.inra.urgi.faidare.domain.criteria.FaidareGermplasmPOSTShearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmGETSearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmPOSTSearchCriteria;
import fr.inra.urgi.faidare.domain.data.germplasm.GermplasmMcpdVO;
import fr.inra.urgi.faidare.domain.data.germplasm.GermplasmVO;
import fr.inra.urgi.faidare.domain.datadiscovery.response.GermplasmSearchResponse;
import fr.inra.urgi.faidare.domain.response.ApiResponseFactory;
import fr.inra.urgi.faidare.domain.response.PaginatedList;
import fr.inra.urgi.faidare.service.es.GermplasmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.web.bind.annotation.*;
......@@ -29,6 +35,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
public class GnpISGermplasmController {
private final GermplasmService germplasmService;
private final static Logger LOGGER = LoggerFactory.getLogger(GermplasmController.class);
@Autowired
public GnpISGermplasmController(GermplasmService germplasmService) {
......@@ -78,6 +85,20 @@ public class GnpISGermplasmController {
return germplasm;
}
/**
* @link https://brapi.docs.apiary.io/#reference/germplasm/germplasm/get-germplasm-mcpd-by-germplasmdbid
*/
@ApiOperation("Get germplasm mcpd by id")
@GetMapping("/faidare/v1/germplasm/{germplasmDbId}/mcpd")
public BrapiResponse<GermplasmMcpdVO> getGermplasmMcpd(@PathVariable String germplasmDbId) {
LOGGER.debug("germplasmDbId = " + germplasmDbId);
GermplasmMcpdVO germplasm = germplasmService.getMcpdById(germplasmDbId);
if (germplasm == null) {
throw new NotFoundException("Germplasm not found for id '" + germplasmDbId + "'");
}
return ApiResponseFactory.createSingleObjectResponse(germplasm, null);
}
/**
* Webservice for exporting germplasm by criteria into a CSV.
* <p>
......
......@@ -28,7 +28,7 @@ public interface BrapiGermplasmMcpd {
List<String> getAlternateIDs();
@JsonView(JSONView.BrapiFields.class)
String getCropName();
String getCommonCropName();
@JsonView(JSONView.BrapiFields.class)
String getGenus();
......@@ -81,4 +81,7 @@ public interface BrapiGermplasmMcpd {
@JsonView(JSONView.BrapiFields.class)
List<String> getStorageTypeCodes();
@JsonView(JSONView.BrapiFields.class)
String getRemarks();
}
......@@ -20,7 +20,7 @@ public class GermplasmMcpdVO implements Serializable, BrapiGermplasmMcpd, Extend
private List<String> alternateIDs;
private List<String> accessionNames;
private String cropName;
private String commonCropName;
private String genus;
private String species;
private String speciesAuthority;
......@@ -108,12 +108,12 @@ public class GermplasmMcpdVO implements Serializable, BrapiGermplasmMcpd, Extend
this.accessionNames = accessionNames;
}
public String getCropName() {
return cropName;
public String getCommonCropName() {
return commonCropName;
}
public void setCropName(String cropName) {
this.cropName = cropName;
public void setCommonCropName(String commonCropName) {
this.commonCropName = commonCropName;
}
public String getGenus() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment