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

Commit 5935a0a

Browse files
fix program search by person name
1 parent cefa17d commit 5935a0a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/java/org/brapi/test/BrAPITestServer/service/SearchQueryBuilder.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Map<String, Object> getParams() {
4040
public Class<T> getClazz() {
4141
return clazz;
4242
}
43-
43+
4444
public SearchQueryBuilder<T> appendList(List<String> list, String columnName) {
4545
String paramName = paramFilter(columnName);
4646
if (list != null && !list.isEmpty()) {
@@ -156,6 +156,21 @@ public SearchQueryBuilder<T> appendNumberRange(BigDecimal min, BigDecimal max, S
156156
return this;
157157
}
158158

159+
public SearchQueryBuilder<T> appendPersonNamesList(List<String> list, String columnFirst, String columnMiddle, String columnLast) {
160+
if (list != null && !list.isEmpty()) {
161+
this.params.put("namesList", list);
162+
this.query += "AND (" + entityPrefix(columnFirst) + " in :namesList ";
163+
this.query += "OR " + entityPrefix(columnMiddle) + " in :namesList ";
164+
this.query += "OR " + entityPrefix(columnLast) + " in :namesList ";
165+
this.query += "OR concat(" + entityPrefix(columnFirst) + ", ' ', " + entityPrefix(columnMiddle) + ") in :namesList ";
166+
this.query += "OR concat(" + entityPrefix(columnFirst) + ", ' ', " + entityPrefix(columnLast) + ") in :namesList ";
167+
this.query += "OR concat(" + entityPrefix(columnMiddle) + ", ' ', " + entityPrefix(columnLast) + ") in :namesList ";
168+
this.query += "OR concat(" + entityPrefix(columnFirst) + ", ' ', " + entityPrefix(columnMiddle) + ", ' ', " + entityPrefix(columnLast) + ") in :namesList ";
169+
this.query += ") ";
170+
}
171+
return this;
172+
}
173+
159174
public SearchQueryBuilder<T> appendGeoJSONArea(GeoJSONSearchArea area) {
160175
// if (single != null && !single.isEmpty()) {
161176
// this.query += "AND " + entityPrefix(columnName) + " = :" + columnName + " ";

src/main/java/org/brapi/test/BrAPITestServer/service/core/ProgramService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public List<Program> findPrograms(ProgramSearchRequest request, Metadata metadat
6464
.appendList(request.getAbbreviations(), "abbreviation")
6565
.appendList(request.getCommonCropNames(), "crop.cropName")
6666
.appendList(request.getLeadPersonDbIds(), "leadPerson.id")
67-
.appendList(request.getLeadPersonNames(), "leadPerson.lastName")
67+
.appendPersonNamesList(request.getLeadPersonNames(), "leadPerson.firstName", "leadPerson.middleName", "leadPerson.lastName")
6868
.appendList(request.getObjectives(), "objective").appendList(request.getProgramDbIds(), "id")
6969
.appendList(request.getProgramNames(), "name");
7070

0 commit comments

Comments
 (0)