adamsaghy commented on code in PR #2446:
URL: https://github.com/apache/fineract/pull/2446#discussion_r929978705
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java:
##########
@@ -1471,18 +1472,43 @@ private String mapToActualAppTable(final String
appTable) {
return appTable;
}
- private List<ResultsetRowData> fillDatatableResultSetDataRows(final String
sql) {
+ private List<ResultsetRowData> fillDatatableResultSetDataRows(final String
sql, final List<ResultsetColumnHeaderData> columnHeaders) {
final List<ResultsetRowData> resultsetDataRows = new ArrayList<>();
+ final GenericResultsetData genericResultsetData = new
GenericResultsetData(columnHeaders, null);
final SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql); // NOSONAR
final SqlRowSetMetaData rsmd = rowSet.getMetaData();
while (rowSet.next()) {
- final List<String> columnValues = new ArrayList<>();
+ final List<Object> columnValues = new ArrayList<>();
+
for (int i = 0; i < rsmd.getColumnCount(); i++) {
final String columnName = rsmd.getColumnName(i + 1);
- final String columnValue = rowSet.getString(columnName);
- columnValues.add(columnValue);
+ if (columnHeaders.isEmpty()) {
+ columnValues.add(rowSet.getString(columnName));
+ } else {
+ final String colType =
genericResultsetData.getColTypeOfColumnNamed(columnName);
+ if ("DECIMAL".equalsIgnoreCase(colType)) {
+ columnValues.add(rowSet.getBigDecimal(columnName));
+ } else if ("DATE".equalsIgnoreCase(colType)) {
+ columnValues.add(rowSet.getDate(columnName));
+ } else if ("timestamp without time
zone".equalsIgnoreCase(colType) // PostgreSQL
Review Comment:
@josehernandezfintecheandomx What do you think?
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/GenericDataServiceImpl.java:
##########
@@ -160,23 +162,28 @@ public String generateJsonFromGenericResultsetData(final
GenericResultsetData gr
if (currColType == null && colType.equalsIgnoreCase("DATE")) {
currColType = "DATE";
}
+ if (currColType == null &&
colType.equalsIgnoreCase("DATETIME")) {
+ currColType = "DATETIME";
+ }
currVal = row.get(j);
if (currVal != null && currColType != null) {
if (currColType.equals("DECIMAL") ||
currColType.equals("INTEGER")) {
writer.append(currVal);
} else {
if (currColType.equals("DATE")) {
- final LocalDate localDate =
LocalDate.parse(currVal);
- writer.append(
- "[" + localDate.getYear() + ", " +
localDate.getMonthValue() + ", " + localDate.getDayOfMonth() + "]");
+ final LocalDate localDate =
LocalDate.parse(currVal.toString());
+ writer.append(format("[%d,%d,%d]",
localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth()));
} else if (currColType.equals("DATETIME")) {
- final LocalDateTime localDateTime =
LocalDateTime.parse(formatDateTimeValue(currVal),
- DateUtils.DEFAULT_DATETIME_FORMATER);
- writer.append("[" + localDateTime.getYear() + ", "
+ localDateTime.getMonthValue() + ", "
- + localDateTime.getDayOfMonth() + ", " +
localDateTime.getHour() + ", " + localDateTime.getMinute()
- + ", " + localDateTime.getSecond() + ", "
+ localDateTime.get(ChronoField.MILLI_OF_SECOND) + "]");
+ LocalDateTime ldt = null;
Review Comment:
@josehernandezfintecheandomx What do you think?
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/GenericDataServiceImpl.java:
##########
@@ -160,23 +162,28 @@ public String generateJsonFromGenericResultsetData(final
GenericResultsetData gr
if (currColType == null && colType.equalsIgnoreCase("DATE")) {
currColType = "DATE";
}
+ if (currColType == null &&
colType.equalsIgnoreCase("DATETIME")) {
+ currColType = "DATETIME";
+ }
currVal = row.get(j);
if (currVal != null && currColType != null) {
if (currColType.equals("DECIMAL") ||
currColType.equals("INTEGER")) {
writer.append(currVal);
} else {
if (currColType.equals("DATE")) {
- final LocalDate localDate =
LocalDate.parse(currVal);
- writer.append(
- "[" + localDate.getYear() + ", " +
localDate.getMonthValue() + ", " + localDate.getDayOfMonth() + "]");
+ final LocalDate localDate =
LocalDate.parse(currVal.toString());
Review Comment:
@josehernandezfintecheandomx What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]