Skip to content

Commit

Permalink
Merge pull request #930 from PhenoApps/brapi_trait_import_bugfix
Browse files Browse the repository at this point in the history
add nullability check before parsing categories into trait detail
  • Loading branch information
trife authored Apr 3, 2024
2 parents 97779e1 + 8004143 commit fd96d5d
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,25 @@ private Pair<List<TraitObject>, Integer> mapTraits(List<BrAPIObservationVariable
} else {
trait.setFormat("text");
}
//For categorical traits, include label value pairs in details
if (trait.getFormat().equals("categorical")) {
String details = trait.getDetails();

if (var.getScale() != null &&
var.getScale().getValidValues() != null &&
var.getScale().getValidValues().getCategories() != null &&
!var.getScale().getValidValues().getCategories().isEmpty()) {

List<BrAPIScaleValidValuesCategories> categories = var.getScale().getValidValues().getCategories();
details += "\nCategories: " + buildCategoryDescriptionString(categories);
}
trait.setDetails(details);
// try {
// trait.setAdditionalInfo(buildCategoryValueLabelJsonStr(var.getScale().getValidValues().getCategories()));
// } catch (Exception e) {
// Log.d("FieldBookError", "Error parsing trait label/value.");
// }
}
}

// The BMS implementation of BrAPI 2.x Variables includes an Observation Variable with observationLevelNames metadata in the additionalInfo field.
Expand Down

0 comments on commit fd96d5d

Please sign in to comment.