-
Notifications
You must be signed in to change notification settings - Fork 1
[BI-2778] Deprecate additionalinfo usage for level and use obs unit lvl #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HMS17
wants to merge
9
commits into
develop
Choose a base branch
from
feature/BI-2778
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ddaf750
[BI-2778] Deprecate additionalinfo usage for level and use obs unit l…
HMS17 5379e4a
[BI-2778] Tests casing fix
HMS17 7074247
[BI-2778] Export file casing fix
HMS17 d5e532c
[BI-2778] Fixes
HMS17 81a7a85
[BI-2778] Casing test
HMS17 e4cae76
[BI-2778] Another casing fix
HMS17 341c310
[BI-2778] Null pointer fix re treatment factors
HMS17 7db5470
[BI-2778] Test fix
HMS17 a80a381
[BI-2778] Unit test experiment
HMS17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,7 +222,7 @@ public DownloadFile exportObservations( | |
| columns = dynamicUpdateObsUnitIDLabel(columns, topObservationLvl); | ||
| } | ||
| } | ||
| String observationLvl = ous.get(0).getAdditionalInfo().get(BrAPIAdditionalInfoFields.OBSERVATION_LEVEL).getAsString(); | ||
| String observationLvl = StringUtils.capitalize(ous.get(0).getObservationUnitPosition().getObservationLevel().getLevelName()); | ||
| columns = dynamicUpdateObsUnitIDLabel(columns, observationLvl); | ||
|
|
||
| if (params.getDatasetId() != null) { | ||
|
|
@@ -576,7 +576,7 @@ public BrAPIObservationUnit createSubObservationUnit( | |
| } | ||
|
|
||
| // Set treatment factors. | ||
| if (!expUnit.getTreatments().isEmpty()) { | ||
| if (!(expUnit.getTreatments() == null || expUnit.getTreatments().isEmpty())) { | ||
| List<BrAPIObservationTreatment> treatmentFactors = new ArrayList<>(); | ||
| for (BrAPIObservationTreatment t : expUnit.getTreatments()) { | ||
| BrAPIObservationTreatment treatment = new BrAPIObservationTreatment(); | ||
|
|
@@ -587,9 +587,6 @@ public BrAPIObservationUnit createSubObservationUnit( | |
| observationUnit.setTreatments(treatmentFactors); | ||
| } | ||
|
|
||
| // Put level in additional info: keep this in case we decide to rename levels in future. | ||
| observationUnit.putAdditionalInfoItem(BrAPIAdditionalInfoFields.OBSERVATION_LEVEL, subEntityDatasetName); | ||
|
|
||
| // Put RTK in additional info. | ||
| JsonElement rtk = expUnit.getAdditionalInfo().get(BrAPIAdditionalInfoFields.RTK); | ||
| if (rtk != null) { | ||
|
|
@@ -641,16 +638,13 @@ public BrAPIObservationUnit createSubObservationUnit( | |
| } | ||
| // ObservationLevelRelationships for top-level Exp Unit linking. | ||
| BrAPIObservationUnitLevelRelationship expUnitLevel = new BrAPIObservationUnitLevelRelationship(); | ||
| // TODO: switch to using level name in main obs unit properties once dynamic obs unit support is complete | ||
| expUnitLevel.setLevelName(expUnit.getAdditionalInfo().get(BrAPIAdditionalInfoFields.OBSERVATION_LEVEL).getAsString().toLowerCase()); | ||
| expUnitLevel.setLevelName(expUnit.getObservationUnitPosition().getObservationLevel().getLevelName().toLowerCase()); | ||
| String expUnitUUID = Utilities.getExternalReference(expUnit.getExternalReferences(), referenceSource, ExternalReferenceSource.OBSERVATION_UNITS).orElseThrow().getReferenceId(); | ||
| expUnitLevel.setLevelCode(Utilities.appendProgramKey(expUnitUUID, program.getKey(), seqVal)); | ||
| expUnitLevel.setLevelOrder(DatasetLevel.EXP_UNIT.getValue()); | ||
| levelRelationships.add(expUnitLevel); | ||
| position.setObservationLevelRelationships(levelRelationships); | ||
|
|
||
| observationUnit.putAdditionalInfoItem(BrAPIAdditionalInfoFields.EXP_UNIT_ID, expUnit.getObservationUnitName()); | ||
|
|
||
| // Set ObservationUnitPosition. | ||
| observationUnit.setObservationUnitPosition(position); | ||
|
|
||
|
|
@@ -884,7 +878,7 @@ private Map<String, Object> createExportRow( | |
| } | ||
|
|
||
| //Append observation level to obsUnitID | ||
| String observationLvl = ou.getAdditionalInfo().getAsJsonObject().get(BrAPIAdditionalInfoFields.OBSERVATION_LEVEL).getAsString(); | ||
| String observationLvl = StringUtils.capitalize(ou.getObservationUnitPosition().getObservationLevel().getLevelName()); | ||
| row.put(observationLvl + " " + OBSERVATION_UNIT_ID_SUFFIX, ouId); | ||
|
|
||
| if (isSubEntity) { | ||
|
|
@@ -897,13 +891,13 @@ private Map<String, Object> createExportRow( | |
| String topLvlOuId = Utilities.removeProgramKeyAndUnknownAdditionalData(topLevel.getLevelCode(), program.getKey()); | ||
| row.put(topLvlName + " " + OBSERVATION_UNIT_ID_SUFFIX, topLvlOuId); | ||
| } | ||
| row.put(ExperimentObservation.Columns.EXP_UNIT_ID, ou.getAdditionalInfo().get(BrAPIAdditionalInfoFields.EXP_UNIT_ID).getAsString()); | ||
| row.put(ExperimentObservation.Columns.EXP_UNIT_ID, StringUtils.capitalize(getTopLevel(ou).getLevelName())); | ||
|
|
||
| row.put(ExperimentObservation.Columns.SUB_OBS_UNIT, ou.getAdditionalInfo().getAsJsonObject().get(BrAPIAdditionalInfoFields.OBSERVATION_LEVEL).getAsString()); | ||
| row.put(ExperimentObservation.Columns.SUB_OBS_UNIT, StringUtils.capitalize(ou.getObservationUnitPosition().getObservationLevel().getLevelName())); | ||
| row.put(ExperimentObservation.Columns.SUB_UNIT_ID, Utilities.removeProgramKeyAndUnknownAdditionalData(ou.getObservationUnitName(), program.getKey())); | ||
|
|
||
| } else { | ||
| row.put(ExperimentObservation.Columns.EXP_UNIT, ou.getAdditionalInfo().getAsJsonObject().get(BrAPIAdditionalInfoFields.OBSERVATION_LEVEL).getAsString()); | ||
| row.put(ExperimentObservation.Columns.EXP_UNIT, StringUtils.capitalize(ou.getObservationUnitPosition().getObservationLevel().getLevelName())); | ||
| row.put(ExperimentObservation.Columns.EXP_UNIT_ID, Utilities.removeProgramKeyAndUnknownAdditionalData(ou.getObservationUnitName(), program.getKey())); | ||
| } | ||
|
|
||
|
|
@@ -995,7 +989,7 @@ private void sortDefaultForObservationUnit(List<BrAPIObservationUnit> ous) { | |
|
|
||
| if (isSubEntityDataset(ous)) { | ||
| Comparator<BrAPIObservationUnit> subUnitComparator = Comparator.comparing(BrAPIObservationUnit::getObservationUnitName, new IntOrderComparator()); | ||
| Comparator<BrAPIObservationUnit> ouNameComparator = Comparator.comparing(row -> (row.getAdditionalInfo().get(BrAPIAdditionalInfoFields.EXP_UNIT_ID).toString()), new IntOrderComparator()); | ||
| Comparator<BrAPIObservationUnit> ouNameComparator = Comparator.comparing(row -> (getTopLevel(row).getLevelName()), new IntOrderComparator()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it ok to swap the logic for exp unit id with level name? |
||
| ous.sort((studyNameComparator).thenComparing(ouNameComparator).thenComparing(subUnitComparator)); | ||
| } | ||
| else { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to swap the logic for exp unit id with level name?