Skip to content

Commit

Permalink
Merge pull request #493 from egovernments/client-audit-details-addres…
Browse files Browse the repository at this point in the history
…s-issue

fixing address fields position in row mapper
  • Loading branch information
kanishq-egov authored Sep 13, 2023
2 parents f473183 + cfc45c5 commit 70e7334
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public List<Facility> findById(List<String> ids, String columnName, Boolean incl
}
}

String query = String.format("SELECT * FROM facility f LEFT JOIN address a ON f.addressid = a.id WHERE f.%s IN (:ids) AND isDeleted = false", columnName);
String query = String.format("SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM facility f LEFT JOIN address a ON f.addressid = a.id WHERE f.%s IN (:ids) AND isDeleted = false", columnName);
if (null != includeDeleted && includeDeleted) {
query = String.format("SELECT * FROM facility f LEFT JOIN address a ON f.addressid = a.id WHERE f.%s IN (:ids)", columnName);
query = String.format("SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM facility f LEFT JOIN address a ON f.addressid = a.id WHERE f.%s IN (:ids)", columnName);
}
Map<String, Object> paramMap = new HashMap();
paramMap.put("ids", ids);
Expand All @@ -61,7 +61,7 @@ public List<Facility> findById(List<String> ids, String columnName, Boolean incl
}

public List<Facility> find(FacilitySearch searchObject, Integer limit, Integer offset, String tenantId, Long lastChangedSince, Boolean includeDeleted) throws QueryBuilderException {
String query = "SELECT * FROM facility f LEFT JOIN address a ON f.addressid = a.id";
String query = "SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM facility f LEFT JOIN address a ON f.addressid = a.id";
Map<String, Object> paramsMap = new HashMap<>();
List<String> whereFields = GenericQueryBuilder.getFieldsWithCondition(searchObject, QueryFieldChecker.isNotNull, paramsMap);
query = GenericQueryBuilder.generateQuery(query, whereFields).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public Facility mapRow(ResultSet resultSet, int i) throws SQLException {
.usage(resultSet.getString("usage"))
.storageCapacity(resultSet.getInt("storageCapacity"))
.address(Address.builder()
.id(resultSet.getString(15))
.tenantId(resultSet.getString(16))
.id(resultSet.getString("aid"))
.tenantId(resultSet.getString("atenantid"))
.doorNo(resultSet.getString("doorNo"))
.latitude(resultSet.getDouble("latitude"))
.longitude(resultSet.getDouble("longitude"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public List<Household> findById(List<String> ids, String columnName, Boolean inc
}
}

String query = String.format("SELECT * FROM household h LEFT JOIN address a ON h.addressid = a.id WHERE h.%s IN (:ids) AND isDeleted = false", columnName);
String query = String.format("SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM household h LEFT JOIN address a ON h.addressid = a.id WHERE h.%s IN (:ids) AND isDeleted = false", columnName);
if (null != includeDeleted && includeDeleted) {
query = String.format("SELECT * FROM household h LEFT JOIN address a ON h.addressid = a.id WHERE h.%s IN (:ids)", columnName);
query = String.format("SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM household h LEFT JOIN address a ON h.addressid = a.id WHERE h.%s IN (:ids)", columnName);
}
Map<String, Object> paramMap = new HashMap();
paramMap.put("ids", ids);
Expand All @@ -65,7 +65,7 @@ public List<Household> findById(List<String> ids, String columnName, Boolean inc
}

public List<Household> find(HouseholdSearch searchObject, Integer limit, Integer offset, String tenantId, Long lastChangedSince, Boolean includeDeleted) throws QueryBuilderException {
String query = "SELECT * FROM household h LEFT JOIN address a ON h.addressid = a.id";
String query = "SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM household h LEFT JOIN address a ON h.addressid = a.id";
Map<String, Object> paramsMap = new HashMap<>();
List<String> whereFields = GenericQueryBuilder.getFieldsWithCondition(searchObject, QueryFieldChecker.isNotNull, paramsMap);
query = GenericQueryBuilder.generateQuery(query, whereFields).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public Household mapRow(ResultSet resultSet, int i) throws SQLException {
.additionalFields(resultSet.getString("additionalDetails") == null ? null : objectMapper.readValue(resultSet
.getString("additionalDetails"), AdditionalFields.class))
.address(Address.builder()
.id(resultSet.getString(13))
.clientReferenceId(resultSet.getString(28))
.tenantId(resultSet.getString(14))
.id(resultSet.getString("aid"))
.clientReferenceId(resultSet.getString("aclientreferenceid"))
.tenantId(resultSet.getString("atenantid"))
.doorNo(resultSet.getString("doorNo"))
.latitude(resultSet.getDouble("latitude"))
.longitude(resultSet.getDouble("longitude"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected ProjectTaskRepository(Producer producer, NamedParameterJdbcTemplate na

public List<Task> find(TaskSearch searchObject, Integer limit, Integer offset, String tenantId,
Long lastChangedSince, Boolean includeDeleted) throws QueryBuilderException {
String query = "SELECT * FROM project_task pt LEFT JOIN address a ON pt.addressid = a.id";
String query = "SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM project_task pt LEFT JOIN address a ON pt.addressid = a.id";
Map<String, Object> paramsMap = new HashMap<>();
List<String> whereFields = GenericQueryBuilder.getFieldsWithCondition(searchObject,
QueryFieldChecker.isNotNull, paramsMap);
Expand Down Expand Up @@ -111,9 +111,9 @@ public List<Task> findById(List<String> ids, String columnName, Boolean includeD
}
}

String query = String.format("SELECT * FROM project_task pt LEFT JOIN address a ON pt.addressid = a.id WHERE pt.%s IN (:ids) AND isDeleted = false", columnName);
String query = String.format("SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM project_task pt LEFT JOIN address a ON pt.addressid = a.id WHERE pt.%s IN (:ids) AND isDeleted = false", columnName);
if (null != includeDeleted && includeDeleted) {
query = String.format("SELECT * FROM project_task pt LEFT JOIN address a ON pt.addressid = a.id WHERE pt.%s IN (:ids)", columnName);
query = String.format("SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM project_task pt LEFT JOIN address a ON pt.addressid = a.id WHERE pt.%s IN (:ids)", columnName);
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ids", ids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public Task mapRow(ResultSet resultSet, int i) throws SQLException {
.additionalFields(resultSet.getString("additionalDetails") == null ? null : objectMapper
.readValue(resultSet.getString("additionalDetails"), AdditionalFields.class))
.address(Address.builder()
.id(resultSet.getString(20))
.tenantId(resultSet.getString(21))
.clientReferenceId(resultSet.getString(35))
.id(resultSet.getString("aid"))
.tenantId(resultSet.getString("atenantid"))
.clientReferenceId(resultSet.getString("aclientreferenceid"))
.doorNo(resultSet.getString("doorNo"))
.latitude(resultSet.getDouble("latitude"))
.longitude(resultSet.getDouble("longitude"))
Expand All @@ -80,4 +80,4 @@ public Task mapRow(ResultSet resultSet, int i) throws SQLException {
throw new SQLException(e);
}
}
}
}

0 comments on commit 70e7334

Please sign in to comment.