diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java index 3136d0fde..f4897b56b 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java @@ -108,8 +108,8 @@ public List getRawGermplasm(UUID programId) throws ApiException List cacheList = new ArrayList<>(programGermplasmCache.get(programId).values()); return cacheList.stream().map(germplasm -> { germplasm.setGermplasmName(Utilities.appendProgramKey(germplasm.getDefaultDisplayName(), program.getKey(), germplasm.getAccessionNumber())); - if(germplasm.getAdditionalInfo() != null && germplasm.getAdditionalInfo() - .has(BrAPIAdditionalInfoFields.GERMPLASM_RAW_PEDIGREE)) { + if(germplasm.getAdditionalInfo() != null && germplasm.getAdditionalInfo().has(BrAPIAdditionalInfoFields.GERMPLASM_RAW_PEDIGREE) + && !(germplasm.getAdditionalInfo().get(BrAPIAdditionalInfoFields.GERMPLASM_RAW_PEDIGREE).isJsonNull())) { germplasm.setPedigree(germplasm.getAdditionalInfo().get(BrAPIAdditionalInfoFields.GERMPLASM_RAW_PEDIGREE).getAsString()); } @@ -178,7 +178,6 @@ private Map processGermplasmForDisplay(List processGermplasmForDisplay(List parents = Arrays.asList(germplasm.getPedigree().split("/")); + List parents = Arrays.asList("",""); + if (germplasm.getPedigree() != null) { + parents = Arrays.asList(germplasm.getPedigree().split("/")); + } if (parents.size() >= 1) { if (programGermplasmByFullName.containsKey(parents.get(0))) { String femaleParentAccessionNumber = programGermplasmByFullName.get(parents.get(0)).getAccessionNumber(); @@ -212,10 +214,10 @@ private Map processGermplasmForDisplay(List processGermplasmForDisplay(List referenceSource.equals(reference.getReferenceSource())).findFirst().orElseThrow(() -> new IllegalStateException("No BI external reference found")); String germplasmId = extRef.getReferenceID();