Skip to content

BI-1195 - 4.3 Exp Preview: Append Experiment with Observations#241

Merged
timparsons merged 15 commits intodevelopfrom
feature/BI-1195
Mar 9, 2023
Merged

BI-1195 - 4.3 Exp Preview: Append Experiment with Observations#241
timparsons merged 15 commits intodevelopfrom
feature/BI-1195

Conversation

@timparsons
Copy link
Member

@timparsons timparsons commented Feb 9, 2023

Description

Story: https://breedinginsight.atlassian.net/browse/BI-1195

  • Added support to recognize the ObsUnitId column in an experiment import file
    • will fetch existing observationunits by ObsUnitId
    • will fetch trials, studies, and locations if there is an ObsUnitId
  • Added validation to check for existing observations for a given OUxTrait combo
    • if there is, throw an error
  • Refactored the ExperimentProcessor to be easier to read
  • Updated the creation of new locations via the experiment import to create them in the BI database before creating them in the BrAPI server
  • Updated locations being created in a BrAPI server to have
    • the program key in the name
    • an external reference to the program
  • Created a Java-based migration to update existing locations with an external reference to the program
  • Created unit test for testing experiment file import

Dependencies

bi-web: Breeding-Insight/bi-web#302
sgn: Breeding-Insight/sgn#109

Testing

This code isn't testable via the UI with BreedBase until the UI to download an experiment with ObsUnitIds is implemented, however, you can hit the BrAPI endpoints to fetch the ObservationUnit external references that were generated by DeltaBreed to then put into an import file.

  1. Review the tests in ExperimentFileImportTest for coverage
  2. Run the ExperimentFileImportTest and verify all tests pass

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: https://github.com/Breeding-Insight/taf/actions/runs/4129982227

);
}

public Optional<BrAPIStudy> getStudyByDbId(String studyDbId, Program program) throws ApiException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think getStudyByDbId() is ever called

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, you're right. Thoughts on leaving it as I can see it being used at some point?

@@ -24,6 +24,7 @@
import org.breedinginsight.brapps.importer.model.config.ImportFieldType;
Copy link
Contributor

Choose a reason for hiding this comment

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

the statement import org.brapi.v2.model.core.BrAPILocation; is no longer needed.

import org.breedinginsight.model.User;
import org.breedinginsight.services.ProgramLocationService;
import org.breedinginsight.services.exceptions.ValidatorException;
import org.breedinginsight.utilities.Utilities;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused import statement

import org.brapi.client.v2.BrAPIClient;
import org.brapi.client.v2.model.exceptions.ApiException;
import org.brapi.client.v2.model.queryParams.phenotype.VariableQueryParams;
import org.brapi.client.v2.modules.core.LocationsApi;
Copy link
Contributor

Choose a reason for hiding this comment

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

unused import statement

ProgramLocation location = dsl.transactionResult(configuration -> {
programLocationDao.insert(placeEntity);
ProgramLocation progLocation = programLocationDao.getById(programId, placeEntity.getId()).get();
ProgramLocation progLocation = programLocationDao.getById(programId, placeEntity.getId(), false).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

'Optional.get()' without 'isPresent()' check

ProgramLocation location = dsl.transactionResult(configuration -> {
programLocationDao.update(placeEntity);
ProgramLocation progLocation = programLocationDao.getById(programId, placeEntity.getId()).get();
ProgramLocation progLocation = programLocationDao.getById(programId, placeEntity.getId(), false).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

'Optional.get()' without 'isPresent()' check

return ret;
}

private Map<String, Object> assertValidPreviewRow(Map<String, Object> expected, JsonObject actual, Program program, List<Trait> traits) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this private method ever called

Copy link
Member Author

@timparsons timparsons Mar 2, 2023

Choose a reason for hiding this comment

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

Not at the moment. I was thinking that there should probably be some tests added for preview of import (current tests are only focused on the full save), so it may be worth keeping this here. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense

@davedrp
Copy link
Contributor

davedrp commented Feb 24, 2023

Test failed - see the comment

@davedrp
Copy link
Contributor

davedrp commented Mar 1, 2023

Unit Test passed

@timparsons timparsons merged commit a13fe6e into develop Mar 9, 2023
@timparsons timparsons deleted the feature/BI-1195 branch March 9, 2023 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants