Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit fb1a01f

Browse files
committed
Handle empty name search use case in GermService, add mother/father warn logs
1 parent 4836f33 commit fb1a01f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/java/org/brapi/test/BrAPITestServer/service/germ/GermplasmService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,13 @@ private void updateSynonymEntities(List<GermplasmNewRequestSynonyms> synonyms, G
772772
}
773773

774774
public List<GermplasmEntity> findByNames(List<String> germplasmNames) {
775-
return germplasmRepository.findByGermplasmNameIn(germplasmNames);
775+
List<GermplasmEntity> foundGerms = new ArrayList<>();
776+
777+
if (!germplasmNames.isEmpty()) {
778+
foundGerms = germplasmRepository.findByGermplasmNameIn(germplasmNames);
779+
}
780+
781+
return foundGerms;
776782
}
777783

778784
public List<GermplasmEntity> findByIds(List<String> germplasmDbIds)

src/main/java/org/brapi/test/BrAPITestServer/service/germ/PedigreeService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,17 @@ public List<PedigreeNode> convertFromGermplasmToPedigreeBatchUsingNames(List<Ger
827827
}
828828

829829
List<GermplasmEntity> motherGerms = germplasmService.findByNames(new ArrayList<>(germsByPedigreeMother.values()));
830+
831+
if (motherGerms.isEmpty() && !germsByPedigreeMother.isEmpty()) {
832+
log.warn("Could not find any germplasms looking up with mother names {}", germsByPedigreeMother.values());
833+
}
834+
830835
List<GermplasmEntity> fatherGerms = germplasmService.findByNames(new ArrayList<>(germsByPedigreeFather.values()));
831836

837+
if (fatherGerms.isEmpty() && !germsByPedigreeFather.isEmpty()) {
838+
log.warn("Could not find any germplasms looking up with father names {}", germsByPedigreeFather.values());
839+
}
840+
832841
for (Germplasm germplasm : germplasms) {
833842
GermplasmEntity motherGerm = null;
834843
GermplasmEntity fatherGerm = null;

0 commit comments

Comments
 (0)