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 @@ -59,6 +59,7 @@
import org.breedinginsight.services.ProgramLocationService;
import org.breedinginsight.services.exceptions.DoesNotExistException;
import org.breedinginsight.services.exceptions.MissingRequiredInfoException;
import org.breedinginsight.services.exceptions.UnprocessableEntityException;
import org.breedinginsight.services.exceptions.ValidatorException;
import org.breedinginsight.utilities.Utilities;
import org.jooq.DSLContext;
Expand All @@ -85,6 +86,7 @@ public class ExperimentProcessor implements Processor {
"If you’re trying to add these units to the experiment, please create a new environment" +
" with all appropriate experiment units (NOTE: this will generate new Observation Unit Ids " +
"for each experiment unit).";
private static final String MULTIPLE_EXP_TITLES = "File contains more than one Experiment Title";
private static final String MIDNIGHT = "T00:00:00-00:00";
private static final String TIMESTAMP_PREFIX = "TS:";
private static final String TIMESTAMP_REGEX = "^"+TIMESTAMP_PREFIX+"\\s*";
Expand Down Expand Up @@ -476,7 +478,12 @@ private void initNewBrapiData(List<BrAPIImport> importRows, List<Column<?>> phen
for (int rowNum = 0; rowNum < importRows.size(); rowNum++) {
ExperimentObservation importRow = (ExperimentObservation) importRows.get(rowNum);

PendingImportObject<BrAPITrial> trialPIO = fetchOrCreateTrialPIO(program, user, commit, importRow, expNextVal);
PendingImportObject<BrAPITrial> trialPIO = null;
try {
trialPIO = fetchOrCreateTrialPIO(program, user, commit, importRow, expNextVal);
} catch (UnprocessableEntityException e) {
throw new HttpStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage());
}

String expSeqValue = null;
if (commit) {
Expand Down Expand Up @@ -552,7 +559,6 @@ private ValidationErrors validateFields(List<BrAPIImport> importRows, Validation
for (int rowNum = 0; rowNum < importRows.size(); rowNum++) {
ExperimentObservation importRow = (ExperimentObservation) importRows.get(rowNum);
PendingImport mappedImportRow = mappedBrAPIImport.get(rowNum);

if (StringUtils.isNotBlank(importRow.getGid())) { // if GID is blank, don't bother to check if it is valid.
validateGermplasm(importRow, validationErrors, rowNum, mappedImportRow.getGermplasm());
}
Expand Down Expand Up @@ -981,10 +987,12 @@ private PendingImportObject<ProgramLocation> fetchOrCreateLocationPIO(Experiment
return pio;
}

private PendingImportObject<BrAPITrial> fetchOrCreateTrialPIO(Program program, User user, boolean commit, ExperimentObservation importRow, Supplier<BigInteger> expNextVal) {
private PendingImportObject<BrAPITrial> fetchOrCreateTrialPIO(Program program, User user, boolean commit, ExperimentObservation importRow, Supplier<BigInteger> expNextVal) throws UnprocessableEntityException {
PendingImportObject<BrAPITrial> pio;
if (trialByNameNoScope.containsKey(importRow.getExpTitle())) {
pio = trialByNameNoScope.get(importRow.getExpTitle());
} else if (!trialByNameNoScope.isEmpty()) {
throw new UnprocessableEntityException(MULTIPLE_EXP_TITLES);
} else {
UUID id = UUID.randomUUID();
String expSeqValue = null;
Expand Down