From 9dcc9b65e24dfb373a1bb69d462a3b254b3c5e24 Mon Sep 17 00:00:00 2001 From: Juhi Date: Fri, 17 Mar 2023 13:25:30 +0530 Subject: [PATCH] org search api engancements --- .../common/model/SBApiOrgSearchRequest.java | 26 ++++++++++++++----- .../common/model/SBApiSortByRequest.java | 15 ----------- .../org/sunbird/common/util/Constants.java | 3 ++- .../org/service/ExtendedOrgServiceImpl.java | 6 ++++- 4 files changed, 27 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/org/sunbird/common/model/SBApiSortByRequest.java diff --git a/src/main/java/org/sunbird/common/model/SBApiOrgSearchRequest.java b/src/main/java/org/sunbird/common/model/SBApiOrgSearchRequest.java index 1f102ac60..6f5b2c015 100644 --- a/src/main/java/org/sunbird/common/model/SBApiOrgSearchRequest.java +++ b/src/main/java/org/sunbird/common/model/SBApiOrgSearchRequest.java @@ -1,8 +1,21 @@ package org.sunbird.common.model; +import java.util.HashMap; +import java.util.Map; + public class SBApiOrgSearchRequest { private SBApiOrgFilterRequest filters = new SBApiOrgFilterRequest(); - private SBApiSortByRequest sort_by = new SBApiSortByRequest(); + + private Map sortBy = new HashMap<>(); + private String query; + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } public SBApiOrgFilterRequest getFilters() { return filters; @@ -12,11 +25,12 @@ public void setFilters(SBApiOrgFilterRequest filters) { this.filters = filters; } - public SBApiSortByRequest getSort_by() { - return sort_by; + public Map getSortBy() { + return sortBy; } - public void setSort_by(SBApiSortByRequest sort_by) { - this.sort_by = sort_by; + public void setSortBy(Map sortBy) { + this.sortBy = sortBy; } -} + +} \ No newline at end of file diff --git a/src/main/java/org/sunbird/common/model/SBApiSortByRequest.java b/src/main/java/org/sunbird/common/model/SBApiSortByRequest.java deleted file mode 100644 index f290a5507..000000000 --- a/src/main/java/org/sunbird/common/model/SBApiSortByRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sunbird.common.model; - -import org.sunbird.common.util.Constants; - -public class SBApiSortByRequest { - private String channel = Constants.ASC_ORDER; - - public String getChannel() { - return channel; - } - - public void setChannel(String channel) { - this.channel = channel; - } -} diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index c407763d5..52a2d7f01 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -635,7 +635,8 @@ public class Constants { public static final String CHECKS = "checks"; public static final String CASSANDRA_DB = "cassandra db"; public static final String REDIS_CACHE = "redis cache"; - + public static final String QUERY = "query"; + public static final String SORT_BY_KEYWORD = "sortBy"; private Constants() { throw new IllegalStateException("Utility class"); } diff --git a/src/main/java/org/sunbird/org/service/ExtendedOrgServiceImpl.java b/src/main/java/org/sunbird/org/service/ExtendedOrgServiceImpl.java index d2e313ebb..d0e15fd04 100644 --- a/src/main/java/org/sunbird/org/service/ExtendedOrgServiceImpl.java +++ b/src/main/java/org/sunbird/org/service/ExtendedOrgServiceImpl.java @@ -185,7 +185,11 @@ public SBApiResponse orgExtSearch(Map request) throws Exception }).collect(Collectors.toList()); SBApiOrgSearchRequest orgSearchRequest = new SBApiOrgSearchRequest(); orgSearchRequest.getFilters().setId(orgIdList); - + if(!ProjectUtil.isStringNullOREmpty((String) requestData.get(Constants.QUERY))) + { + orgSearchRequest.setQuery((String) requestData.get(Constants.QUERY)); + } + orgSearchRequest.setSortBy((Map) requestData.get(Constants.SORT_BY_KEYWORD)); Map orgSearchRequestBody = new HashMap() { private static final long serialVersionUID = 1L;