Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public BrAPIObservationUnit constructBrAPIObservationUnit(
String seqVal,
boolean commit,
String germplasmName,
String gid,
String referenceSource,
UUID trialID,
UUID datasetId,
Expand All @@ -250,6 +251,7 @@ public BrAPIObservationUnit constructBrAPIObservationUnit(
germplasmName = getGermplasmName();
}
observationUnit.setGermplasmName(germplasmName);
observationUnit.putAdditionalInfoItem(BrAPIAdditionalInfoFields.GID, gid);

BrAPIObservationUnitPosition position = new BrAPIObservationUnitPosition();
BrAPIObservationUnitLevelRelationship level = new BrAPIObservationUnitLevelRelationship();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ private PendingImportObject<BrAPIObservationUnit> fetchOrCreateObsUnitPIO(Progra
PendingImportObject<BrAPIStudy> studyPIO = this.studyByNameNoScope.get(importRow.getEnv());
UUID studyID = studyPIO.getId();
UUID id = UUID.randomUUID();
BrAPIObservationUnit newObservationUnit = importRow.constructBrAPIObservationUnit(program, envSeqValue, commit, germplasmName, BRAPI_REFERENCE_SOURCE, trialID, datasetId, studyID, id);
BrAPIObservationUnit newObservationUnit = importRow.constructBrAPIObservationUnit(program, envSeqValue, commit, germplasmName, importRow.getGid(), BRAPI_REFERENCE_SOURCE, trialID, datasetId, studyID, id);

// check for existing units if this is an existing study
if (studyPIO.getBrAPIObject().getStudyDbId() != null) {
Expand Down Expand Up @@ -1291,16 +1291,15 @@ private void updateStudyDbId(BrAPIStudy study, String programKey) {
private void updateGermplasmDbId(BrAPIGermplasm germplasm) {
this.observationUnitByNameNoScope.values()
.stream()
.filter(obsUnit -> obsUnit.getBrAPIObject()
.getGermplasmName() != null &&
obsUnit.getBrAPIObject()
.getGermplasmName()
.equals(germplasm.getGermplasmName()))
.filter(obsUnit -> germplasm.getAccessionNumber() != null &&
germplasm.getAccessionNumber().equals(obsUnit
.getBrAPIObject()
.getAdditionalInfo().getAsJsonObject()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a migration to add gids to existing observation units additionalinfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most existing OUs have the correct gemplasm dbId assigned, so a migration adding the GID wouldn't matter either way for them. It's a question more for Alex and Shawn to estimate how many cases of existing OUs using germplasm there are. They haven't com across this until now, so I'm guessing it's a small number where manually fixing it in the species database would make more sense. I'm not sure what a migration would look like. It wouldn't be a case of just adding the GID to the OU additional info since the existing id in the OU germplasmDbId field could be wrong. You couldn't easily tell if it was right or wrong, and if it's wrong, it's not clear which germplasmDbId would be correct? So a migration just looks like re-importing the experiment with bug fix in place.

.get(BrAPIAdditionalInfoFields.GID).getAsString()))
.forEach(obsUnit -> obsUnit.getBrAPIObject()
.setGermplasmDbId(germplasm.getGermplasmDbId()));
}


private void updateStudyDependencyValues(Map<Integer, PendingImport> mappedBrAPIImport, String programKey) {
// update location DbIds in studies for all distinct locations
mappedBrAPIImport.values()
Expand Down