Skip to content
Merged
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 @@ -326,10 +326,9 @@ public Map<String, ImportPreviewStatistics> process(ImportUpload upload, List<Br
// Construct pedigree
constructPedigreeString(importRows, mappedBrAPIImport, commit);

// Construct a dependency tree for POSTing order. Dependents on unique germplasm name, (<Name> [<Program Key> - <Accession Number>])
if (commit) {
createPostOrder();
}
// for commit: Construct a dependency tree for POSTing order. Dependents on unique germplasm name, (<Name> [<Program Key> - <Accession Number>])
// for !commit: Validate for circular pedigree dependencies.
createPostOrder(commit);

// Construct our response object
return getStatisticsMap(importRows);
Expand Down Expand Up @@ -556,9 +555,18 @@ private void validatePedigree(Germplasm germplasm, Integer rowNumber, Validation
}
}

private void createPostOrder() {
/*
This will set the postOrder and validate for circular pedigree dependencies.
*/
private void createPostOrder(boolean commit) {
Set<String> created = null;
// Construct a dependency tree for POSTing order
Set<String> created = existingGermplasm.stream().map(BrAPIGermplasm::getGermplasmName).collect(Collectors.toSet());
if(commit){
created = existingGermplasm.stream().map(BrAPIGermplasm::getGermplasmName).collect(Collectors.toSet());
}
else {
created = existingGermplasm.stream().map(BrAPIGermplasm::getDefaultDisplayName).collect(Collectors.toSet());
}

//todo this gets messy

Expand All @@ -569,7 +577,7 @@ private void createPostOrder() {
for (BrAPIGermplasm germplasm : newGermplasmList) {

// If we've already planned this germplasm, skip
if (created.contains(germplasm.getGermplasmName())) {
if ( (commit && created.contains(germplasm.getGermplasmName())) || (!commit && created.contains(germplasm.getDefaultDisplayName())) ) {
continue;
}

Expand Down
Loading