Datatable integration test
This commit is contained in:
committed by
Arnold Gálovics
parent
6849f45bb8
commit
64bfe33766
+3
@@ -37,6 +37,9 @@ import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidati
|
||||
|
||||
public final class DateUtils {
|
||||
|
||||
public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final DateTimeFormatter DEFAULT_DATETIME_FORMATER = DateTimeFormatter.ofPattern(DEFAULT_DATETIME_FORMAT);
|
||||
|
||||
private DateUtils() {
|
||||
|
||||
}
|
||||
|
||||
-4
@@ -53,7 +53,6 @@ import org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.apache.fineract.infrastructure.dataqueries.service.GenericDataService;
|
||||
import org.apache.fineract.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -71,7 +70,6 @@ public class DatatablesApiResource {
|
||||
private final ReadWriteNonCoreDataService readWriteNonCoreDataService;
|
||||
private final ToApiJsonSerializer<GenericResultsetData> toApiJsonSerializer;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(DatatablesApiResource.class);
|
||||
|
||||
@Autowired
|
||||
public DatatablesApiResource(final PlatformSecurityContext context, final GenericDataService genericDataService,
|
||||
@@ -259,8 +257,6 @@ public class DatatablesApiResource {
|
||||
public String getDatatableManyEntry(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId,
|
||||
@PathParam("datatableId") final Long datatableId, @QueryParam("order") final String order, @Context final UriInfo uriInfo) {
|
||||
|
||||
LOG.debug("::1 we came in the getDatatbleManyEntry apiRessource method");
|
||||
|
||||
this.context.authenticatedUser().validateHasDatatableReadPermission(datatable);
|
||||
|
||||
final GenericResultsetData results = this.readWriteNonCoreDataService.retrieveDataTableGenericResultSet(datatable, apptableId,
|
||||
|
||||
+14
-5
@@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
|
||||
import org.apache.fineract.infrastructure.core.service.database.DatabaseIndependentQueryService;
|
||||
import org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
@@ -32,8 +33,6 @@ import org.apache.fineract.infrastructure.dataqueries.data.ResultsetColumnHeader
|
||||
import org.apache.fineract.infrastructure.dataqueries.data.ResultsetColumnValueData;
|
||||
import org.apache.fineract.infrastructure.dataqueries.data.ResultsetRowData;
|
||||
import org.apache.fineract.infrastructure.dataqueries.exception.DatatableNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -47,7 +46,6 @@ public class GenericDataServiceImpl implements GenericDataService {
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final DataSource dataSource;
|
||||
private final DatabaseIndependentQueryService databaseIndependentQueryService;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GenericDataServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
public GenericDataServiceImpl(final RoutingDataSource dataSource, final JdbcTemplate jdbcTemplate,
|
||||
@@ -169,9 +167,10 @@ public class GenericDataServiceImpl implements GenericDataService {
|
||||
writer.append(
|
||||
"[" + localDate.getYear() + ", " + localDate.getMonthValue() + ", " + localDate.getDayOfMonth() + "]");
|
||||
} else if (currColType.equals("DATETIME")) {
|
||||
final LocalDateTime localDateTime = LocalDateTime.parse(currVal);
|
||||
final LocalDateTime localDateTime = LocalDateTime.parse(formatDateTimeValue(currVal),
|
||||
DateUtils.DEFAULT_DATETIME_FORMATER);
|
||||
writer.append("[" + localDateTime.getYear() + ", " + localDateTime.getMonthValue() + ", "
|
||||
+ localDateTime.getDayOfMonth() + " " + localDateTime.getHour() + ", " + localDateTime.getMinute()
|
||||
+ localDateTime.getDayOfMonth() + ", " + localDateTime.getHour() + ", " + localDateTime.getMinute()
|
||||
+ ", " + localDateTime.getSecond() + ", " + localDateTime.get(ChronoField.MILLI_OF_SECOND) + "]");
|
||||
} else {
|
||||
writer.append(doubleQuote + replace(currVal, doubleQuote, slashDoubleQuote) + doubleQuote);
|
||||
@@ -262,4 +261,14 @@ public class GenericDataServiceImpl implements GenericDataService {
|
||||
throw new DatatableNotFoundException(datatable);
|
||||
}
|
||||
}
|
||||
|
||||
private String formatDateTimeValue(String dateTimeValue) {
|
||||
if (dateTimeValue.length() > 19) {
|
||||
dateTimeValue = dateTimeValue.substring(0, 19);
|
||||
}
|
||||
if (dateTimeValue.contains("T")) {
|
||||
dateTimeValue = dateTimeValue.replace("T", " ");
|
||||
}
|
||||
return dateTimeValue;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1710,7 +1710,8 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
// ignores id and foreign key fields
|
||||
// also ignores locale and dateformat fields that are used for
|
||||
// validating numeric and date data
|
||||
if (!(key.equalsIgnoreCase("id") || key.equalsIgnoreCase(keyFieldName) || key.equals("locale") || key.equals("dateFormat"))) {
|
||||
if (!(key.equalsIgnoreCase("id") || key.equalsIgnoreCase(keyFieldName) || key.equals("locale") || key.equals("dateFormat")
|
||||
|| key.equals(DataTableApiConstant.CREATEDAT_FIELD_NAME) || key.equals(DataTableApiConstant.UPDATEDAT_FIELD_NAME))) {
|
||||
notFound = true;
|
||||
// matches incoming fields with and without underscores (spaces
|
||||
// and underscores considered the same)
|
||||
|
||||
Reference in New Issue
Block a user