SEBSERV-230 removed attributes from GUI

This commit is contained in:
anhefti 2021-09-27 10:35:21 +02:00
parent b42dd5e146
commit 33c915bd92
4 changed files with 89 additions and 63 deletions

View file

@ -1027,7 +1027,10 @@ public class WidgetFactory {
} }
public static void setARIALabel(final Widget widget, final String label) { public static void setARIALabel(final Widget widget, final String label) {
setAttribute(widget, ADD_HTML_ATTR_ARIA_LABEL, label); setAttribute(
widget,
ADD_HTML_ATTR_ARIA_LABEL,
Utils.escapeHTML_XML_EcmaScript(label));
} }
public static void setAttribute(final Widget widget, final String name, final String value) { public static void setAttribute(final Widget widget, final String name, final String value) {

View file

@ -127,6 +127,9 @@ class ConfigurationDAOBatchService {
.where( .where(
ConfigurationNodeRecordDynamicSqlSupport.name, ConfigurationNodeRecordDynamicSqlSupport.name,
isEqualTo(data.name)) isEqualTo(data.name))
.and(
ConfigurationNodeRecordDynamicSqlSupport.type,
SqlBuilder.isEqualTo(data.type.name()))
.and( .and(
ConfigurationNodeRecordDynamicSqlSupport.institutionId, ConfigurationNodeRecordDynamicSqlSupport.institutionId,
SqlBuilder.isEqualTo(data.institutionId)) SqlBuilder.isEqualTo(data.institutionId))
@ -355,6 +358,9 @@ class ConfigurationDAOBatchService {
.where( .where(
ConfigurationNodeRecordDynamicSqlSupport.name, ConfigurationNodeRecordDynamicSqlSupport.name,
isEqualTo(copyInfo.name)) isEqualTo(copyInfo.name))
.and(
ConfigurationNodeRecordDynamicSqlSupport.type,
SqlBuilder.isEqualTo(copyInfo.configurationType.name()))
.and( .and(
ConfigurationNodeRecordDynamicSqlSupport.institutionId, ConfigurationNodeRecordDynamicSqlSupport.institutionId,
isEqualTo(institutionId)) isEqualTo(institutionId))
@ -406,9 +412,9 @@ class ConfigurationDAOBatchService {
if (BooleanUtils.toBoolean(copyInfo.withHistory)) { if (BooleanUtils.toBoolean(copyInfo.withHistory)) {
configs.forEach(configRec -> this.copyConfiguration( configs.forEach(configRec -> this.copyConfiguration(
configRec.getInstitutionId(), configRec.getInstitutionId(),
configRec.getId(), configRec.getId(),
newNodeRec.getId())); newNodeRec.getId()));
} else { } else {
configs configs
.stream() .stream()
@ -764,37 +770,37 @@ class ConfigurationDAOBatchService {
final List<ConfigurationValueRecord> templateValues = getTemplateValues(configNode); final List<ConfigurationValueRecord> templateValues = getTemplateValues(configNode);
templateValues.forEach(templateValue -> { templateValues.forEach(templateValue -> {
final Long existingId = this.batchConfigurationValueRecordMapper final Long existingId = this.batchConfigurationValueRecordMapper
.selectIdsByExample() .selectIdsByExample()
.where( .where(
ConfigurationValueRecordDynamicSqlSupport.configurationId, ConfigurationValueRecordDynamicSqlSupport.configurationId,
isEqualTo(config.getId())) isEqualTo(config.getId()))
.and( .and(
ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId, ConfigurationValueRecordDynamicSqlSupport.configurationAttributeId,
isEqualTo(templateValue.getConfigurationAttributeId())) isEqualTo(templateValue.getConfigurationAttributeId()))
.and( .and(
ConfigurationValueRecordDynamicSqlSupport.listIndex, ConfigurationValueRecordDynamicSqlSupport.listIndex,
isEqualTo(templateValue.getListIndex())) isEqualTo(templateValue.getListIndex()))
.build() .build()
.execute() .execute()
.stream() .stream()
.findFirst() .findFirst()
.orElse(null); .orElse(null);
final ConfigurationValueRecord valueRec = new ConfigurationValueRecord( final ConfigurationValueRecord valueRec = new ConfigurationValueRecord(
existingId, existingId,
configNode.institutionId, configNode.institutionId,
config.getId(), config.getId(),
templateValue.getConfigurationAttributeId(), templateValue.getConfigurationAttributeId(),
templateValue.getListIndex(), templateValue.getListIndex(),
templateValue.getValue()); templateValue.getValue());
if (existingId != null) { if (existingId != null) {
this.batchConfigurationValueRecordMapper.updateByPrimaryKey(valueRec); this.batchConfigurationValueRecordMapper.updateByPrimaryKey(valueRec);
} else { } else {
this.batchConfigurationValueRecordMapper.insert(valueRec); this.batchConfigurationValueRecordMapper.insert(valueRec);
} }
}); });
this.batchSqlSessionTemplate.flushStatements(); this.batchSqlSessionTemplate.flushStatements();
} }

View file

@ -185,38 +185,22 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
@Override @Override
@Transactional @Transactional
public Result<ConfigurationNode> save(final ConfigurationNode data) { public Result<ConfigurationNode> save(final ConfigurationNode data) {
return Result.tryCatch(() -> { return checkUniqueName(data)
.map(_d -> {
final Long count = this.configurationNodeRecordMapper.countByExample() final ConfigurationNodeRecord newRecord = new ConfigurationNodeRecord(
.where( data.id,
ConfigurationNodeRecordDynamicSqlSupport.name, null,
isEqualTo(data.name)) null,
.and( null,
ConfigurationNodeRecordDynamicSqlSupport.id, data.name,
isNotEqualTo(data.id)) data.description,
.and( null,
ConfigurationNodeRecordDynamicSqlSupport.institutionId, (data.status != null) ? data.status.name() : ConfigurationStatus.CONSTRUCTION.name());
isNotEqualTo(data.institutionId))
.build()
.execute();
if (count != null && count > 0) { this.configurationNodeRecordMapper.updateByPrimaryKeySelective(newRecord);
throw new FieldValidationException("name", "configurationNode:name:exists"); return this.configurationNodeRecordMapper.selectByPrimaryKey(data.id);
} })
final ConfigurationNodeRecord newRecord = new ConfigurationNodeRecord(
data.id,
null,
null,
null,
data.name,
data.description,
null,
(data.status != null) ? data.status.name() : ConfigurationStatus.CONSTRUCTION.name());
this.configurationNodeRecordMapper.updateByPrimaryKeySelective(newRecord);
return this.configurationNodeRecordMapper.selectByPrimaryKey(data.id);
})
.flatMap(ConfigurationNodeDAOImpl::toDomainModel) .flatMap(ConfigurationNodeDAOImpl::toDomainModel)
.onError(TransactionHandler::rollback); .onError(TransactionHandler::rollback);
} }
@ -316,6 +300,32 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
}); });
} }
private Result<ConfigurationNode> checkUniqueName(final ConfigurationNode data) {
return Result.tryCatch(() -> {
final Long count = this.configurationNodeRecordMapper.countByExample()
.where(
ConfigurationNodeRecordDynamicSqlSupport.name,
isEqualTo(data.name))
.and(
ConfigurationNodeRecordDynamicSqlSupport.type,
isNotEqualTo(data.type.name()))
.and(
ConfigurationNodeRecordDynamicSqlSupport.id,
isNotEqualTo(data.id))
.and(
ConfigurationNodeRecordDynamicSqlSupport.institutionId,
isNotEqualTo(data.institutionId))
.build()
.execute();
if (count != null && count > 0) {
throw new FieldValidationException("name", "configurationNode:name:exists");
}
return data;
});
}
static Result<ConfigurationNode> toDomainModel(final ConfigurationNodeRecord record) { static Result<ConfigurationNode> toDomainModel(final ConfigurationNodeRecord record) {
return Result.tryCatch(() -> new ConfigurationNode( return Result.tryCatch(() -> new ConfigurationNode(
record.getId(), record.getId(),

View file

@ -0,0 +1,7 @@
-- -----------------------------------------------------
-- Remove SEB Settings from GUI (and templates too)
-- -----------------------------------------------------
DELETE FROM `orientation` WHERE `config_attribute_id`='5';
DELETE FROM `orientation` WHERE `config_attribute_id`='6';
DELETE FROM `orientation` WHERE `config_attribute_id`='7';