Commit f5495b84 authored by Célia Michotey's avatar Célia Michotey
Browse files

Merge branch 'feat/germplasm_mcpd' into 'master'

Add mcpd developments. Fix GNP-5428.

Closes GNP-5428

See merge request !53
parents 8c8e2e4c 85eadb44
......@@ -65,7 +65,7 @@ build-loader-docker-image:
lint:
stage: test
tags:
- openstack
- openstack
script: "./gradlew lint"
cache:
key: "$CI_COMMIT_REF_NAME"
......@@ -135,7 +135,7 @@ test-and-sonarqube-master:
build:
tags:
- openstack
- openstack
stage: build
script:
- ./gradlew assemble
......@@ -155,26 +155,26 @@ build:
.restart-config-server: &restart_config_server
stage: build
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "${SSH_PRIVATE_KEY}")
- ssh -o StrictHostKeyChecking=no ${SERVER_USER}@${SERVER_IP} 'echo "Successfully connected on $(hostname)"'
- ssh ${SERVER_USER}@${SERVER_IP} "sudo systemctl restart bootapp@config-server"
- eval $(ssh-agent -k)
- eval $(ssh-agent -s)
- ssh-add <(echo "${SSH_PRIVATE_KEY}")
- ssh -o StrictHostKeyChecking=no ${SERVER_USER}@${SERVER_IP} 'echo "Successfully connected on $(hostname)"'
- ssh ${SERVER_USER}@${SERVER_IP} "sudo systemctl restart bootapp@config-server"
- eval $(ssh-agent -k)
allow_failure: true
restart-config-server-proxmox:
variables:
SERVER_IP: ${SERVER_IP_PROXMOX}
SERVER_USER: ${SERVER_USER_PROXMOX}
<<: *restart_config_server
variables:
SERVER_IP: ${SERVER_IP_PROXMOX}
SERVER_USER: ${SERVER_USER_PROXMOX}
<<: *restart_config_server
restart-config-server-openstack:
tags:
- openstack
variables:
SERVER_IP: ${SERVER_IP_OPENSTACK_DEV}
SERVER_USER: ${SERVER_USER_OPENSTACK}
<<: *restart_config_server
tags:
- openstack
variables:
SERVER_IP: ${SERVER_IP_OPENSTACK_DEV}
SERVER_USER: ${SERVER_USER_OPENSTACK}
<<: *restart_config_server
# DEPLOY
......
......@@ -12,6 +12,7 @@ import fr.inra.urgi.faidare.domain.criteria.GermplasmGETSearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmPOSTSearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmSearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.base.PaginationCriteriaImpl;
import fr.inra.urgi.faidare.domain.data.germplasm.GermplasmMcpdVO;
import fr.inra.urgi.faidare.domain.response.ApiResponseFactory;
import fr.inra.urgi.faidare.domain.response.PaginatedList;
import fr.inra.urgi.faidare.domain.response.Pagination;
......@@ -69,6 +70,21 @@ public class GermplasmController {
return searchGermplasmService(criteria);
}
/**
* @link https://brapi.docs.apiary.io/#reference/germplasm/germplasm/get-germplasm-mcpd-by-germplasmdbid
*/
@ApiOperation("Get germplasm mcpd by id")
@GetMapping("/brapi/v1/germplasm/{germplasmDbId}/mcpd")
public BrapiResponse<GermplasmMcpdVO> getGermplasmMcpd(@PathVariable String germplasmDbId) {
LOGGER.debug("germplasmDbId = " + germplasmDbId);
GermplasmMcpdVO germplasm = germplasmService.getAsMcpdById(germplasmDbId);
if (germplasm == null) {
throw new NotFoundException("Germplasm not found for id '" + germplasmDbId + "'");
}
return ApiResponseFactory.createSingleObjectResponse(germplasm, null);
}
/**
* @link https://github.com/plantbreeding/API/blob/master/Specification/Germplasm/GermplasmSearchGET.md
*/
......
......@@ -3,6 +3,7 @@ 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.criteria.FaidareGermplasmPOSTShearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmGETSearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmPOSTSearchCriteria;
......@@ -12,6 +13,8 @@ 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 +32,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 +82,7 @@ public class GnpISGermplasmController {
return germplasm;
}
/**
* Webservice for exporting germplasm by criteria into a CSV.
* <p>
......@@ -121,6 +126,27 @@ public class GnpISGermplasmController {
return null;
}
@PostMapping(value = "/germplasm-mcpd-csv", produces = "text/csv", consumes = APPLICATION_JSON_VALUE)
public FileSystemResource exportMcpd(@RequestBody @Valid FaidareGermplasmPOSTShearchCriteria criteria, HttpServletResponse response) {
long limitResult = 50000L;
long nbResult = germplasmService.germplasmFind(criteria).getMetadata().getPagination().getTotalCount();
if (!(nbResult > limitResult)) {
try {
File exportFile = germplasmService.exportGermplasmMcpd(criteria);
response.setHeader("Content-Disposition", "attachment; filename=germplasm.gnpis.csv");
return new FileSystemResource(exportFile);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("An error occurred when exporting germplasm: " + e.getMessage() + ".", e);
}
}
return null;
}
@ApiOperation("Search list of germplasm")
@PostMapping(value = "/search", consumes = APPLICATION_JSON_VALUE)
public GermplasmSearchResponse germplasmSearch(@RequestBody @Valid FaidareGermplasmPOSTShearchCriteria criteria) {
......
......@@ -113,6 +113,7 @@ public class FaidareProperties {
}
public String getBaseIndexName(String documentType) {
documentType = documentType.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase();
return elasticsearchIndexingTemplate
.replace("{documentType}", documentType.toLowerCase());
}
......
package fr.inra.urgi.faidare.domain.brapi.v1.data;
import com.fasterxml.jackson.annotation.JsonView;
import fr.inra.urgi.faidare.domain.JSONView;
import fr.inra.urgi.faidare.domain.data.germplasm.ExtendedInstitute;
import fr.inra.urgi.faidare.domain.data.germplasm.InstituteVO;
import java.io.Serializable;
import java.util.List;
public interface BrapiGermplasmCollectingInfo extends Serializable {
@JsonView(JSONView.BrapiFields.class)
List<? extends BrapiGermplasmInstitute> getCollectingInstitutes();
@JsonView(JSONView.BrapiFields.class)
String getCollectingMissionIdentifier();
@JsonView(JSONView.BrapiFields.class)
String getCollectingNumber();
@JsonView(JSONView.BrapiFields.class)
BrapiGermplasmCollectingSite getCollectingSite();
}
package fr.inra.urgi.faidare.domain.brapi.v1.data;
import com.fasterxml.jackson.annotation.JsonView;
import fr.inra.urgi.faidare.domain.JSONView;
import java.io.Serializable;
public interface BrapiGermplasmCollectingSite extends Serializable {
@JsonView(JSONView.BrapiFields.class)
String getCoordinateUncertainty();
@JsonView(JSONView.BrapiFields.class)
String getElevation();
@JsonView(JSONView.BrapiFields.class)
String getGeoreferencingMethod();
@JsonView(JSONView.BrapiFields.class)
String getLatitudeDecimal();
@JsonView(JSONView.BrapiFields.class)
String getLatitudeDegrees();
@JsonView(JSONView.BrapiFields.class)
String getLocationDescription();
@JsonView(JSONView.BrapiFields.class)
String getLongitudeDecimal();
@JsonView(JSONView.BrapiFields.class)
String getLongitudeDegrees();
@JsonView(JSONView.BrapiFields.class)
String getSpatialReferenceSystem();
}
package fr.inra.urgi.faidare.domain.brapi.v1.data;
import com.fasterxml.jackson.annotation.JsonView;
import fr.inra.urgi.faidare.domain.JSONView;
import fr.inra.urgi.faidare.domain.data.germplasm.ExtendedInstitute;
import java.io.Serializable;
public interface BrapiGermplasmDonorInfo extends Serializable {
@JsonView(JSONView.BrapiFields.class)
String getDonorAccessionNumber();
@JsonView(JSONView.BrapiFields.class)
BrapiGermplasmInstitute getDonorInstitute();
}
package fr.inra.urgi.faidare.domain.brapi.v1.data;
import com.fasterxml.jackson.annotation.JsonView;
import fr.inra.urgi.faidare.domain.JSONView;
/**
* @author gcornut
*/
public interface BrapiGermplasmInstitute {
@JsonView(JSONView.BrapiFields.class)
String getInstituteName();
@JsonView(JSONView.BrapiFields.class)
String getInstituteCode();
}
package fr.inra.urgi.faidare.domain.brapi.v1.data;
import com.fasterxml.jackson.annotation.JsonView;
import fr.inra.urgi.faidare.domain.JSONView;
import fr.inra.urgi.faidare.domain.data.germplasm.DonorInfoVO;
import fr.inra.urgi.faidare.domain.data.germplasm.InstituteVO;
import java.util.List;
/**
* @author gcornut
*/
public interface BrapiGermplasmMcpd {
@JsonView(JSONView.BrapiFields.class)
String getGermplasmDbId();
@JsonView(JSONView.BrapiFields.class)
String getGermplasmPUI();
@JsonView(JSONView.BrapiFields.class)
String getAccessionNumber();
@JsonView(JSONView.BrapiFields.class)
List<String> getAccessionNames();
@JsonView(JSONView.BrapiFields.class)
List<String> getAlternateIDs();
@JsonView(JSONView.BrapiFields.class)
String getCommonCropName();
@JsonView(JSONView.BrapiFields.class)
String getGenus();
@JsonView(JSONView.BrapiFields.class)
String getSpecies();
@JsonView(JSONView.BrapiFields.class)
String getSpeciesAuthority();
@JsonView(JSONView.BrapiFields.class)
String getSubtaxon();
@JsonView(JSONView.BrapiFields.class)
String getSubtaxonAuthority();
@JsonView(JSONView.BrapiFields.class)
String getAncestralData();
@JsonView(JSONView.BrapiFields.class)
String getBiologicalStatusOfAccessionCode();
@JsonView(JSONView.BrapiFields.class)
String getMlsStatus();
@JsonView(JSONView.BrapiFields.class)
String getCountryOfOriginCode();
@JsonView(JSONView.BrapiFields.class)
String getInstituteCode();
@JsonView(JSONView.BrapiFields.class)
BrapiGermplasmCollectingInfo getCollectingInfo();
@JsonView(JSONView.BrapiFields.class)
String getAcquisitionDate();
@JsonView(JSONView.BrapiFields.class)
String getAcquisitionSourceCode();
@JsonView(JSONView.BrapiFields.class)
List<DonorInfoVO> getDonorInfo();
@JsonView(JSONView.BrapiFields.class)
List<? extends BrapiGermplasmInstitute> getBreedingInstitutes();
@JsonView(JSONView.BrapiFields.class)
List<? extends BrapiGermplasmInstitute> getSafetyDuplicateInstitutes();
@JsonView(JSONView.BrapiFields.class)
List<String> getStorageTypeCodes();
@JsonView(JSONView.BrapiFields.class)
String getRemarks();
}
......@@ -13,12 +13,6 @@ import java.util.List;
*/
public interface GnpISInternal extends Serializable {
/**
* List of species group the VO belongs to
*/
@JsonView(JSONView.Internal.class)
List<Long> getSpeciesGroup();
/**
* Restricted group DB identifier from which the VO belong
*/
......
......@@ -212,15 +212,6 @@ public class LocationVO implements GnpISInternal, BrapiLocation, HasURI, HasURL,
this.additionalInfo = additionalInfo;
}
@Override
public List<Long> getSpeciesGroup() {
return speciesGroup;
}
public void setSpeciesGroup(List<Long> speciesGroup) {
this.speciesGroup = speciesGroup;
}
@Override
public Long getGroupId() {
return groupId;
......
......@@ -123,15 +123,6 @@ public class ProgramVO implements GnpISInternal, BrapiProgram, HasURI, HasURL, I
this.programDbId = programDbId;
}
@Override
public List<Long> getSpeciesGroup() {
return speciesGroup;
}
public void setSpeciesGroup(List<Long> speciesGroup) {
this.speciesGroup = speciesGroup;
}
@Override
public Long getGroupId() {
return groupId;
......
......@@ -198,15 +198,6 @@ public class TrialVO implements GnpISInternal, BrapiTrial, HasURI, HasURL, Inclu
this.additionalInfo = additionalInfo;
}
@Override
public List<Long> getSpeciesGroup() {
return speciesGroup;
}
public void setSpeciesGroup(List<Long> speciesGroup) {
this.speciesGroup = speciesGroup;
}
@Override
public Long getGroupId() {
return groupId;
......
......@@ -7,18 +7,18 @@ import fr.inra.urgi.faidare.domain.JSONView;
* @author gcornut
*/
public interface CollPop {
@JsonView(JSONView.GnpISFields.class)
@JsonView(JSONView.BrapiFields.class)
Long getId();
@JsonView(JSONView.GnpISFields.class)
@JsonView(JSONView.BrapiFields.class)
String getName();
@JsonView(JSONView.GnpISFields.class)
@JsonView(JSONView.BrapiFields.class)
String getType();
@JsonView(JSONView.GnpISFields.class)
@JsonView(JSONView.BrapiFields.class)
PuiNameValue getGermplasmRef();
@JsonView(JSONView.GnpISFields.class)
@JsonView(JSONView.BrapiFields.class)
Integer getGermplasmCount();
}
......@@ -12,8 +12,8 @@ public class CollPopVO implements Serializable, CollPop {
private Long id;
private String name;
private String type;
private SimpleVO germplasmRef;
private Integer germplasmCount;
private PuiNameValueVO germplasmRef;
@Override
public Long getId() {
......@@ -43,11 +43,11 @@ public class CollPopVO implements Serializable, CollPop {
}
@Override
public SimpleVO getGermplasmRef() {
public PuiNameValueVO getGermplasmRef() {
return germplasmRef;
}
public void setGermplasmRef(SimpleVO germplasmRef) {
public void setGermplasmRef(PuiNameValueVO germplasmRef) {
this.germplasmRef = germplasmRef;
}
......
package fr.inra.urgi.faidare.domain.data.germplasm;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import fr.inra.urgi.faidare.domain.brapi.v1.data.BrapiGermplasmCollectingInfo;
import fr.inra.urgi.faidare.domain.data.germplasm.InstituteVO;
import java.io.Serializable;
import java.util.List;
public class CollectingInfoVO implements BrapiGermplasmCollectingInfo, ExtendedCollectingInfo, Serializable {
@JsonDeserialize(contentAs = InstituteVO.class)
private List<InstituteVO> collectingInstitutes;
private String collectingMissionIdentifier;
private String collectingNumber;
private String materialType;
private String collectors;
private String collectingDate;
@JsonDeserialize(as = CollectingSiteVO.class)
private CollectingSiteVO collectingSite;
@Override
public List<InstituteVO> getCollectingInstitutes() {
return collectingInstitutes;
}
public void setCollectingInstitutes(List<InstituteVO> collectingInstitutes) {
this.collectingInstitutes = collectingInstitutes;
}
@Override
public String getCollectingMissionIdentifier() {
return collectingMissionIdentifier;
}
public void setCollectingMissionIdentifier(String collectingMissionIdentifier) {
this.collectingMissionIdentifier = collectingMissionIdentifier;
}
@Override
public String getCollectingNumber() {
return collectingNumber;
}
public void setCollectingNumber(String collectingNumber) {
this.collectingNumber = collectingNumber;
}
public String getMaterialType() {
return materialType;
}
public void setMaterialType(String materialType) {
this.materialType = materialType;
}
public String getCollectors() {
return collectors;
}
public void setCollectors(String collectors) {
this.collectors = collectors;
}
public String getCollectingDate() {
return collectingDate;
}
public void setCollectingDate(String collectingDate) {
this.collectingDate = collectingDate;
}
@Override
public CollectingSiteVO getCollectingSite() {
return collectingSite;
}
public void setCollectingSite(CollectingSiteVO collectingSite) {
this.collectingSite = collectingSite;
}
}
package fr.inra.urgi.faidare.domain.data.germplasm;
import fr.inra.urgi.faidare.domain.brapi.v1.data.BrapiGermplasmCollectingSite;
public class CollectingSiteVO implements BrapiGermplasmCollectingSite, ExtendedCollectingSite {
private String locationDbId;
private String siteName;
private String siteType;
private String coordinateUncertainty;
private String elevation;
private String georeferencingMethod;
private String latitudeDecimal;
private String latitudeDegrees;
private String locationDescription;
private String longitudeDecimal;
private String longitudeDegrees;
private String spatialReferenceSystem;
@Override
public String getLocationDbId() {
return locationDbId;
}
public void setLocationDbId(String locationDbId) {
this.locationDbId = locationDbId;
}
public String getSiteName() {
return siteName;
}