fixed view of foreign SEB Settings

This commit is contained in:
anhefti 2021-02-22 13:05:08 +01:00
parent 8e0dd36a41
commit fa327e4e29
6 changed files with 27 additions and 36 deletions

View file

@ -64,6 +64,10 @@ public final class ViewContext {
this.readonly = readonly; this.readonly = readonly;
} }
public boolean isReadonly() {
return this.readonly;
}
public I18nSupport getI18nSupport() { public I18nSupport getI18nSupport() {
return this.i18nSupport; return this.i18nSupport;
} }

View file

@ -45,7 +45,7 @@ public class BrowserViewModeRule implements ValueChangeRule {
final ConfigurationAttribute attribute, final ConfigurationAttribute attribute,
final ConfigurationValue value) { final ConfigurationValue value) {
if (StringUtils.isBlank(value.value)) { if (context.isReadonly() || StringUtils.isBlank(value.value)) {
return; return;
} }

View file

@ -41,6 +41,10 @@ public class IgnoreSEBService implements ValueChangeRule {
final ConfigurationAttribute attribute, final ConfigurationAttribute attribute,
final ConfigurationValue value) { final ConfigurationValue value) {
if (context.isReadonly()) {
return;
}
if (KEY_IGNORE_SEB_SERVICE.equals(attribute.name)) { if (KEY_IGNORE_SEB_SERVICE.equals(attribute.name)) {
if (BooleanUtils.toBoolean(value.value)) { if (BooleanUtils.toBoolean(value.value)) {
context.disable(KEY_SEB_SERVICE_POLICY); context.disable(KEY_SEB_SERVICE_POLICY);

View file

@ -37,6 +37,7 @@ import org.xml.sax.SAXException;
import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig; import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig;
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Configuration;
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
@ -140,7 +141,7 @@ public class ExamConfigIO {
.collect(Collectors.toList()); .collect(Collectors.toList());
final Function<ConfigurationAttribute, ConfigurationValue> configurationValueSupplier = final Function<ConfigurationAttribute, ConfigurationValue> configurationValueSupplier =
getConfigurationValueSupplier(institutionId, configurationId); getConfigurationValueSupplier(configurationId);
writeHeader(exportFormat, out); writeHeader(exportFormat, out);
@ -316,11 +317,13 @@ public class ExamConfigIO {
} }
private Function<ConfigurationAttribute, ConfigurationValue> getConfigurationValueSupplier( private Function<ConfigurationAttribute, ConfigurationValue> getConfigurationValueSupplier(
final Long institutionId,
final Long configurationId) { final Long configurationId) {
final Configuration configuration = this.configurationDAO.byPK(configurationId)
.getOrThrow();
final Map<Long, ConfigurationValue> mapping = this.configurationValueDAO final Map<Long, ConfigurationValue> mapping = this.configurationValueDAO
.allRootAttributeValues(institutionId, configurationId) .allRootAttributeValues(configuration.institutionId, configurationId)
.getOrThrow() .getOrThrow()
.stream() .stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(

View file

@ -267,26 +267,6 @@ public class ExamConfigServiceImpl implements ExamConfigService {
log.debug("Start to stream plain JSON SEB Configuration data for Config-Key generation"); log.debug("Start to stream plain JSON SEB Configuration data for Config-Key generation");
} }
// if (true) {
// PipedOutputStream pout;
// PipedInputStream pin;
// try {
// pout = new PipedOutputStream();
// pin = new PipedInputStream(pout);
// this.examConfigIO.exportPlain(
// ConfigurationFormat.JSON,
// pout,
// institutionId,
// configurationNodeId);
//
// final String json = IOUtils.toString(pin, "UTF-8");
//
// log.trace("SEB Configuration JSON to create Config-Key: {}", json);
// } catch (final Exception e) {
// log.error("Failed to trace SEB Configuration JSON: ", e);
// }
// }
PipedOutputStream pout = null; PipedOutputStream pout = null;
PipedInputStream pin = null; PipedInputStream pin = null;
try { try {

View file

@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.converter;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -73,9 +74,6 @@ public class TableConverter implements AttributeValueConverter {
this.configurationAttributeDAO = configurationAttributeDAO; this.configurationAttributeDAO = configurationAttributeDAO;
this.configurationValueDAO = configurationValueDAO; this.configurationValueDAO = configurationValueDAO;
log.info("******************************* inject ConfigurationValueDAO is {} configurationAttributeDAO is {}",
configurationValueDAO, configurationAttributeDAO);
} }
@Override @Override
@ -112,15 +110,17 @@ public class TableConverter implements AttributeValueConverter {
final ConfigurationValue value, final ConfigurationValue value,
final boolean xml) throws IOException { final boolean xml) throws IOException {
log.info("******************************** Convert: {} -- {} -- {}", attribute, this.configurationValueDAO, final List<List<ConfigurationValue>> values = new ArrayList<>();
value); if (value != null) {
values.addAll(this.configurationValueDAO.getOrderedTableValues(
final List<List<ConfigurationValue>> values = this.configurationValueDAO.getOrderedTableValues(
value.institutionId, value.institutionId,
value.configurationId, value.configurationId,
attribute.id) attribute.id)
.onError(error -> log.error("Failed to get table values for attribute: {}", attribute.name, error)) .onError(error -> log.error("Failed to get table values for attribute: {}", attribute.name, error))
.getOrElse(() -> Collections.emptyList()); .getOrElse(() -> Collections.emptyList()));
} else {
log.warn("No ConfigurationValue for table: {}. Convert to empty table", attribute);
}
final boolean noValues = CollectionUtils.isEmpty(values); final boolean noValues = CollectionUtils.isEmpty(values);