SEBSERV-257 fixed sorting for start date and type

This commit is contained in:
anhefti 2022-01-19 15:45:21 +01:00
parent 95c3f31cb9
commit 499c01e943
4 changed files with 11 additions and 4 deletions

View file

@ -269,7 +269,11 @@ public class PaginationServiceImpl implements PaginationService {
final Map<String, String> examTableMap = new HashMap<>(); final Map<String, String> examTableMap = new HashMap<>();
examTableMap.put(Entity.FILTER_ATTR_INSTITUTION, institutionNameRef); examTableMap.put(Entity.FILTER_ATTR_INSTITUTION, institutionNameRef);
examTableMap.put(Domain.EXAM.ATTR_LMS_SETUP_ID, lmsSetupNameRef); examTableMap.put(Domain.EXAM.ATTR_LMS_SETUP_ID, lmsSetupNameRef);
examTableMap.put(Domain.EXAM.ATTR_TYPE, ExamRecordDynamicSqlSupport.type.name());
// NOTE: This seems not to work and I was not able to figure out why.
// Now the type sorting is done within secondary sort for exams.
//examTableMap.put(Domain.EXAM.ATTR_TYPE, "'" + ExamRecordDynamicSqlSupport.type.name() + "'");
this.sortColumnMapping.put(ExamRecordDynamicSqlSupport.examRecord.name(), examTableMap); this.sortColumnMapping.put(ExamRecordDynamicSqlSupport.examRecord.name(), examTableMap);
this.defaultSortColumn.put(ExamRecordDynamicSqlSupport.examRecord.name(), Domain.EXAM.ATTR_ID); this.defaultSortColumn.put(ExamRecordDynamicSqlSupport.examRecord.name(), Domain.EXAM.ATTR_ID);

View file

@ -154,13 +154,15 @@ public abstract class EntityController<T extends Entity, M extends Entity> {
final FilterMap filterMap = new FilterMap(allRequestParams, request.getQueryString()); final FilterMap filterMap = new FilterMap(allRequestParams, request.getQueryString());
populateFilterMap(filterMap, institutionId, sort); populateFilterMap(filterMap, institutionId, sort);
return this.paginationService.getPage( final Page<T> page = this.paginationService.getPage(
pageNumber, pageNumber,
pageSize, pageSize,
sort, sort,
getSQLTableOfEntity().name(), getSQLTableOfEntity().name(),
() -> getAll(filterMap)) () -> getAll(filterMap))
.getOrThrow(); .getOrThrow();
return page;
} }
protected void populateFilterMap(final FilterMap filterMap, final Long institutionId, final String sort) { protected void populateFilterMap(final FilterMap filterMap, final Long institutionId, final String sort) {

View file

@ -152,7 +152,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
// of the SEB Server. Therefore in the case we have no or the default sorting we can use the // of the SEB Server. Therefore in the case we have no or the default sorting we can use the
// native PaginationService within MyBatis and SQL. For the other cases we need an in-line sorting and paging // native PaginationService within MyBatis and SQL. For the other cases we need an in-line sorting and paging
if (StringUtils.isBlank(sort) || if (StringUtils.isBlank(sort) ||
this.paginationService.isNativeSortingSupported(ExamRecordDynamicSqlSupport.examRecord, sort)) { (this.paginationService.isNativeSortingSupported(ExamRecordDynamicSqlSupport.examRecord, sort))) {
return super.getPage(institutionId, pageNumber, pageSize, sort, allRequestParams, request); return super.getPage(institutionId, pageNumber, pageSize, sort, allRequestParams, request);
@ -592,7 +592,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
if (sortBy.equals(Exam.FILTER_ATTR_TYPE)) { if (sortBy.equals(Exam.FILTER_ATTR_TYPE)) {
list.sort(Comparator.comparing(exam -> exam.type)); list.sort(Comparator.comparing(exam -> exam.type));
} }
if (sortBy.equals(QuizData.FILTER_ATTR_START_TIME)) { if (sortBy.equals(QuizData.FILTER_ATTR_START_TIME) || sortBy.equals(QuizData.QUIZ_ATTR_START_TIME)) {
list.sort(Comparator.comparing(exam -> exam.startTime)); list.sort(Comparator.comparing(exam -> exam.startTime));
} }

View file

@ -17,6 +17,7 @@ logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.session.impl.indicat
#logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl=DEBUG #logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl=DEBUG
#logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis=DEBUG #logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis=DEBUG
#logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper=DEBUG #logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper=DEBUG
logging.level.ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordMapper=DEBUG
#logging.level.ch.ethz.seb.sebserver.webservice.weblayer.api.ExamAPI_V1_Controller=TRACE #logging.level.ch.ethz.seb.sebserver.webservice.weblayer.api.ExamAPI_V1_Controller=TRACE
logging.level.com.zaxxer.hikari=DEBUG logging.level.com.zaxxer.hikari=DEBUG