code cleanup

This commit is contained in:
anhefti 2022-01-25 10:04:20 +01:00
parent e19e7aeb2a
commit ecc5398147
21 changed files with 391 additions and 166 deletions

View file

@ -13,6 +13,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -212,14 +213,20 @@ public class BatchActionDAOImpl implements BatchActionDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<BatchAction>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.batchActionRecordMapper.selectByExample()
.where(BatchActionRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.batchActionRecordMapper.selectByExample()
.where(BatchActionRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -293,6 +300,10 @@ public class BatchActionDAOImpl implements BatchActionDAO {
final List<Long> ids = extractListOfPKs(all);
if (ids.isEmpty()) {
return Collections.emptyList();
}
this.batchActionRecordMapper.deleteByExample()
.where(BatchActionRecordDynamicSqlSupport.id, isIn(ids))
.build()

View file

@ -141,7 +141,7 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO {
@Transactional(readOnly = true)
public Result<Collection<ClientConnection>> allOf(final Set<Long> pks) {
if (pks == null || pks.isEmpty()) {
return Result.ofRuntimeError("Null or empty set reference");
return Result.of(Collections.emptyList());
}
return Result.tryCatch(() -> this.clientConnectionRecordMapper.selectByExample()
.where(ClientConnectionRecordDynamicSqlSupport.id, SqlBuilder.isIn(new ArrayList<>(pks)))

View file

@ -13,6 +13,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
@ -186,14 +187,21 @@ public class ClientEventDAOImpl implements ClientEventDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<ClientEvent>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.clientEventRecordMapper.selectByExample()
.where(ClientEventRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ClientEventDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.clientEventRecordMapper.selectByExample()
.where(ClientEventRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ClientEventDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -378,6 +386,10 @@ public class ClientEventDAOImpl implements ClientEventDAO {
public Result<Collection<EntityKey>> delete(final Set<EntityKey> all) {
return Result.tryCatch(() -> {
if (all == null || all.isEmpty()) {
return Collections.emptyList();
}
final List<Long> pks = all
.stream()
.map(EntityKey::getModelId)
@ -402,12 +414,20 @@ public class ClientEventDAOImpl implements ClientEventDAO {
public Result<Collection<EntityKey>> deleteClientNotification(final Set<EntityKey> keys) {
return Result.tryCatch(() -> {
if (keys == null || keys.isEmpty()) {
return Collections.emptyList();
}
final List<Long> pks = keys
.stream()
.map(EntityKey::getModelId)
.map(Long::parseLong)
.collect(Collectors.toList());
if (log.isDebugEnabled()) {
log.debug("Going to delete all client notifications: {}", pks);
}
this.clientNotificationRecordMapper
.deleteByExample()
.where(ClientNotificationRecordDynamicSqlSupport.id, isIn(pks))

View file

@ -12,6 +12,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.isIn;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
@ -75,14 +76,21 @@ public class ConfigurationAttributeDAOImpl implements ConfigurationAttributeDAO
@Override
@Transactional(readOnly = true)
public Result<Collection<ConfigurationAttribute>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.configurationAttributeRecordMapper.selectByExample()
.where(ConfigurationAttributeRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationAttributeDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.configurationAttributeRecordMapper.selectByExample()
.where(ConfigurationAttributeRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationAttributeDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -191,6 +199,10 @@ public class ConfigurationAttributeDAOImpl implements ConfigurationAttributeDAO
final List<Long> ids = extractListOfPKs(all);
final List<EntityKey> result = new ArrayList<>();
if (ids == null || ids.isEmpty()) {
return result;
}
// if this is a complex attribute that has children, delete the children first
final List<ConfigurationAttributeRecord> children =
this.configurationAttributeRecordMapper.selectByExample()

View file

@ -552,15 +552,17 @@ class ConfigurationDAOBatchService {
.collect(Collectors.toList());
// first delete all old values of this table
this.batchConfigurationValueRecordMapper.deleteByExample()
.where(
ConfigurationValueRecordDynamicSqlSupport.configurationId,
isEqualTo(value.configurationId))
.and(
ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId,
SqlBuilder.isIn(columnAttributeIds))
.build()
.execute();
if (!columnAttributeIds.isEmpty()) {
this.batchConfigurationValueRecordMapper.deleteByExample()
.where(
ConfigurationValueRecordDynamicSqlSupport.configurationId,
isEqualTo(value.configurationId))
.and(
ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId,
SqlBuilder.isIn(columnAttributeIds))
.build()
.execute();
}
// then add the new values
for (final TableValue tableValue : value.values) {

View file

@ -8,6 +8,22 @@
package ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Configuration;
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
@ -23,20 +39,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport;
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ResourceNotFoundException;
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.TransactionHandler;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
@Lazy
@Component
@ -72,14 +74,21 @@ public class ConfigurationDAOImpl implements ConfigurationDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<Configuration>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.configurationRecordMapper.selectByExample()
.where(ConfigurationRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.configurationRecordMapper.selectByExample()
.where(ConfigurationRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override

View file

@ -91,14 +91,21 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<ConfigurationNode>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.configurationNodeRecordMapper.selectByExample()
.where(ConfigurationNodeRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationNodeDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.configurationNodeRecordMapper.selectByExample()
.where(ConfigurationNodeRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationNodeDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -225,6 +232,10 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
// find all configurations for this configuration node
final List<Long> configurationIds = this.configurationRecordMapper.selectIdsByExample()
.where(ConfigurationRecordDynamicSqlSupport.configurationNodeId, isIn(ids))

View file

@ -11,7 +11,17 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl;
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
import static org.mybatis.dynamic.sql.SqlBuilder.isIn;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@ -115,14 +125,21 @@ public class ConfigurationValueDAOImpl implements ConfigurationValueDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<ConfigurationValue>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.configurationValueRecordMapper.selectByExample()
.where(ConfigurationValueRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationValueDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.configurationValueRecordMapper.selectByExample()
.where(ConfigurationValueRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ConfigurationValueDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -248,6 +265,9 @@ public class ConfigurationValueDAOImpl implements ConfigurationValueDAO {
.flatMap(this::getAttributeMapping)
.map(attributeMapping -> {
// get all values of the table
final ArrayList<Long> attrs = (attributeMapping != null && !attributeMapping.isEmpty())
? new ArrayList<>(attributeMapping.keySet())
: null;
final List<TableValue> values = this.configurationValueRecordMapper.selectByExample()
.where(
ConfigurationValueRecordDynamicSqlSupport.institutionId,
@ -257,7 +277,7 @@ public class ConfigurationValueDAOImpl implements ConfigurationValueDAO {
isEqualTo(configurationId))
.and(
ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId,
SqlBuilder.isIn(new ArrayList<>(attributeMapping.keySet())))
SqlBuilder.isInWhenPresent(attrs))
.build()
.execute()
.stream()
@ -329,13 +349,13 @@ public class ConfigurationValueDAOImpl implements ConfigurationValueDAO {
rows.sort(Comparator.naturalOrder());
rows.forEach(i -> {
final Map<Long, ConfigurationValue> rowValuesMapping = indexMapping.get(i);
final List<ConfigurationValue> rowValues = attributes
.stream()
.map(attr -> rowValuesMapping.get(attr.getId()))
.collect(Collectors.toList());
result.add(rowValues);
});
final Map<Long, ConfigurationValue> rowValuesMapping = indexMapping.get(i);
final List<ConfigurationValue> rowValues = attributes
.stream()
.map(attr -> rowValuesMapping.get(attr.getId()))
.collect(Collectors.toList());
result.add(rowValues);
});
return result;
});
@ -362,7 +382,9 @@ public class ConfigurationValueDAOImpl implements ConfigurationValueDAO {
final Set<EntityKey> tableValues = new HashSet<>();
if (attributeMapping != null && !attributeMapping.isEmpty()) {
final ArrayList<Long> attrs = (attributeMapping != null && !attributeMapping.isEmpty())
? new ArrayList<>(attributeMapping.keySet())
: null;
tableValues.addAll(this.configurationValueRecordMapper.selectByExample()
.where(
ConfigurationValueRecordDynamicSqlSupport.institutionId,
@ -372,7 +394,7 @@ public class ConfigurationValueDAOImpl implements ConfigurationValueDAO {
isEqualTo(configurationId))
.and(
ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId,
SqlBuilder.isIn(new ArrayList<>(attributeMapping.keySet())))
SqlBuilder.isInWhenPresent(attrs))
.build()
.execute()
.stream()

View file

@ -98,14 +98,21 @@ public class ExamConfigurationMapDAOImpl implements ExamConfigurationMapDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<ExamConfigurationMap>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.examConfigurationMapRecordMapper.selectByExample()
.where(ExamConfigurationMapRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.examConfigurationMapRecordMapper.selectByExample()
.where(ExamConfigurationMapRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -268,6 +275,9 @@ public class ExamConfigurationMapDAOImpl implements ExamConfigurationMapDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
// get all involved configurations
final List<Long> configIds = this.examConfigurationMapRecordMapper.selectByExample()

View file

@ -217,6 +217,10 @@ public class ExamDAOImpl implements ExamDAO {
final Result<Collection<EntityKey>> tryCatch = Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
final ExamRecord examRecord = new ExamRecord(null, null, null, null, null,
null, null, null, null, null, null, null, null, BooleanUtils.toInteger(active), null,
Utils.getMillisecondsNow());
@ -484,6 +488,9 @@ public class ExamDAOImpl implements ExamDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
// notify exam deletion listener about following deletion, to cleanup stuff before deletion
this.applicationEventPublisher.publishEvent(new ExamDeletionEvent(ids));

View file

@ -12,6 +12,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -330,10 +331,17 @@ public class ExamRecordDAO {
@Transactional(readOnly = true)
public Result<Collection<ExamRecord>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.examRecordMapper.selectByExample()
.where(ExamRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute());
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.examRecordMapper.selectByExample()
.where(ExamRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute();
});
}
}

View file

@ -117,14 +117,21 @@ public class ExamTemplateDAOImpl implements ExamTemplateDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<ExamTemplate>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.examTemplateRecordMapper.selectByExample()
.where(IndicatorRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.examTemplateRecordMapper.selectByExample()
.where(IndicatorRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -247,6 +254,9 @@ public class ExamTemplateDAOImpl implements ExamTemplateDAO {
log.info("Delete exam templates: {}", all);
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
ids.stream()
.forEach(id -> {

View file

@ -105,14 +105,21 @@ public class IndicatorDAOImpl implements IndicatorDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<Indicator>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.indicatorRecordMapper.selectByExample()
.where(IndicatorRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.indicatorRecordMapper.selectByExample()
.where(IndicatorRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -193,6 +200,9 @@ public class IndicatorDAOImpl implements IndicatorDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
// first delete all thresholds of indicators
this.thresholdRecordMapper.deleteByExample()

View file

@ -170,6 +170,10 @@ public class InstitutionDAOImpl implements InstitutionDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
final InstitutionRecord institutionRecord = new InstitutionRecord(
null, null, null, null, BooleanUtils.toInteger(active), null);
@ -204,6 +208,9 @@ public class InstitutionDAOImpl implements InstitutionDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
this.institutionRecordMapper.deleteByExample()
.where(InstitutionRecordDynamicSqlSupport.id, isIn(ids))
@ -226,14 +233,21 @@ public class InstitutionDAOImpl implements InstitutionDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<Institution>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.institutionRecordMapper.selectByExample()
.where(InstitutionRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(InstitutionDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.institutionRecordMapper.selectByExample()
.where(InstitutionRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(InstitutionDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
private Result<InstitutionRecord> recordById(final Long id) {

View file

@ -241,6 +241,10 @@ public class LmsSetupDAOImpl implements LmsSetupDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
final LmsSetupRecord lmsSetupRecord = new LmsSetupRecord(
null, null, null, null, null, null, null, null, null, null, null, null,
System.currentTimeMillis(),
@ -277,6 +281,9 @@ public class LmsSetupDAOImpl implements LmsSetupDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
this.lmsSetupRecordMapper.deleteByExample()
.where(LmsSetupRecordDynamicSqlSupport.id, isIn(ids))
@ -303,14 +310,21 @@ public class LmsSetupDAOImpl implements LmsSetupDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<LmsSetup>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.lmsSetupRecordMapper.selectByExample()
.where(LmsSetupRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.lmsSetupRecordMapper.selectByExample()
.where(LmsSetupRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override

View file

@ -13,6 +13,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.isIn;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -68,14 +69,21 @@ public class OrientationDAOImpl implements OrientationDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<Orientation>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.orientationRecordMapper.selectByExample()
.where(OrientationRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(OrientationDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.orientationRecordMapper.selectByExample()
.where(OrientationRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(OrientationDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -227,6 +235,9 @@ public class OrientationDAOImpl implements OrientationDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
this.orientationRecordMapper.deleteByExample()
.where(OrientationRecordDynamicSqlSupport.id, isIn(ids))

View file

@ -196,6 +196,10 @@ public class SEBClientConfigDAOImpl implements SEBClientConfigDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
final SebClientConfigRecord record = new SebClientConfigRecord(
null, null, null, null, null, null, null,
BooleanUtils.toIntegerObject(active));
@ -278,6 +282,9 @@ public class SEBClientConfigDAOImpl implements SEBClientConfigDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
this.sebClientConfigRecordMapper.deleteByExample()
.where(SebClientConfigRecordDynamicSqlSupport.id, isIn(ids))
@ -293,14 +300,21 @@ public class SEBClientConfigDAOImpl implements SEBClientConfigDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<SEBClientConfig>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.sebClientConfigRecordMapper.selectByExample()
.where(SebClientConfigRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.sebClientConfigRecordMapper.selectByExample()
.where(SebClientConfigRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override

View file

@ -324,6 +324,9 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
this.userLogRecordMapper.deleteByExample()
.where(UserActivityLogRecordDynamicSqlSupport.id, isIn(ids))
@ -438,12 +441,19 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<UserActivityLog>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.toDomainModel(
this.userService.getCurrentUser().institutionId(),
this.userLogRecordMapper.selectByExample()
.where(UserActivityLogRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.toDomainModel(
this.userService.getCurrentUser().institutionId(),
this.userLogRecordMapper.selectByExample()
.where(UserActivityLogRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute());
});
}
@Override

View file

@ -324,6 +324,10 @@ public class UserDAOImpl implements UserDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
final UserRecord userRecord = new UserRecord(
null, null, null, null, null, null, null, null, null, null, null,
BooleanUtils.toIntegerObject(active));
@ -363,6 +367,9 @@ public class UserDAOImpl implements UserDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
// get all user records for later processing
final List<UserRecord> users = this.userRecordMapper.selectByExample()
@ -413,14 +420,21 @@ public class UserDAOImpl implements UserDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<UserInfo>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.userRecordMapper.selectByExample()
.where(InstitutionRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.userRecordMapper.selectByExample()
.where(InstitutionRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(this::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -429,6 +443,11 @@ public class UserDAOImpl implements UserDAO {
return UserDAO.super.extractPKsFromKeys(keys);
} else {
try {
if (keys == null || keys.isEmpty()) {
return Collections.emptySet();
}
final List<String> uuids = keys.stream()
.map(key -> key.modelId)
.collect(Collectors.toList());

View file

@ -12,6 +12,7 @@ import static org.mybatis.dynamic.sql.SqlBuilder.isIn;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -65,14 +66,21 @@ public class ViewDAOImpl implements ViewDAO {
@Override
@Transactional(readOnly = true)
public Result<Collection<View>> allOf(final Set<Long> pks) {
return Result.tryCatch(() -> this.viewRecordMapper.selectByExample()
.where(ViewRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ViewDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList()));
return Result.tryCatch(() -> {
if (pks == null || pks.isEmpty()) {
return Collections.emptyList();
}
return this.viewRecordMapper.selectByExample()
.where(ViewRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
.build()
.execute()
.stream()
.map(ViewDAOImpl::toDomainModel)
.flatMap(DAOLoggingSupport::logAndSkipOnError)
.collect(Collectors.toList());
});
}
@Override
@ -212,6 +220,9 @@ public class ViewDAOImpl implements ViewDAO {
return Result.tryCatch(() -> {
final List<Long> ids = extractListOfPKs(all);
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
this.viewRecordMapper.deleteByExample()
.where(ViewRecordDynamicSqlSupport.id, isIn(ids))

View file

@ -282,7 +282,7 @@ sebserver.useraccount.delete.form.deleteExams.tooltip=This includes all Exams wh
sebserver.useraccount.delete.form.action.delete=Delete
sebserver.useraccount.delete.form.action.report=Show Report
sebserver.useraccount.delete.confirm.title=Deletion Successful
sebserver.useraccount.delete.confirm.message=The User Account ({0}) was successfully deleted.<br/>Also the following number dependencies where successfully deleted: {1}.<br/><br/>And there where {2} errors.
sebserver.useraccount.delete.confirm.message=The User Account ({0}) was successfully deleted.<br/>Also the following number of dependencies where successfully deleted: {1}.<br/><br/>And there where {2} errors.
sebserver.useraccount.delete.confirm.message.noDeps=The User Account ({0}) was successfully deleted.
################################
# LMS Setup