Skip to content
Open
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 @@ -43,6 +43,7 @@
import org.breedinginsight.brapps.importer.services.processors.experiment.create.workflow.steps.PopulateNewPendingImportObjectsStep;
import org.breedinginsight.brapps.importer.services.processors.experiment.create.workflow.steps.ValidatePendingImportObjectsStep;
import org.breedinginsight.brapps.importer.services.processors.experiment.services.ExperimentPhenotypeService;
import org.breedinginsight.services.exceptions.UnprocessableEntityException;
import org.breedinginsight.services.exceptions.ValidatorException;

import javax.inject.Inject;
Expand All @@ -57,6 +58,7 @@

import javax.inject.Singleton;

import static org.breedinginsight.brapps.importer.services.processors.experiment.model.ExpImportProcessConstants.ErrMessage.MULTIPLE_EXP_TITLES;
import static org.breedinginsight.brapps.importer.services.processors.experiment.model.ExpImportProcessConstants.OBSERVATION_UNIT_ID_SUFFIX;

@Slf4j
Expand Down Expand Up @@ -99,6 +101,12 @@ private ImportPreviewResponse runWorkflow(ImportContext context) throws Exceptio
throw new HttpStatusException(HttpStatus.UNPROCESSABLE_ENTITY, "ObsUnitIDs are detected");
}

//Make sure file only contains one exp title, check early cause avoids issues with titles corresponding to existing and new trials
List<ExperimentObservation> experimentImportRows = ExperimentUtilities.importRowsToExperimentObservations(importRows);
if (experimentImportRows.stream().map(ExperimentObservation::getExpTitle).distinct().count() > 1) {
throw new UnprocessableEntityException(MULTIPLE_EXP_TITLES.getValue());
}

statusService.updateMessage(upload, "Checking existing experiment objects in brapi service and mapping data");

ProcessedPhenotypeData phenotypeData = experimentPhenotypeService.extractPhenotypes(context);
Expand Down
Loading