Merge pull request #772 from emmanuelnnaa/MIFOSX-923
MIFOSX-923 - entity status property added to the search resultset
This commit is contained in:
+8
@@ -40,4 +40,12 @@ public class LoanStatusEnumData {
|
||||
public Long id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String code() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
+9
@@ -314,6 +314,15 @@ public class LoanEnumerations {
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData status(final LoanStatusEnumData status) {
|
||||
|
||||
Long id = status.id();
|
||||
String code = status.code();
|
||||
String value = status.value();
|
||||
|
||||
return new EnumOptionData(id, code, value);
|
||||
}
|
||||
|
||||
public static LoanStatusEnumData status(final Integer statusId) {
|
||||
return status(LoanStatus.fromInt(statusId));
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class SearchConstants {
|
||||
|
||||
public static enum SEARCH_RESPONSE_PARAMETERS {
|
||||
ENTITY_ID("entityId"), ENTITY_ACCOUNT_NO("entityAccountNo"), ENTITY_EXTERNAL_ID("entityExternalId"), ENTITY_NAME("entityName"), ENTITY_TYPE(
|
||||
"entityType"), PARENT_ID("parentId"), PARENT_NAME("parentName");
|
||||
"entityType"), PARENT_ID("parentId"), PARENT_NAME("parentName"), ENTITY_STATUS("entityStatus");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
+9
-1
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.search.data;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
|
||||
public class SearchData {
|
||||
|
||||
private final Long entityId;
|
||||
@@ -14,9 +16,10 @@ public class SearchData {
|
||||
private final String entityType;
|
||||
private final Long parentId;
|
||||
private final String parentName;
|
||||
private final EnumOptionData entityStatus;
|
||||
|
||||
public SearchData(final Long entityId, final String entityAccountNo, final String entityExternalId, final String entityName,
|
||||
final String entityType, final Long parentId, final String parentName) {
|
||||
final String entityType, final Long parentId, final String parentName, final EnumOptionData entityStatus) {
|
||||
|
||||
this.entityId = entityId;
|
||||
this.entityAccountNo = entityAccountNo;
|
||||
@@ -25,6 +28,7 @@ public class SearchData {
|
||||
this.entityType = entityType;
|
||||
this.parentId = parentId;
|
||||
this.parentName = parentName;
|
||||
this.entityStatus = entityStatus;
|
||||
}
|
||||
|
||||
public Long getEntityId() {
|
||||
@@ -54,5 +58,9 @@ public class SearchData {
|
||||
public String getParentName() {
|
||||
return this.parentName;
|
||||
}
|
||||
|
||||
public EnumOptionData getEntityStatus() {
|
||||
return this.entityStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+32
-9
@@ -30,6 +30,11 @@ import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.client.domain.ClientEnumerations;
|
||||
import org.mifosplatform.portfolio.group.domain.GroupingTypeEnumerations;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
|
||||
@Service
|
||||
public class SearchReadPlatformServiceImpl implements SearchReadPlatformService {
|
||||
@@ -69,39 +74,39 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
|
||||
|
||||
final String union = " union ";
|
||||
final String clientExactMatchSql = " (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo "
|
||||
+ " , c.office_id as parentId, o.name as parentName "
|
||||
+ " , c.office_id as parentId, o.name as parentName, c.status_enum as entityStatusEnum "
|
||||
+ " from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :search or c.display_name like :search or c.external_id like :search)) ";
|
||||
|
||||
final String clientMatchSql = " (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo "
|
||||
+ " , c.office_id as parentId, o.name as parentName "
|
||||
+ " , c.office_id as parentId, o.name as parentName, c.status_enum as entityStatusEnum "
|
||||
+ " from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :partialSearch and c.account_no not like :search) or "
|
||||
+ "(c.display_name like :partialSearch and c.display_name not like :search) or "
|
||||
+ "(c.external_id like :partialSearch and c.external_id not like :search))";
|
||||
|
||||
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 "
|
||||
+ " , 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) ";
|
||||
|
||||
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 "
|
||||
+ " , 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) ";
|
||||
|
||||
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 "
|
||||
+ " 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) ";
|
||||
|
||||
final String clientIdentifierMatchSql = " (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 "
|
||||
+ " 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 :partialSearch and ci.document_key not like :search) ";
|
||||
|
||||
final String groupExactMatchSql = " (select IF(g.level_id=1,'CENTER','GROUP') as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, NULL as entityAccountNo "
|
||||
+ " , g.office_id as parentId, o.name as parentName "
|
||||
+ " , g.office_id as parentId, o.name as parentName, g.status_enum as entityStatusEnum "
|
||||
+ " from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and (g.display_name like :search or g.external_id like :search)) ";
|
||||
|
||||
final String groupMatchSql = " (select IF(g.level_id=1,'CENTER','GROUP') as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, NULL as entityAccountNo "
|
||||
+ " , g.office_id as parentId, o.name as parentName "
|
||||
+ " , g.office_id as parentId, o.name as parentName, g.status_enum as entityStatusEnum "
|
||||
+ " from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and (g.display_name like :partialSearch and g.display_name not like :search) or (g.external_id like :partialSearch and g.external_id not like :search)) ";
|
||||
|
||||
final StringBuffer sql = new StringBuffer();
|
||||
@@ -155,7 +160,25 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
|
||||
final String entityType = rs.getString("entityType");
|
||||
final Long parentId = JdbcSupport.getLong(rs, "parentId");
|
||||
final String parentName = rs.getString("parentName");
|
||||
return new SearchData(entityId, entityAccountNo, entityExternalId, entityName, entityType, parentId, parentName);
|
||||
final Integer entityStatusEnum = JdbcSupport.getInteger(rs, "entityStatusEnum");
|
||||
|
||||
EnumOptionData entityStatus = new EnumOptionData(0L, "", "");
|
||||
|
||||
if(entityType.equalsIgnoreCase("client") || entityType.equalsIgnoreCase("clientidentifier")) {
|
||||
entityStatus = ClientEnumerations.status(entityStatusEnum);
|
||||
}
|
||||
|
||||
else if(entityType.equalsIgnoreCase("group") || entityType.equalsIgnoreCase("center")) {
|
||||
entityStatus = GroupingTypeEnumerations.status(entityStatusEnum);
|
||||
}
|
||||
|
||||
else if(entityType.equalsIgnoreCase("loan")) {
|
||||
LoanStatusEnumData loanStatusEnumData = LoanEnumerations.status(entityStatusEnum);
|
||||
|
||||
entityStatus = LoanEnumerations.status(loanStatusEnumData);
|
||||
}
|
||||
|
||||
return new SearchData(entityId, entityAccountNo, entityExternalId, entityName, entityType, parentId, parentName, entityStatus);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user