Merge pull request #1020 from okelekemike/develop

MIFOSX-1315 Global search should also search for saving account number a...
This commit is contained in:
Vishwas Babu A J
2014-07-21 21:36:53 -07:00
3 changed files with 36 additions and 8 deletions
@@ -72,7 +72,7 @@ public class SearchConstants {
}
public static enum SEARCH_SUPPORTED_RESOURCES {
CLIENTS("clients"), GROUPS("groups"), LOANS("loans"), CLIENTIDENTIFIERS("clientIdentifiers");
CLIENTS("clients"), GROUPS("groups"), LOANS("loans"), SAVINGS("savings"), CLIENTIDENTIFIERS("clientIdentifiers");
private final String value;
@@ -14,6 +14,7 @@ public class SearchConditions {
private final Boolean clientSearch;
private final Boolean groupSearch;
private final Boolean loanSeach;
private final Boolean savingSeach;
private final Boolean clientIdentifierSearch;
public SearchConditions(final String searchQueryParam, final String searchResource) {
@@ -25,17 +26,20 @@ public class SearchConditions {
SEARCH_SUPPORTED_RESOURCES.GROUPS.name().toLowerCase())) ? true : false;
this.loanSeach = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.LOANS.name().toLowerCase())) ? true : false;
this.clientIdentifierSearch = (null == searchResource || searchResource.toLowerCase().contains(
this.savingSeach = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.SAVINGS.name().toLowerCase())) ? true : false;
this.clientIdentifierSearch = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.CLIENTIDENTIFIERS.name().toLowerCase())) ? true : false;
}
public SearchConditions(final String searchQueryParam, final String searchResource, final Boolean clientSearch,
final Boolean groupSearch, final Boolean loanSeach, final Boolean clientIdentifierSearch) {
final Boolean groupSearch, final Boolean loanSeach, final Boolean savingSeach, final Boolean clientIdentifierSearch) {
this.searchQuery = searchQueryParam;
this.searchResource = searchResource;
this.clientSearch = clientSearch;
this.groupSearch = groupSearch;
this.loanSeach = loanSeach;
this.savingSeach = savingSeach;
this.clientIdentifierSearch = clientIdentifierSearch;
}
@@ -59,7 +63,11 @@ public class SearchConditions {
return this.loanSeach;
}
public Boolean isClientIdentifierSearch() {
public Boolean isSavingSeach() {
return this.savingSeach;
}
public Boolean isClientIdentifierSearch() {
return this.clientIdentifierSearch;
}
@@ -85,13 +85,25 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
final String loanExactMatchSql = " (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo "
+ " , c.id as parentId, c.display_name as parentName, l.loan_status_id as entityStatusEnum "
+ " from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and l.account_no like :search) ";
+ " from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and (l.account_no like :search or l.external_id like :search)) ";
final String loanMatchSql = " (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo "
+ " , c.id as parentId, c.display_name as parentName, l.loan_status_id as entityStatusEnum "
+ " from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and l.account_no like :partialSearch and l.account_no not like :search) ";
+ " from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and "
+ " ((l.account_no like :partialSearch and l.account_no not like :search) or (l.external_id like :partialSearch and l.external_id not like :search))) ";
final String clientIdentifierExactMatchSql = " (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, "
final String savingExactMatchSql = " (select 'SAVING' as entityType, s.id as entityId, sp.name as entityName, s.external_id as entityExternalId, s.account_no as entityAccountNo "
+ " , c.id as parentId, c.display_name as parentName, s.status_enum as entityStatusEnum "
+ " from m_savings_account s join m_client c on s.client_id = c.id join m_office o on o.id = c.office_id join m_savings_product sp on sp.id=s.product_id "
+ " where o.hierarchy like :hierarchy and (s.account_no like :search or s.external_id like :search)) ";
final String savingMatchSql = " (select 'SAVING' as entityType, s.id as entityId, sp.name as entityName, s.external_id as entityExternalId, s.account_no as entityAccountNo "
+ " , c.id as parentId, c.display_name as parentName, s.status_enum as entityStatusEnum "
+ " from m_savings_account s join m_client c on s.client_id = c.id join m_office o on o.id = c.office_id join m_savings_product sp on sp.id=s.product_id "
+ " where o.hierarchy like :hierarchy and (s.account_no like :partialSearch and s.account_no not like :search) or "
+ "(s.external_id like :partialSearch and s.external_id not like :search)) ";
final String clientIdentifierExactMatchSql = " (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, "
+ " null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName, c.status_enum as entityStatusEnum "
+ " from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id "
+ " where o.hierarchy like :hierarchy and ci.document_key like :search) ";
@@ -120,7 +132,11 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
sql.append(loanExactMatchSql).append(union);
}
if (searchConditions.isClientIdentifierSearch()) {
if (searchConditions.isSavingSeach()) {
sql.append(savingExactMatchSql).append(union);
}
if (searchConditions.isClientIdentifierSearch()) {
sql.append(clientIdentifierExactMatchSql).append(union);
}
@@ -137,6 +153,10 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
sql.append(loanMatchSql).append(union);
}
if (searchConditions.isSavingSeach()) {
sql.append(savingMatchSql).append(union);
}
if (searchConditions.isClientIdentifierSearch()) {
sql.append(clientIdentifierMatchSql).append(union);
}