SEBSERV-296 fixed
This commit is contained in:
parent
554be43828
commit
9956f1a122
4 changed files with 58 additions and 25 deletions
|
@ -32,6 +32,7 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionR
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ConfigurationNodeRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ConfigurationNodeRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordDynamicSqlSupport;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.InstitutionRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.InstitutionRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.LmsSetupRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.LmsSetupRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.SebClientConfigRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.SebClientConfigRecordDynamicSqlSupport;
|
||||||
|
@ -203,11 +204,11 @@ public class PaginationServiceImpl implements PaginationService {
|
||||||
if (StringUtils.isNotBlank(sortColumnName)) {
|
if (StringUtils.isNotBlank(sortColumnName)) {
|
||||||
switch (sortOrder) {
|
switch (sortOrder) {
|
||||||
case DESCENDING: {
|
case DESCENDING: {
|
||||||
PageHelper.orderBy(sortColumnName + " DESC");
|
PageHelper.orderBy(sortColumnName + " DESC, id DESC");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
PageHelper.orderBy(sortColumnName);
|
PageHelper.orderBy(sortColumnName + ", id");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,6 +266,18 @@ public class PaginationServiceImpl implements PaginationService {
|
||||||
this.sortColumnMapping.put(LmsSetupRecordDynamicSqlSupport.lmsSetupRecord.name(), lmsSetupTableMap);
|
this.sortColumnMapping.put(LmsSetupRecordDynamicSqlSupport.lmsSetupRecord.name(), lmsSetupTableMap);
|
||||||
this.defaultSortColumn.put(LmsSetupRecordDynamicSqlSupport.lmsSetupRecord.name(), Domain.LMS_SETUP.ATTR_ID);
|
this.defaultSortColumn.put(LmsSetupRecordDynamicSqlSupport.lmsSetupRecord.name(), Domain.LMS_SETUP.ATTR_ID);
|
||||||
|
|
||||||
|
// Exam Template Table
|
||||||
|
final Map<String, String> examTemplateTableMap = new HashMap<>();
|
||||||
|
examTemplateTableMap.put(Entity.FILTER_ATTR_INSTITUTION, institutionNameRef);
|
||||||
|
examTemplateTableMap.put(Domain.EXAM_TEMPLATE.ATTR_NAME, ExamTemplateRecordDynamicSqlSupport.name.name());
|
||||||
|
examTemplateTableMap.put(Domain.EXAM_TEMPLATE.ATTR_EXAM_TYPE,
|
||||||
|
ExamTemplateRecordDynamicSqlSupport.examType.name());
|
||||||
|
|
||||||
|
this.sortColumnMapping.put(ExamTemplateRecordDynamicSqlSupport.examTemplateRecord.name(), examTemplateTableMap);
|
||||||
|
this.defaultSortColumn.put(
|
||||||
|
ExamTemplateRecordDynamicSqlSupport.examTemplateRecord.name(),
|
||||||
|
Domain.EXAM_TEMPLATE.ATTR_ID);
|
||||||
|
|
||||||
// Exam Table
|
// Exam Table
|
||||||
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);
|
||||||
|
|
|
@ -22,6 +22,9 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.mybatis.dynamic.sql.SqlBuilder;
|
||||||
|
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
|
||||||
|
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -42,6 +45,7 @@ import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordMapper;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordMapper;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.IndicatorRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.IndicatorRecordDynamicSqlSupport;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.InstitutionRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ExamTemplateRecord;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ExamTemplateRecord;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.impl.BulkAction;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.impl.BulkAction;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO;
|
||||||
|
@ -140,24 +144,38 @@ public class ExamTemplateDAOImpl implements ExamTemplateDAO {
|
||||||
final FilterMap filterMap,
|
final FilterMap filterMap,
|
||||||
final Predicate<ExamTemplate> predicate) {
|
final Predicate<ExamTemplate> predicate) {
|
||||||
|
|
||||||
return Result.tryCatch(() -> this.examTemplateRecordMapper
|
return Result.tryCatch(() -> {
|
||||||
.selectByExample()
|
final QueryExpressionDSL<MyBatis3SelectModelAdapter<List<ExamTemplateRecord>>>.QueryExpressionWhereBuilder whereClause =
|
||||||
.where(
|
(filterMap.getBoolean(FilterMap.ATTR_ADD_INSITUTION_JOIN))
|
||||||
ExamTemplateRecordDynamicSqlSupport.institutionId,
|
? this.examTemplateRecordMapper
|
||||||
isEqualToWhenPresent(filterMap.getInstitutionId()))
|
.selectByExample()
|
||||||
.and(
|
.join(InstitutionRecordDynamicSqlSupport.institutionRecord)
|
||||||
ExamTemplateRecordDynamicSqlSupport.name,
|
.on(InstitutionRecordDynamicSqlSupport.id,
|
||||||
isLikeWhenPresent(filterMap.getExamTemplateName()))
|
SqlBuilder.equalTo(ExamTemplateRecordDynamicSqlSupport.institutionId))
|
||||||
.and(
|
.where(
|
||||||
ExamTemplateRecordDynamicSqlSupport.examType,
|
ExamTemplateRecordDynamicSqlSupport.institutionId,
|
||||||
isEqualToWhenPresent(filterMap.getString(ExamTemplate.FILTER_ATTR_EXAM_TYPE)))
|
isEqualToWhenPresent(filterMap.getInstitutionId()))
|
||||||
.build()
|
: this.examTemplateRecordMapper
|
||||||
.execute()
|
.selectByExample()
|
||||||
.stream()
|
.where(
|
||||||
.map(this::toDomainModel)
|
ExamTemplateRecordDynamicSqlSupport.institutionId,
|
||||||
.flatMap(DAOLoggingSupport::logAndSkipOnError)
|
isEqualToWhenPresent(filterMap.getInstitutionId()));
|
||||||
.filter(predicate)
|
|
||||||
.collect(Collectors.toList()));
|
return whereClause
|
||||||
|
.and(
|
||||||
|
ExamTemplateRecordDynamicSqlSupport.name,
|
||||||
|
isLikeWhenPresent(filterMap.getExamTemplateName()))
|
||||||
|
.and(
|
||||||
|
ExamTemplateRecordDynamicSqlSupport.examType,
|
||||||
|
isEqualToWhenPresent(filterMap.getString(ExamTemplate.FILTER_ATTR_EXAM_TYPE)))
|
||||||
|
.build()
|
||||||
|
.execute()
|
||||||
|
.stream()
|
||||||
|
.map(this::toDomainModel)
|
||||||
|
.flatMap(DAOLoggingSupport::logAndSkipOnError)
|
||||||
|
.filter(predicate)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -248,11 +249,12 @@ public abstract class AdministrationAPIIntegrationTester {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getOrderedUUIDs(final Collection<? extends Entity> list) {
|
protected String getOrderedUUIDs(final Collection<? extends Entity> list) {
|
||||||
return list
|
final List<String> l = list
|
||||||
.stream()
|
.stream()
|
||||||
.map(userInfo -> userInfo.getModelId())
|
.map(userInfo -> userInfo.getModelId())
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList());
|
||||||
.toString();
|
l.sort((s1, s2) -> s1.compareTo(s2));
|
||||||
|
return l.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
|
||||||
assertTrue(userInfos.numberOfPages == 1);
|
assertTrue(userInfos.numberOfPages == 1);
|
||||||
assertNotNull(userInfos.content);
|
assertNotNull(userInfos.content);
|
||||||
assertTrue(userInfos.content.size() == 3);
|
assertTrue(userInfos.content.size() == 3);
|
||||||
assertEquals("[user5, user2, user1]", getOrderedUUIDs(userInfos.content));
|
assertEquals("[user1, user2, user5]", getOrderedUUIDs(userInfos.content));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -347,7 +347,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester {
|
||||||
assertTrue(userInfos.numberOfPages == 2);
|
assertTrue(userInfos.numberOfPages == 2);
|
||||||
assertNotNull(userInfos.content);
|
assertNotNull(userInfos.content);
|
||||||
assertTrue(userInfos.content.size() == 3);
|
assertTrue(userInfos.content.size() == 3);
|
||||||
assertEquals("[user7, user6, user4]", getOrderedUUIDs(userInfos.content));
|
assertEquals("[user4, user6, user7]", getOrderedUUIDs(userInfos.content));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue