SEBSERV-425 fixed (also tests)

This commit is contained in:
anhefti 2023-04-13 15:10:07 +02:00
parent 2355db41a5
commit 7ef5f91d42

View file

@ -24,6 +24,8 @@ import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -130,28 +132,38 @@ public class SEBClientConfigDAOImpl implements SEBClientConfigDAO {
final FilterMap filterMap, final FilterMap filterMap,
final Predicate<SEBClientConfig> predicate) { final Predicate<SEBClientConfig> predicate) {
return Result.tryCatch(() -> this.sebClientConfigRecordMapper return Result.tryCatch(() -> {
.selectByExample()
.where( QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SebClientConfigRecord>>>.QueryExpressionWhereBuilder query =
SebClientConfigRecordDynamicSqlSupport.institutionId, this.sebClientConfigRecordMapper
isEqualToWhenPresent(filterMap.getInstitutionId())) .selectByExample()
.and( .where(
SebClientConfigRecordDynamicSqlSupport.name, SebClientConfigRecordDynamicSqlSupport.institutionId,
isLikeWhenPresent(filterMap.getName())) isEqualToWhenPresent(filterMap.getInstitutionId()))
.and( .and(
SebClientConfigRecordDynamicSqlSupport.name,
isLikeWhenPresent(filterMap.getName()))
.and(
SebClientConfigRecordDynamicSqlSupport.active,
isEqualToWhenPresent(filterMap.getActiveAsInt()));
final DateTime sebClientConfigFromTime = filterMap.getSEBClientConfigFromTime();
if (sebClientConfigFromTime != null) {
query = query.and(
SebClientConfigRecordDynamicSqlSupport.date, SebClientConfigRecordDynamicSqlSupport.date,
isGreaterThanOrEqualToWhenPresent(filterMap.getSEBClientConfigFromTime()), isGreaterThanOrEqualTo(sebClientConfigFromTime),
or(SebClientConfigRecordDynamicSqlSupport.active, isNotEqualTo(0))) or(SebClientConfigRecordDynamicSqlSupport.active, isNotEqualTo(0)));
.and( }
SebClientConfigRecordDynamicSqlSupport.active,
isEqualToWhenPresent(filterMap.getActiveAsInt())) return query.build()
.build() .execute()
.execute() .stream()
.stream() .map(this::toDomainModel)
.map(this::toDomainModel) .flatMap(DAOLoggingSupport::logAndSkipOnError)
.flatMap(DAOLoggingSupport::logAndSkipOnError) .filter(predicate)
.filter(predicate) .collect(Collectors.toList());
.collect(Collectors.toList())); });
} }
@Override @Override