diff --git a/src/main/java/org/breedinginsight/api/v1/controller/TokenController.java b/src/main/java/org/breedinginsight/api/v1/controller/TokenController.java index e1356dbfd..6c5442585 100644 --- a/src/main/java/org/breedinginsight/api/v1/controller/TokenController.java +++ b/src/main/java/org/breedinginsight/api/v1/controller/TokenController.java @@ -70,5 +70,5 @@ public HttpResponse apiToken(@QueryValue @NotBlank String returnUrl) { } } - + } diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java index 1f5c83e18..14ffdf6b3 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java @@ -25,13 +25,12 @@ import lombok.extern.slf4j.Slf4j; import org.brapi.client.v2.ApiResponse; import org.brapi.client.v2.model.exceptions.ApiException; -import org.brapi.client.v2.model.queryParams.germplasm.GermplasmQueryParams; import org.brapi.client.v2.modules.germplasm.GermplasmApi; import org.brapi.v2.model.BrAPIExternalReference; import org.brapi.v2.model.germ.BrAPIGermplasm; import org.brapi.v2.model.germ.BrAPIGermplasmSynonyms; import org.brapi.v2.model.germ.request.BrAPIGermplasmSearchRequest; -import org.brapi.v2.model.germ.response.BrAPIGermplasmListResponse; +import org.brapi.v2.model.germ.response.BrAPIGermplasmSingleResponse; import org.breedinginsight.brapi.v2.constants.BrAPIAdditionalInfoFields; import org.breedinginsight.brapps.importer.daos.ImportDAO; import org.breedinginsight.brapps.importer.model.ImportUpload; @@ -239,14 +238,34 @@ private Map processGermplasmForDisplay(List importBrAPIGermplasm(List brAPIGermplasmList, UUID programId, ImportUpload upload) throws ApiException { + public List createBrAPIGermplasm(List postBrAPIGermplasmList, UUID programId, ImportUpload upload) { GermplasmApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(programId), GermplasmApi.class); var program = programDAO.fetchOneById(programId); + Callable> postFunction = null; try { - Callable> postFunction = () -> { - List postResponse = brAPIDAOUtil.post(brAPIGermplasmList, upload, api::germplasmPost, importDAO::update); - return processGermplasmForDisplay(postResponse, program.getKey()); - }; + if (!postBrAPIGermplasmList.isEmpty()) { + postFunction = () -> { + List postResponse = brAPIDAOUtil.post(postBrAPIGermplasmList, upload, api::germplasmPost, importDAO::update); + return processGermplasmForDisplay(postResponse, program.getKey()); + }; + } + return programGermplasmCache.post(programId, postFunction); + } catch (Exception e) { + throw new InternalServerException("Unknown error has occurred: " + e.getMessage(), e); + } + } + + public List updateBrAPIGermplasm(List putBrAPIGermplasmList, UUID programId, ImportUpload upload) { + GermplasmApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(programId), GermplasmApi.class); + var program = programDAO.fetchOneById(programId); + Callable> postFunction = null; + try { + if (!putBrAPIGermplasmList.isEmpty()) { + postFunction = () -> { + List postResponse = putGermplasm(putBrAPIGermplasmList, api); + return processGermplasmForDisplay(postResponse, program.getKey()); + }; + } return programGermplasmCache.post(programId, postFunction); } catch (Exception e) { throw new InternalServerException("Unknown error has occurred: " + e.getMessage(), e); @@ -292,4 +311,17 @@ public List getGermplasmsByDBID(Collection germplasmDbId } return germplasm; } + + public List putGermplasm(List germplasmList, GermplasmApi api) throws ApiException { + List listResult = new ArrayList<>(); + + // TODO: temporary until generic BrAPIDAOUtil code is written + // generic code should handle importer progress updates + for (BrAPIGermplasm germplasm : germplasmList) { + ApiResponse response = api.germplasmGermplasmDbIdPut(germplasm.getGermplasmDbId(), germplasm); + listResult.add(response.getBody().getResult()); + } + + return listResult; + } } diff --git a/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java b/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java index d09848c91..527ad1272 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java +++ b/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java @@ -285,8 +285,17 @@ private String removeAppendedKey(String listName, String programKey){ return listName.replace(appendedKey, ""); } - public List importBrAPIGermplasm(List brAPIGermplasmList, UUID programId, ImportUpload upload) throws ApiException { - return germplasmDAO.importBrAPIGermplasm(brAPIGermplasmList, programId, upload); + public List createBrAPIGermplasm(List postBrAPIGermplasmList, UUID programId, ImportUpload upload) { + return germplasmDAO.createBrAPIGermplasm(postBrAPIGermplasmList, programId, upload); + } + + public List updateBrAPIGermplasm(List putBrAPIGermplasmList, UUID programId, ImportUpload upload) { + return germplasmDAO.updateBrAPIGermplasm(putBrAPIGermplasmList, programId, upload); + } + + public List importBrAPIGermplasm(List postBrAPIGermplasmList, List putBrAPIGermplasmList, + UUID programId, ImportUpload upload) throws ApiException { + return germplasmDAO.createBrAPIGermplasm(postBrAPIGermplasmList, programId, upload); } public List getRawGermplasmByAccessionNumber(ArrayList germplasmAccessionNumbers, UUID programId) throws ApiException { diff --git a/src/main/java/org/breedinginsight/brapps/importer/model/base/Germplasm.java b/src/main/java/org/breedinginsight/brapps/importer/model/base/Germplasm.java index 0a9c5bb1d..725bb9e44 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/model/base/Germplasm.java +++ b/src/main/java/org/breedinginsight/brapps/importer/model/base/Germplasm.java @@ -17,6 +17,8 @@ package org.breedinginsight.brapps.importer.model.base; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -109,6 +111,10 @@ public class Germplasm implements BrAPIObject { @ImportFieldMetadata(id="collection", name="Family Name", description = "The name of the family this germplasm is a part of.") private String collection; + @ImportFieldType(type= ImportFieldTypeEnum.TEXT) + @ImportFieldMetadata(id="germplasmAccessionNumber", name="Accession Number", description = "The accession number of the germplasm if germplasm is being re-imported with updated synonyms/parents.") + private String accessionNumber; + // Removed for now, need to add to breedbase /*@ImportType(type=ImportFieldType.LIST, clazz=GermplasmAttribute.class) private List germplasmAttributes;*/ @@ -150,12 +156,78 @@ public static String constructGermplasmListName(String listName, Program program return String.format("%s [%s-germplasm]", listName, program.getKey()); } + public void updateBrAPIGermplasm(BrAPIGermplasm germplasm, Program program, UUID listId, boolean commit) { + + germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_GID, getFemaleParentDBID()); + germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_MALE_PARENT_GID, getMaleParentDBID()); + germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_ENTRY_NO, getFemaleParentEntryNo()); + germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_MALE_PARENT_ENTRY_NO, getMaleParentEntryNo()); + + // Append synonyms to germplasm that don't already exist + // Synonym comparison is based on name and type + if (synonyms != null) { + Set existingSynonyms = new HashSet<>(germplasm.getSynonyms()); + for (String synonym: synonyms.split(";")){ + BrAPIGermplasmSynonyms brapiSynonym = new BrAPIGermplasmSynonyms(); + brapiSynonym.setSynonym(synonym); + if (!existingSynonyms.contains(brapiSynonym)) { + germplasm.addSynonymsItem(brapiSynonym); + } + } + } + + // Add germplasm to the new list + JsonObject listEntryNumbers = germplasm.getAdditionalInfo().getAsJsonObject(BrAPIAdditionalInfoFields.GERMPLASM_LIST_ENTRY_NUMBERS); + listEntryNumbers.addProperty(listId.toString(), entryNo); + + // TODO: figure out why clear this out: brapi-server + germplasm.setBreedingMethodDbId(null); + + if (commit) { + setUpdateCommitFields(germplasm, program.getKey()); + } + } + + + public void setUpdateCommitFields(BrAPIGermplasm germplasm, String programKey) { + + // Set germplasm name to [-] + String name = Utilities.appendProgramKey(germplasm.getDefaultDisplayName(), programKey, germplasm.getAccessionNumber()); + germplasm.setGermplasmName(name); + + // Update our synonyms to [-] + if (germplasm.getSynonyms() != null && !germplasm.getSynonyms().isEmpty()) { + for (BrAPIGermplasmSynonyms synonym: germplasm.getSynonyms()) { + synonym.setSynonym(Utilities.appendProgramKey(synonym.getSynonym(), programKey, germplasm.getAccessionNumber())); + } + } + } + + public boolean pedigreesEqual(BrAPIGermplasm brAPIGermplasm) { + JsonElement femaleGid = brAPIGermplasm.getAdditionalInfo().get(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_GID); + String brapiFemaleGid = femaleGid != null ? femaleGid.getAsString() : null; + JsonElement maleGid = brAPIGermplasm.getAdditionalInfo().get(BrAPIAdditionalInfoFields.GERMPLASM_MALE_PARENT_GID); + String brapiMaleGid = maleGid != null ? maleGid.getAsString() : null; + JsonElement femaleEntryNo = brAPIGermplasm.getAdditionalInfo().get(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_ENTRY_NO); + String brapiFemaleEntryNo = femaleEntryNo != null ? femaleEntryNo.getAsString() : null; + JsonElement maleEntryNo = brAPIGermplasm.getAdditionalInfo().get(BrAPIAdditionalInfoFields.GERMPLASM_MALE_PARENT_ENTRY_NO); + String brapiMaleEntryNo = maleEntryNo != null ? maleEntryNo.getAsString() : null; + + return ((getFemaleParentDBID() == null && brapiFemaleGid == null) || (getFemaleParentDBID() != null && getFemaleParentDBID().equals(brapiFemaleGid))) && + ((getMaleParentDBID() == null && brapiMaleGid == null) || (getMaleParentDBID() != null && getMaleParentDBID().equals(brapiMaleGid))) && + ((getFemaleParentEntryNo() == null && brapiFemaleEntryNo == null) || (getFemaleParentEntryNo() != null && getFemaleParentEntryNo().equals(brapiFemaleEntryNo))) && + ((getMaleParentEntryNo() == null && brapiMaleEntryNo == null) || (getMaleParentEntryNo() != null && getMaleParentEntryNo().equals(brapiMaleEntryNo))); + } + public BrAPIGermplasm constructBrAPIGermplasm(ProgramBreedingMethodEntity breedingMethod, User user, UUID listId) { BrAPIGermplasm germplasm = new BrAPIGermplasm(); germplasm.setGermplasmName(getGermplasmName()); germplasm.setDefaultDisplayName(getGermplasmName()); germplasm.setGermplasmPUI(getGermplasmPUI()); germplasm.setCollection(getCollection()); + germplasm.setGermplasmDbId(getAccessionNumber()); + //TODO: maybe remove germplasm import entry number + germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_IMPORT_ENTRY_NUMBER, entryNo); germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_GID, getFemaleParentDBID()); germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_MALE_PARENT_GID, getMaleParentDBID()); germplasm.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_ENTRY_NO, getFemaleParentEntryNo()); diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/ExperimentProcessor.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/ExperimentProcessor.java index 3eabe8c4d..e94ab7503 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/ExperimentProcessor.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/ExperimentProcessor.java @@ -106,6 +106,7 @@ public class ExperimentProcessor implements Processor { private final OntologyService ontologyService; private final FileMappingUtil fileMappingUtil; + // used to make the yearsToSeasonDbId() function more efficient private final Map yearToSeasonDbIdCache = new HashMap<>(); // used to make the seasonDbIdtoYear() function more efficient diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java index 7276a36ac..097f59fb1 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java @@ -16,6 +16,9 @@ */ package org.breedinginsight.brapps.importer.services.processors; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Prototype; import io.micronaut.http.HttpStatus; @@ -27,8 +30,11 @@ import org.brapi.v2.model.core.BrAPIListSummary; import org.brapi.v2.model.core.request.BrAPIListNewRequest; import org.brapi.v2.model.germ.BrAPIGermplasm; +import org.brapi.v2.model.germ.BrAPIGermplasmSynonyms; import org.breedinginsight.api.model.v1.response.ValidationError; import org.breedinginsight.api.model.v1.response.ValidationErrors; +import org.breedinginsight.brapi.v2.constants.BrAPIAdditionalInfoFields; +import org.breedinginsight.brapi.v2.dao.BrAPIGermplasmDAO; import org.breedinginsight.brapi.v2.services.BrAPIGermplasmService; import org.breedinginsight.brapps.importer.daos.BrAPIListDAO; import org.breedinginsight.brapps.importer.model.ImportUpload; @@ -65,12 +71,16 @@ public class GermplasmProcessor implements Processor { private final BreedingMethodDAO breedingMethodDAO; private final BrAPIListDAO brAPIListDAO; private final DSLContext dsl; + private final BrAPIGermplasmDAO brAPIGermplasmDAO; Map> germplasmByAccessionNumber = new HashMap<>(); Map fileGermplasmByName = new HashMap<>(); Map dbGermplasmByName = new HashMap<>(); + Map dbGermplasmByAccessionNo = new HashMap<>(); Map germplasmIndexByEntryNo = new HashMap<>(); List newGermplasmList; + + List updatedGermplasmList; List existingGermplasms; List existingParentGermplasms; List> postOrder = new ArrayList<>(); @@ -83,7 +93,10 @@ public class GermplasmProcessor implements Processor { public static String duplicateEntryNoMsg = "Entry numbers must be unique. Duplicated entry numbers found: %s"; public static String circularDependency = "Circular dependency in the pedigree tree"; public static String listNameAlreadyExists = "Import group name already exists"; + public static String missingGID = "No germplasm of GID %s was found in the database"; + public static String pedigreeAlreadyExists = "Pedigree information cannot be overwritten"; public static String missingFemaleParent = "Female parent is missing. If the female parent is unknown, specify GID or entry number 0 as the female parent"; + public static Function, String> arrayOfStringFormatter = (lst) -> { List lstCopy = new ArrayList<>(lst); Collections.sort(lstCopy); @@ -91,9 +104,11 @@ public class GermplasmProcessor implements Processor { }; @Inject - public GermplasmProcessor(BrAPIGermplasmService brAPIGermplasmService, DSLContext dsl, BreedingMethodDAO breedingMethodDAO, BrAPIListDAO brAPIListDAO) { + public GermplasmProcessor(BrAPIGermplasmService brAPIGermplasmService, DSLContext dsl, BreedingMethodDAO breedingMethodDAO, BrAPIListDAO brAPIListDAO, BrAPIGermplasmDAO brAPIGermplasmDAO) { + this.brAPIGermplasmService = brAPIGermplasmService; this.dsl = dsl; this.breedingMethodDAO = breedingMethodDAO; + this.brAPIGermplasmDAO = brAPIGermplasmDAO; this.brAPIListDAO = brAPIListDAO; this.brAPIGermplasmService = brAPIGermplasmService; } @@ -149,6 +164,7 @@ public void getExistingBrapiData(List importRows, Program program) // Get existing germplasm names List dbGermplasm = brAPIGermplasmService.getGermplasmByDisplayName(new ArrayList<>(fileGermplasmByName.keySet()), program.getId()); dbGermplasm.stream().forEach(germplasm -> dbGermplasmByName.put(germplasm.getDefaultDisplayName(), germplasm)); + dbGermplasm.stream().forEach(germplasm -> dbGermplasmByAccessionNo.put(germplasm.getAccessionNumber(), germplasm)); // Check for existing germplasm lists Boolean listNameDup = false; @@ -227,8 +243,8 @@ public Map process(List importRows importList = germplasm.constructBrAPIList(program, BRAPI_REFERENCE_SOURCE); } - // All rows are considered new germplasm, we don't check for duplicates newGermplasmList = new ArrayList<>(); + updatedGermplasmList = new ArrayList<>(); Map breedingMethods = new HashMap<>(); Boolean nullEntryNotFound = false; List badBreedingMethods = new ArrayList<>(); @@ -242,52 +258,90 @@ public Map process(List importRows Germplasm germplasm = brapiImport.getGermplasm(); + // Assign the entry number + if (germplasm.getEntryNo() == null) { + germplasm.setEntryNo(Integer.toString(i + 1)); + } else { + userProvidedEntryNumbers.add(germplasm.getEntryNo()); + } + entryNumberCounts.put(germplasm.getEntryNo(), + entryNumberCounts.containsKey(germplasm.getEntryNo()) ? entryNumberCounts.get(germplasm.getEntryNo()) + 1 : 1); + + UUID importListId = brAPIGermplasmService.getGermplasmListId(importList); + // Germplasm - if (germplasm != null && germplasm.getGermplasmName() != null) { - // Get the breeding method database object - ProgramBreedingMethodEntity breedingMethod = null; - if (germplasm.getBreedingMethod() != null) { - if (breedingMethods.containsKey(germplasm.getBreedingMethod())) { - breedingMethod = breedingMethods.get(germplasm.getBreedingMethod()); + //todo double check what dbgermplasmbyaccessionNo actually getting + //TODO maybe make separate method for cleanliness + if (germplasm != null) { + //Fetch and update existing germplasm + BrAPIGermplasm existingGermplasm; + + // Have GID so updating an existing germplasm record + if (germplasm.getAccessionNumber() != null) { + if (dbGermplasmByAccessionNo.containsKey(germplasm.getAccessionNumber()) ) { + existingGermplasm = dbGermplasmByAccessionNo.get(germplasm.getAccessionNumber()); } else { - List breedingMethodResults = breedingMethodDAO.findByNameOrAbbreviation(germplasm.getBreedingMethod(), program.getId()); - if (breedingMethodResults.size() > 0) { - breedingMethods.put(germplasm.getBreedingMethod(), breedingMethodResults.get(0)); + ValidationError ve = new ValidationError("GID", missingGID, HttpStatus.NOT_FOUND); + validationErrors.addError(i+2, ve ); // +2 instead of +1 to account for the column header row. + continue; + } + + // Error conditions: + // has existing pedigree and file pedigree is different + // Valid conditions: + // no existing pedigree and file different pedigree (not blank though, will fail other validations) + // existing pedigree and file pedigree same + + if (!StringUtils.isBlank(existingGermplasm.getPedigree()) && !germplasm.pedigreesEqual(existingGermplasm) ) { + ValidationError ve = new ValidationError("Pedigree", pedigreeAlreadyExists, HttpStatus.UNPROCESSABLE_ENTITY); + validationErrors.addError(i+2, ve ); // +2 instead of +1 to account for the column header row. + continue; + } + + validatePedigree(germplasm, i+2, validationErrors); + + germplasm.updateBrAPIGermplasm(existingGermplasm, program, importListId, commit); + + updatedGermplasmList.add(existingGermplasm); + mappedImportRow.setGermplasm(new PendingImportObject<>(ImportObjectState.EXISTING, existingGermplasm)); + + importList.addDataItem(existingGermplasm.getGermplasmName()); + + } else { + // Get the breeding method database object + ProgramBreedingMethodEntity breedingMethod = null; + if (germplasm.getBreedingMethod() != null) { + if (breedingMethods.containsKey(germplasm.getBreedingMethod())) { breedingMethod = breedingMethods.get(germplasm.getBreedingMethod()); } else { - ValidationError ve = new ValidationError("Breeding Method", badBreedMethodsMsg, HttpStatus.UNPROCESSABLE_ENTITY); - validationErrors.addError(i+2, ve ); // +2 instead of +1 to account for the column header row. - badBreedingMethods.add(germplasm.getBreedingMethod()); - breedingMethod = null; + List breedingMethodResults = breedingMethodDAO.findByNameOrAbbreviation(germplasm.getBreedingMethod(), program.getId()); + if (breedingMethodResults.size() > 0) { + breedingMethods.put(germplasm.getBreedingMethod(), breedingMethodResults.get(0)); + breedingMethod = breedingMethods.get(germplasm.getBreedingMethod()); + } else { + ValidationError ve = new ValidationError("Breeding Method", badBreedMethodsMsg, HttpStatus.UNPROCESSABLE_ENTITY); + validationErrors.addError(i + 2, ve); // +2 instead of +1 to account for the column header row. + badBreedingMethods.add(germplasm.getBreedingMethod()); + breedingMethod = null; + } } } - } - - validatePedigree(germplasm, i+2, validationErrors); - // Assign the entry number - if (germplasm.getEntryNo() == null) { - germplasm.setEntryNo(Integer.toString(i + 1)); - } else { - userProvidedEntryNumbers.add(germplasm.getEntryNo()); - } - entryNumberCounts.put(germplasm.getEntryNo(), - entryNumberCounts.containsKey(germplasm.getEntryNo()) ? entryNumberCounts.get(germplasm.getEntryNo()) + 1 : 1); + validatePedigree(germplasm, i + 2, validationErrors); - UUID importListId = brAPIGermplasmService.getGermplasmListId(importList); + BrAPIGermplasm newGermplasm = germplasm.constructBrAPIGermplasm(program, breedingMethod, user, commit, BRAPI_REFERENCE_SOURCE, nextVal, importListId); - BrAPIGermplasm newGermplasm = germplasm.constructBrAPIGermplasm(program, breedingMethod, user, commit, BRAPI_REFERENCE_SOURCE, nextVal, importListId); + newGermplasmList.add(newGermplasm); + // Assign status of the germplasm + if (fileGermplasmByName.get(newGermplasm.getDefaultDisplayName()) > 1 || dbGermplasmByName.containsKey(newGermplasm.getDefaultDisplayName())) { + mappedImportRow.setGermplasm(new PendingImportObject<>(ImportObjectState.EXISTING, newGermplasm)); + } else { + mappedImportRow.setGermplasm(new PendingImportObject<>(ImportObjectState.NEW, newGermplasm)); + } - newGermplasmList.add(newGermplasm); - // Assign status of the germplasm - if (fileGermplasmByName.get(newGermplasm.getDefaultDisplayName()) > 1 || dbGermplasmByName.containsKey(newGermplasm.getDefaultDisplayName())) { - mappedImportRow.setGermplasm(new PendingImportObject<>(ImportObjectState.EXISTING, newGermplasm)); - } else { - mappedImportRow.setGermplasm(new PendingImportObject<>(ImportObjectState.NEW, newGermplasm)); + importList.addDataItem(newGermplasm.getGermplasmName()); } - - importList.addDataItem(newGermplasm.getGermplasmName()); } else { mappedImportRow.setGermplasm(null); } @@ -320,17 +374,23 @@ public Map process(List importRows } // Construct our response object + return getStatisticsMap(importRows); + } + + private Map getStatisticsMap(List importRows) { + ImportPreviewStatistics germplasmStats = ImportPreviewStatistics.builder() - .newObjectCount(newGermplasmList.size()) - .build(); + .newObjectCount(newGermplasmList.size()) + .ignoredObjectCount(germplasmByAccessionNumber.size()) + .build(); //Modified logic here to check for female parent dbid or entry no, removed check for male due to assumption that shouldn't have only male parent int newObjectCount = newGermplasmList.stream().filter(newGermplasm -> newGermplasm != null).collect(Collectors.toList()).size(); ImportPreviewStatistics pedigreeConnectStats = ImportPreviewStatistics.builder() - .newObjectCount(importRows.stream().filter(germplasmImport -> - germplasmImport.getGermplasm() != null && - (germplasmImport.getGermplasm().getFemaleParentDBID() != null || germplasmImport.getGermplasm().getFemaleParentEntryNo() != null) - ).collect(Collectors.toList()).size()).build(); + .newObjectCount(importRows.stream().filter(germplasmImport -> + germplasmImport.getGermplasm() != null && + (germplasmImport.getGermplasm().getFemaleParentDBID() != null || germplasmImport.getGermplasm().getFemaleParentEntryNo() != null) + ).collect(Collectors.toList()).size()).build(); return Map.of( "Germplasm", germplasmStats, @@ -356,6 +416,8 @@ private void createPostOrder() { // Construct a dependency tree for POSTing order Set created = existingGermplasms.stream().map(BrAPIGermplasm::getGermplasmName).collect(Collectors.toSet()); + //todo this gets messy + int totalRecorded = 0; while (totalRecorded < newGermplasmList.size()) { @@ -407,12 +469,21 @@ public void postBrapiData(Map mappedBrAPIImport, Program // POST Germplasm List createdGermplasm = new ArrayList<>(); - if (newGermplasmList.size() > 0) { - try { - for (List postGroup: postOrder){ - createdGermplasm.addAll(brAPIGermplasmService.importBrAPIGermplasm(postGroup, program.getId(), upload)); - } + if (!newGermplasmList.isEmpty()) { + for (List postGroup: postOrder){ + createdGermplasm.addAll(brAPIGermplasmService.createBrAPIGermplasm(postGroup, program.getId(), upload)); + } + } + + // PUT germplasm + if (!updatedGermplasmList.isEmpty()) { + brAPIGermplasmService.updateBrAPIGermplasm(updatedGermplasmList, program.getId(), upload); + } + + // Create list + if (!newGermplasmList.isEmpty() || !updatedGermplasmList.isEmpty()) { + try { // Create germplasm list brAPIListDAO.createBrAPILists(List.of(importList), program.getId(), upload); } catch (ApiException e) { @@ -420,6 +491,7 @@ public void postBrapiData(Map mappedBrAPIImport, Program } } + // Update our records with what is returned Map createdGermplasmMap = new HashMap<>(); createdGermplasm.forEach(germplasm -> { @@ -505,10 +577,20 @@ else if (germplasmIndexByEntryNo.containsKey(germplasm.getFemaleParentEntryNo()) } } } - mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject().setPedigree(pedigreeString.length() > 0 ? pedigreeString.toString() : null); - //Simpler to just always add boolean, but consider for logic that previous imported values won't have that additional info value - mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject().putAdditionalInfoItem("femaleParentUnknown", femaleParentUnknown); - mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject().putAdditionalInfoItem("maleParentUnknown", maleParentUnknown); + + // only update brapi object for new germplasm or update with no previous pedigree + BrAPIGermplasm brapiGermplasm = mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject(); + + Optional existingPedigree = existingGermplasms.stream() + .filter(g -> g.equals(brapiGermplasm) && StringUtils.isBlank(g.getPedigree())) + .findFirst(); + + if (existingPedigree.isEmpty()) { + mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject().setPedigree(pedigreeString.length() > 0 ? pedigreeString.toString() : null); + //Simpler to just always add boolean, but consider for logic that previous imported values won't have that additional info value + mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject().putAdditionalInfoItem("femaleParentUnknown", femaleParentUnknown); + mappedBrAPIImport.get(i).getGermplasm().getBrAPIObject().putAdditionalInfoItem("maleParentUnknown", maleParentUnknown); + } } } } diff --git a/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java b/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java index 27edbf315..3abb9dcc8 100644 --- a/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java +++ b/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java @@ -28,7 +28,10 @@ import org.apache.commons.lang3.tuple.Pair; import org.brapi.client.v2.ApiResponse; import org.brapi.client.v2.model.exceptions.ApiException; +import org.brapi.client.v2.modules.germplasm.GermplasmApi; import org.brapi.v2.model.*; +import org.brapi.v2.model.germ.BrAPIGermplasm; +import org.brapi.v2.model.germ.response.BrAPIGermplasmSingleResponse; import org.breedinginsight.brapps.importer.model.ImportUpload; import javax.inject.Inject; @@ -273,6 +276,14 @@ private List getListResult(ApiResponse, Optional(); } + // TODO: write generic put code + public List put(List brapiObjects, + ImportUpload upload, + Function, ApiResponse> putMethod, + Consumer progressUpdateMethod) throws ApiException { + throw new UnsupportedOperationException(); + } + public List post(List brapiObjects, ImportUpload upload, Function, ApiResponse> postMethod, diff --git a/src/main/resources/db/migration/V1.0.14__germplasm_import_add_GID.sql b/src/main/resources/db/migration/V1.0.14__germplasm_import_add_GID.sql new file mode 100644 index 000000000..0739723ef --- /dev/null +++ b/src/main/resources/db/migration/V1.0.14__germplasm_import_add_GID.sql @@ -0,0 +1,21 @@ +/* + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +update importer_mapping +set mapping = '[{"id": "f8d43c7e-a618-4c16-8829-3085f7202a67", "mapping": [{"id": "f384837e-ad8d-4dbe-b54e-87b57070bed1", "value": {"fileFieldName": "Name"}, "objectId": "germplasmName"}, {"id": "39628d14-458b-429b-8e66-bb48e0445a83", "value": {"fileFieldName": "Breeding Method"}, "objectId": "breedingMethod"}, {"id": "f1ba63e1-f5e4-433f-a53e-1c2f3e2fa71f", "value": {"fileFieldName": "Source"}, "objectId": "germplasmSource"}, {"id": "f5892565-f888-4596-be82-ab8eeabf37ce", "value": {"fileFieldName": "External UID"}, "objectId": "externalUID"}, {"id": "65507e5d-2d66-4595-8763-e772fe25c870", "value": {"fileFieldName": "Entry No"}, "objectId": "entryNo"}, {"id": "3eae24c1-ca4a-48a2-96d0-3cf4630acd3a", "value": {"fileFieldName": "Female Parent GID"}, "objectId": "femaleParentDBID"}, {"id": "2dbd7262-93a1-44b0-86b7-f5fca290b965", "value": {"fileFieldName": "Male Parent GID"}, "objectId": "maleParentDBID"}, {"id": "6f7f1539-6e8f-4ede-b7d3-3423cc63abec", "value": {"fileFieldName": "Female Parent Entry No"}, "objectId": "femaleParentEntryNo"}, {"id": "25fe9954-bca7-42f1-818a-5f71e242fa1f", "value": {"fileFieldName": "Male Parent Entry No"}, "objectId": "maleParentEntryNo"}, {"id": "b910adfe-a474-47a0-8410-514578898436", "value": {"fileFieldName": "Synonyms"}, "objectId": "synonyms"}, {"id": "15836d5f-8194-40a8-a771-114eaae31eb4", "objectId": "germplasmPUI"}, {"id": "675b6af8-5a17-4146-a503-2e4e1a65d5fa", "objectId": "acquisitionDate"}, {"id": "69a3bd3c-cebc-435c-acdd-0be62dda25ed", "objectId": "countryOfOrigin"}, {"id": "8ab25267-20f2-450e-89ca-21634ff8fadb", "objectId": "collection"}, {"id": "bc09c6e1-866f-45c3-a285-a25859e8c982", "value": {"fileFieldName": "GID"}, "objectId": "germplasmAccessionNumber"}, {"id": "ce1701e2-2f61-4250-8595-9536e3f5ddcf", "objectId": "AdditionalInfo"}, {"id": "3470e9df-a028-45b7-943f-198bc62b6dbe", "objectId": "ExternalReference"}], "objectId": "Germplasm"}]', + file = '[{"Name": "BITest Pinot Noir", "Source": "Unknown", "Entry No": "1", "External UID": "", "Breeding Method": "UMM", "Male Parent GID": "", "Female Parent GID": "", "Male Parent Entry No": "", "Female Parent Entry No": "", "Synonyms": "test1;test2", "GID": ""}, {"Name": "BITest Pixie", "Source": "Winters Nursery", "Entry No": "2", "External UID": "", "Breeding Method": "CFV", "Male Parent GID": "", "Female Parent GID": "", "Male Parent Entry No": "", "Female Parent Entry No": "1", "Synonyms": "test1;test2", "GID": ""}, {"Name": "BITest BI002", "Source": "Ithaca Nursery", "Entry No": "7", "External UID": "12231321", "Breeding Method": "Biparental cross", "Male Parent GID": "", "Female Parent GID": "", "Male Parent Entry No": "", "Female Parent Entry No": "2", "Synonyms": "test1;test2", "GID": ""}, {"Name": "BITest BI003", "Source": "Ithaca Nursery", "Entry No": "8", "External UID": "", "Breeding Method": "BPC", "Male Parent GID": "", "Female Parent GID": "", "Male Parent Entry No": "7", "Female Parent Entry No": "2", "Synonyms": "test1;test2", "GID": ""}, {"Name": "BITest Pinot Noir", "Source": "Unknown", "Entry No": "3", "External UID": "", "Breeding Method": "UMM", "Male Parent GID": "", "Female Parent GID": "5fb01ea5-c212-4cfa-84e4-6d190379341f", "Male Parent Entry No": "", "Female Parent Entry No": "", "Synonyms": "test1;test2", "GID": ""}, {"Name": "BITest Pixie", "Source": "Winters Nursery", "Entry No": "4", "External UID": "", "Breeding Method": "CFV", "Male Parent GID": "640e8b58-1b1c-44a6-91a6-85b2b773376b", "Female Parent GID": "5fb01ea5-c212-4cfa-84e4-6d190379341f", "Male Parent Entry No": "", "Female Parent Entry No": "", "Synonyms": "test1;test2", "GID": ""}, {"Name": "BITest BI002", "Source": "Ithaca Nursery", "Entry No": "5", "External UID": "12231321", "Breeding Method": "Biparental cross", "Male Parent GID": "", "Female Parent GID": "5fb01ea5-c212-4cfa-84e4-6d190379341f", "Male Parent Entry No": "", "Female Parent Entry No": "2", "Synonyms": "test1;test2", "GID": ""}]' +where name = 'GermplasmTemplateMap'; \ No newline at end of file diff --git a/src/test/java/org/breedinginsight/api/v1/controller/BreedingMethodControllerIntegrationTest.java b/src/test/java/org/breedinginsight/api/v1/controller/BreedingMethodControllerIntegrationTest.java index cf793f5bf..ed84a3fa2 100644 --- a/src/test/java/org/breedinginsight/api/v1/controller/BreedingMethodControllerIntegrationTest.java +++ b/src/test/java/org/breedinginsight/api/v1/controller/BreedingMethodControllerIntegrationTest.java @@ -400,7 +400,7 @@ public void createGermplasmWithProgramMethod() throws ApiException { .externalReferences(List.of(programRef, germIdRef)) .accessionNumber(accessionNum); - assertDoesNotThrow(() -> germplasmService.importBrAPIGermplasm(List.of(germplasm), program.getId(), null)); + assertDoesNotThrow(() -> germplasmService.createBrAPIGermplasm(List.of(germplasm), program.getId(), null)); String germplasmUrl = String.format("/programs/%s/brapi/v2/germplasm", program.getId()); Flowable> germplasmCall = client.exchange( @@ -472,7 +472,7 @@ public void tryDeleteProgramMethodInUse() throws ApiException { .externalReferences(List.of(programRef, germIdRef)) .accessionNumber(accessionNum); - assertDoesNotThrow(() -> germplasmService.importBrAPIGermplasm(List.of(germplasm), program.getId(), null)); + assertDoesNotThrow(() -> germplasmService.createBrAPIGermplasm(List.of(germplasm), program.getId(), null)); String deleteUrl = String.format("/programs/%s/breeding-methods/%s", program.getId(), createdMethod.getId()); Flowable> deleteCall = client.exchange( @@ -548,7 +548,7 @@ public void tryDisableSystemMethodInUse() { .externalReferences(List.of(programRef, germIdRef)) .accessionNumber(accessionNum); - assertDoesNotThrow(() -> germplasmService.importBrAPIGermplasm(List.of(germplasm), program.getId(), null)); + assertDoesNotThrow(() -> germplasmService.createBrAPIGermplasm(List.of(germplasm), program.getId(), null)); Flowable> enableCallRemove = client.exchange( PUT(enableUrl, List.of()).cookie(new NettyCookie("phylo-token", "test-registered-user")) diff --git a/src/test/java/org/breedinginsight/brapps/importer/ExperimentFileImportTest.java b/src/test/java/org/breedinginsight/brapps/importer/ExperimentFileImportTest.java index 9b8db2598..3f8df5c6c 100644 --- a/src/test/java/org/breedinginsight/brapps/importer/ExperimentFileImportTest.java +++ b/src/test/java/org/breedinginsight/brapps/importer/ExperimentFileImportTest.java @@ -895,7 +895,7 @@ private Program createProgram(String name, String abbv, String key, String refer germplasm.forEach(germ -> germ.getExternalReferences().add(newReference)); - germplasmDAO.importBrAPIGermplasm(germplasm, program.getId(), null); + germplasmDAO.createBrAPIGermplasm(germplasm, program.getId(), null); } if(traits != null && !traits.isEmpty()) { diff --git a/src/test/resources/files/germplasm_import/bad_breeding_methods.csv b/src/test/resources/files/germplasm_import/bad_breeding_methods.csv index eabba0bbc..9faa60aee 100644 --- a/src/test/resources/files/germplasm_import/bad_breeding_methods.csv +++ b/src/test/resources/files/germplasm_import/bad_breeding_methods.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,ANE,Wild,,,,,,, -Germplasm 2,BAD,Wild,,,,,,, -Germplasm 3,BAD1,Wild,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,ANE,Wild,,,,,,, +,Germplasm 2,BAD,Wild,,,,,,, +,Germplasm 3,BAD1,Wild,,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/circular_parent_dependencies.csv b/src/test/resources/files/germplasm_import/circular_parent_dependencies.csv index aca160536..eda6c2c49 100644 --- a/src/test/resources/files/germplasm_import/circular_parent_dependencies.csv +++ b/src/test/resources/files/germplasm_import/circular_parent_dependencies.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,1,2,3,1234, -Germplasm 2,BCR,Wild,,,2,1,2,5678, -Germplasm 3,BCR,Wild,,,3,2,3,9123, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,1,2,3,1234, +,Germplasm 2,BCR,Wild,,,2,1,2,5678, +,Germplasm 3,BCR,Wild,,,3,2,3,9123, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/duplicate_db_names.csv b/src/test/resources/files/germplasm_import/duplicate_db_names.csv index 29d16a241..0bdc5c5fe 100644 --- a/src/test/resources/files/germplasm_import/duplicate_db_names.csv +++ b/src/test/resources/files/germplasm_import/duplicate_db_names.csv @@ -1,7 +1,7 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Full Germplasm 1,ANE,Wild,,,,,,, -Full Germplasm 2,ANE,Wild,,,,,,, -Full Germplasm 3,ANE,Wild,,,,,,, -Unique Germplasm 1,ANE,Wild,,,,,,, -File Germplasm 1,ANE,Wild,,,,,,, -File Germplasm 1,ANE,Wild,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Full Germplasm 1,ANE,Wild,,,,,,, +,Full Germplasm 2,ANE,Wild,,,,,,, +,Full Germplasm 3,ANE,Wild,,,,,,, +,Unique Germplasm 1,ANE,Wild,,,,,,, +,File Germplasm 1,ANE,Wild,,,,,,, +,File Germplasm 1,ANE,Wild,,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/duplicate_entry_numbers.csv b/src/test/resources/files/germplasm_import/duplicate_entry_numbers.csv index 724731327..e20f5c845 100644 --- a/src/test/resources/files/germplasm_import/duplicate_entry_numbers.csv +++ b/src/test/resources/files/germplasm_import/duplicate_entry_numbers.csv @@ -1,5 +1,5 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,1,,,, -Germplasm 2,BCR,Wild,,,1,,,, -Germplasm 3,BCR,Wild,,,3,,,, -Germplasm 4,BCR,Wild,,,3,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,1,,,, +,Germplasm 2,BCR,Wild,,,1,,,, +,Germplasm 3,BCR,Wild,,,3,,,, +,Germplasm 4,BCR,Wild,,,3,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/empty_required_fields.csv b/src/test/resources/files/germplasm_import/empty_required_fields.csv index 0cb11e376..3072ce9b2 100644 --- a/src/test/resources/files/germplasm_import/empty_required_fields.csv +++ b/src/test/resources/files/germplasm_import/empty_required_fields.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,ANE,Wild,,,,,,, -,ANE,Wild,,,,,,, -Germplasm 3,ANE,,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,ANE,Wild,,,,,,, +,,ANE,Wild,,,,,,, +,Germplasm 3,ANE,,,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/empty_values_required_fields.csv b/src/test/resources/files/germplasm_import/empty_values_required_fields.csv index 305016a6a..6af9e43a1 100644 --- a/src/test/resources/files/germplasm_import/empty_values_required_fields.csv +++ b/src/test/resources/files/germplasm_import/empty_values_required_fields.csv @@ -1,5 +1,5 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,,Wild,,,,,,, -,,Wild,,,,,,, -Germplasm 3,,,,,,,,, -,,Wild,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,,Wild,,,,,,, +,,,Wild,,,,,,, +,Germplasm 3,,,,,,,,, +,,,Wild,,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/female_dbid_not_exist.csv b/src/test/resources/files/germplasm_import/female_dbid_not_exist.csv index bdfaba7df..08a931520 100644 --- a/src/test/resources/files/germplasm_import/female_dbid_not_exist.csv +++ b/src/test/resources/files/germplasm_import/female_dbid_not_exist.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,1000,,,,,, -Germplasm 2,BCR,Cultivated,1001,,,,,, -Germplasm 3,BCR,Kinda Wild,1002,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,1000,,,,,, +,Germplasm 2,BCR,Cultivated,1001,,,,,, +,Germplasm 3,BCR,Kinda Wild,1002,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/female_entry_number_not_exist.csv b/src/test/resources/files/germplasm_import/female_entry_number_not_exist.csv index ad27c13f3..e8e3f4be4 100644 --- a/src/test/resources/files/germplasm_import/female_entry_number_not_exist.csv +++ b/src/test/resources/files/germplasm_import/female_entry_number_not_exist.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,,1,,, -Germplasm 2,BCR,Cultivated,,,,2,,, -Germplasm 3,BCR,Kinda Wild,,,,3,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,,1,,, +,Germplasm 2,BCR,Cultivated,,,,2,,, +,Germplasm 3,BCR,Kinda Wild,,,,3,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/full_import.csv b/src/test/resources/files/germplasm_import/full_import.csv index 88ce7645c..9073ac69f 100644 --- a/src/test/resources/files/germplasm_import/full_import.csv +++ b/src/test/resources/files/germplasm_import/full_import.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Full Germplasm 1,ANE,Wild,1,2,2,,,1234,test1;test2 -Full Germplasm 2,ANE,Wild,2,,3,,,5678,test3;test2 -Full Germplasm 3,ANE,Wild,,,4,2,3,9123,test3;test4 \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Full Germplasm 1,ANE,Wild,1,2,2,,,1234,test1;test2 +,Full Germplasm 2,ANE,Wild,2,,3,,,5678,test3;test2 +,Full Germplasm 3,ANE,Wild,,,4,2,3,9123,test3;test4 \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/germplasm_column_casing.csv b/src/test/resources/files/germplasm_import/germplasm_column_casing.csv index 86c3b360f..f4c2e226a 100644 --- a/src/test/resources/files/germplasm_import/germplasm_column_casing.csv +++ b/src/test/resources/files/germplasm_import/germplasm_column_casing.csv @@ -1,2 +1,2 @@ -Name,BREEDING METHOD,SOURCE,fEmAlE pArEnT gId,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germ A,ANE,the shire,,,1,,,ABC-123, +GID,Name,BREEDING METHOD,SOURCE,fEmAlE pArEnT gId,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germ A,ANE,the shire,,,1,,,ABC-123, diff --git a/src/test/resources/files/germplasm_import/male_dbid_no_female_success.csv b/src/test/resources/files/germplasm_import/male_dbid_no_female_success.csv index 37625d690..23d9a47d8 100644 --- a/src/test/resources/files/germplasm_import/male_dbid_no_female_success.csv +++ b/src/test/resources/files/germplasm_import/male_dbid_no_female_success.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,,Wild,,100,,,,, -Germplasm 2,,Cultivated,,101,,,,, -Germplasm 3,,Kinda Wild,,102,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,,Wild,,100,,,,, +,Germplasm 2,,Cultivated,,101,,,,, +,Germplasm 3,,Kinda Wild,,102,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/male_dbid_not_exist.csv b/src/test/resources/files/germplasm_import/male_dbid_not_exist.csv index 65ee23994..f01b9a62d 100644 --- a/src/test/resources/files/germplasm_import/male_dbid_not_exist.csv +++ b/src/test/resources/files/germplasm_import/male_dbid_not_exist.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,100,,,,, -Germplasm 2,BCR,Cultivated,,101,,,,, -Germplasm 3,BCR,Kinda Wild,,102,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,100,,,,, +,Germplasm 2,BCR,Cultivated,,101,,,,, +,Germplasm 3,BCR,Kinda Wild,,102,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/male_entry_number_not_exist.csv b/src/test/resources/files/germplasm_import/male_entry_number_not_exist.csv index d0ca41fe7..bfa7f9c0d 100644 --- a/src/test/resources/files/germplasm_import/male_entry_number_not_exist.csv +++ b/src/test/resources/files/germplasm_import/male_entry_number_not_exist.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,,,1,, -Germplasm 2,BCR,Cultivated,,,,,2,, -Germplasm 3,BCR,Kinda Wild,,,,,3,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,,,1,, +,Germplasm 2,BCR,Cultivated,,,,,2,, +,Germplasm 3,BCR,Kinda Wild,,,,,3,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/minimal_germplasm_import.csv b/src/test/resources/files/germplasm_import/minimal_germplasm_import.csv index 122209184..acb35b785 100644 --- a/src/test/resources/files/germplasm_import/minimal_germplasm_import.csv +++ b/src/test/resources/files/germplasm_import/minimal_germplasm_import.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,,,,, -Germplasm 2,BCR,Cultivated,,,,,,, -Germplasm 3,BCR,Kinda Wild,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,,,,, +,Germplasm 2,BCR,Cultivated,,,,,,, +,Germplasm 3,BCR,Kinda Wild,,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/missing_optional_header.csv b/src/test/resources/files/germplasm_import/missing_optional_header.csv index 8ae96df57..0b1844cbb 100644 --- a/src/test/resources/files/germplasm_import/missing_optional_header.csv +++ b/src/test/resources/files/germplasm_import/missing_optional_header.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,ANE,Wild,,,,,, -Germplasm 2,ANE,Wild,,,,,, -Germplasm 3,ANE,Wild,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,ANE,Wild,,,,,, +,Germplasm 2,ANE,Wild,,,,,, +,Germplasm 3,ANE,Wild,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/missing_required_header.csv b/src/test/resources/files/germplasm_import/missing_required_header.csv index b1e28abda..584bfac1a 100644 --- a/src/test/resources/files/germplasm_import/missing_required_header.csv +++ b/src/test/resources/files/germplasm_import/missing_required_header.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,,,,,,,, -Germplasm 2,,,,,,,, -Germplasm 3,,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,,,,,,,, +,Germplasm 2,,,,,,,, +,Germplasm 3,,,,,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/no_female_parent_blank_pedigree.csv b/src/test/resources/files/germplasm_import/no_female_parent_blank_pedigree.csv index fb38a4850..8d1a4b461 100644 --- a/src/test/resources/files/germplasm_import/no_female_parent_blank_pedigree.csv +++ b/src/test/resources/files/germplasm_import/no_female_parent_blank_pedigree.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,0,2,,,,1234, -Germplasm 2,BCR,Wild,0,3,,,,5678, -Germplasm 3,BCR,Wild,0,3,,,,9123, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,0,2,,,,1234, +,Germplasm 2,BCR,Wild,0,3,,,,5678, +,Germplasm 3,BCR,Wild,0,3,,,,9123, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/nonnumerical_entry_numbers.csv b/src/test/resources/files/germplasm_import/nonnumerical_entry_numbers.csv index 8bc876d69..fbca1ed3d 100644 --- a/src/test/resources/files/germplasm_import/nonnumerical_entry_numbers.csv +++ b/src/test/resources/files/germplasm_import/nonnumerical_entry_numbers.csv @@ -1,5 +1,5 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,,Wild,,,a,,,, -Germplasm 2,,Wild,,,b,,,, -Germplasm 3,,Wild,,,3,,,, -Germplasm 4,,Wild,,,4,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,,Wild,,,a,,,, +,Germplasm 2,,Wild,,,b,,,, +,Germplasm 3,,Wild,,,3,,,, +,Germplasm 4,,Wild,,,4,,,, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/self_ref_parent_dependencies.csv b/src/test/resources/files/germplasm_import/self_ref_parent_dependencies.csv index 8f6e3de46..16144b020 100644 --- a/src/test/resources/files/germplasm_import/self_ref_parent_dependencies.csv +++ b/src/test/resources/files/germplasm_import/self_ref_parent_dependencies.csv @@ -1,4 +1,4 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,1,1,1,1234, -Germplasm 2,BCR,Wild,,,2,2,2,5678, -Germplasm 3,BCR,Wild,,,3,3,3,9123, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,1,1,1,1234, +,Germplasm 2,BCR,Wild,,,2,2,2,5678, +,Germplasm 3,BCR,Wild,,,3,3,3,9123, \ No newline at end of file diff --git a/src/test/resources/files/germplasm_import/some_entry_numbers.csv b/src/test/resources/files/germplasm_import/some_entry_numbers.csv index 77373d9cf..b86064c06 100644 --- a/src/test/resources/files/germplasm_import/some_entry_numbers.csv +++ b/src/test/resources/files/germplasm_import/some_entry_numbers.csv @@ -1,5 +1,5 @@ -Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms -Germplasm 1,BCR,Wild,,,1,,,, -Germplasm 2,BCR,Wild,,,,,,, -Germplasm 3,BCR,Wild,,,3,,,, -Germplasm 4,BCR,Wild,,,,,,, \ No newline at end of file +GID,Name,Breeding Method,Source,Female Parent GID,Male Parent GID,Entry No,Female Parent Entry No,Male Parent Entry No,External UID,Synonyms +,Germplasm 1,BCR,Wild,,,1,,,, +,Germplasm 2,BCR,Wild,,,,,,, +,Germplasm 3,BCR,Wild,,,3,,,, +,Germplasm 4,BCR,Wild,,,,,,, \ No newline at end of file