Merge remote-tracking branch 'origin/dev-1.1-patch-1' into development

This commit is contained in:
anhefti 2021-04-06 19:30:15 +02:00
commit 357251d40b
2 changed files with 80 additions and 28 deletions

View file

@ -121,13 +121,6 @@ public class SEBSettingsForm implements TemplateComposer {
.onError(error -> pageContext.notifyLoadError(EntityType.CONFIGURATION_NODE, error)) .onError(error -> pageContext.notifyLoadError(EntityType.CONFIGURATION_NODE, error))
.getOrThrow(); .getOrThrow();
final boolean settingsPublished = this.restService.getBuilder(GetSettingsPublished.class)
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
.call()
.onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage()))
.map(result -> result.settingsPublished)
.getOr(false);
final boolean readonly = pageContext.isReadonly() || configNode.status == ConfigurationStatus.IN_USE; final boolean readonly = pageContext.isReadonly() || configNode.status == ConfigurationStatus.IN_USE;
final boolean isAttachedToExam = !readonly && this.restService final boolean isAttachedToExam = !readonly && this.restService
.getBuilder(GetExamConfigMappingNames.class) .getBuilder(GetExamConfigMappingNames.class)
@ -143,12 +136,11 @@ public class SEBSettingsForm implements TemplateComposer {
gridLayout.marginHeight = 0; gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0; gridLayout.marginWidth = 0;
warningPanelAnchor.setLayout(gridLayout); warningPanelAnchor.setLayout(gridLayout);
final Runnable publishedMessagePanelViewCallback = this.publishedMessagePanelViewCallback( final PublishedMessagePanelViewCallback publishedMessagePanelViewCallback =
warningPanelAnchor, new PublishedMessagePanelViewCallback(
entityKey.modelId); this.pageService,
if (!settingsPublished) { warningPanelAnchor,
publishedMessagePanelViewCallback.run(); entityKey.modelId);
}
final Composite content = widgetFactory.defaultPageLayout( final Composite content = widgetFactory.defaultPageLayout(
pageContext.getParent(), pageContext.getParent(),
@ -266,6 +258,9 @@ public class SEBSettingsForm implements TemplateComposer {
.ignoreMoveAwayFromEdit() .ignoreMoveAwayFromEdit()
.publish(); .publish();
publishedMessagePanelViewCallback.activate();
publishedMessagePanelViewCallback.run();
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
pageContext.notifyUnexpectedError(e); pageContext.notifyUnexpectedError(e);
throw e; throw e;
@ -275,32 +270,85 @@ public class SEBSettingsForm implements TemplateComposer {
} }
} }
private Runnable publishedMessagePanelViewCallback(final Composite parent, final String nodeId) { private static class PublishedMessagePanelViewCallback implements Runnable {
return () -> {
if (parent.getChildren() != null && parent.getChildren().length > 0) { private final PageService pageService;
private final Composite parent;
private final String nodeId;
private boolean active = false;
public PublishedMessagePanelViewCallback(
final PageService pageService,
final Composite parent,
final String nodeId) {
this.pageService = pageService;
this.parent = parent;
this.nodeId = nodeId;
}
public void activate() {
this.active = true;
}
@Override
public void run() {
if (!this.active) {
return; return;
} }
final boolean settingsPublished = this.restService.getBuilder(GetSettingsPublished.class) final boolean settingsPublished = this.pageService.getRestService()
.withURIVariable(API.PARAM_MODEL_ID, nodeId) .getBuilder(GetSettingsPublished.class)
.withURIVariable(API.PARAM_MODEL_ID, this.nodeId)
.call() .call()
.onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage())) .onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage()))
.map(result -> result.settingsPublished) .map(result -> result.settingsPublished)
.getOr(false); .getOr(false);
if (!settingsPublished) { if (!settingsPublished) {
if (this.parent.getChildren() != null && this.parent.getChildren().length == 0) {
final WidgetFactory widgetFactory = this.pageService.getWidgetFactory(); final WidgetFactory widgetFactory = this.pageService.getWidgetFactory();
final Composite warningPanel = widgetFactory.createWarningPanel(parent); final Composite warningPanel = widgetFactory.createWarningPanel(this.parent);
widgetFactory.labelLocalized( widgetFactory.labelLocalized(
warningPanel, warningPanel,
CustomVariant.MESSAGE, CustomVariant.MESSAGE,
UNPUBLISHED_MESSAGE_KEY); UNPUBLISHED_MESSAGE_KEY);
parent.getParent().layout(); }
} else if (this.parent.getChildren() != null && this.parent.getChildren().length > 0) {
this.parent.getChildren()[0].dispose();
} }
}; this.parent.getParent().layout();
}
} }
// private Runnable publishedMessagePanelViewCallback(
// final Composite parent,
// final String nodeId) {
// return () -> {
// final boolean settingsPublished = this.restService.getBuilder(GetSettingsPublished.class)
// .withURIVariable(API.PARAM_MODEL_ID, nodeId)
// .call()
// .onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage()))
// .map(result -> result.settingsPublished)
// .getOr(false);
//
// if (!settingsPublished) {
// if (parent.getChildren() != null && parent.getChildren().length == 0) {
// final WidgetFactory widgetFactory = this.pageService.getWidgetFactory();
// final Composite warningPanel = widgetFactory.createWarningPanel(parent);
// widgetFactory.labelLocalized(
// warningPanel,
// CustomVariant.MESSAGE,
// UNPUBLISHED_MESSAGE_KEY);
// }
// } else if (parent.getChildren() != null && parent.getChildren().length > 0) {
// parent.getChildren()[0].dispose();
// }
// parent.getParent().layout();
// };
// }
private void notifyErrorOnSave(final Exception error, final PageContext context) { private void notifyErrorOnSave(final Exception error, final PageContext context) {
if (error instanceof APIMessageError) { if (error instanceof APIMessageError) {
try { try {

View file

@ -186,7 +186,11 @@ public class TableConverter implements AttributeValueConverter {
if (value == null) { if (value == null) {
log.warn("Missing AttributeValue for ConfigurationAttribute: {}. Create ad-hoc attribute", attr); if (log.isDebugEnabled()) {
log.warn(
"Missing AttributeValue for ConfigurationAttribute: {}. Create ad-hoc attribute",
attr);
}
value = new ConfigurationValue( value = new ConfigurationValue(
-1L, -1L,