From a7e0cf23212c61d960db78498e2dac729ddc5873 Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Sun, 29 Oct 2023 22:15:09 +0100 Subject: [PATCH] #4258 - Reset document button for annotators in dynamic assignment mode - Replace another usage of deprecated ChallengeResponseDialog with modern approach - Move annotation reset dialog panel code to workload base module so it can be used by the static and matrix modules - Fix coloring of table headers on dynamic workload page --- .../main/ts/bootstrap/inception-tables.scss | 1 + .../DynamicWorkloadManagementPage.html | 16 ++++- .../DynamicWorkloadManagementPage.java | 63 +++++++++---------- .../DynamicWorkloadManagementPage.properties | 1 + .../support/AnnotationStateList.html | 2 +- .../dynamic/trait/DynamicWorkloadTraits.java | 11 ++++ .../MatrixWorkflowActionBarItemGroup.java | 2 +- .../MatrixWorkloadManagementPage.java | 3 +- ...ocumentConfirmationDialogContentPanel.html | 0 ...ocumentConfirmationDialogContentPanel.java | 2 +- ...tConfirmationDialogContentPanel.properties | 0 11 files changed, 62 insertions(+), 39 deletions(-) rename inception/{inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management => inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui}/ResetAnnotationDocumentConfirmationDialogContentPanel.html (100%) rename inception/{inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management => inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui}/ResetAnnotationDocumentConfirmationDialogContentPanel.java (97%) rename inception/{inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management => inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui}/ResetAnnotationDocumentConfirmationDialogContentPanel.properties (100%) diff --git a/inception/inception-bootstrap/src/main/ts/bootstrap/inception-tables.scss b/inception/inception-bootstrap/src/main/ts/bootstrap/inception-tables.scss index d85d18de7f2..22072e899a5 100644 --- a/inception/inception-bootstrap/src/main/ts/bootstrap/inception-tables.scss +++ b/inception/inception-bootstrap/src/main/ts/bootstrap/inception-tables.scss @@ -39,6 +39,7 @@ tr.even:hover{ .headers, .headers a:link, .headers a:visited{ + --bs-table-color: var(--bs-light); --bs-table-bg: #B90F22 !important; background-color:#B90F22 !important; color:white !important; diff --git a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.html b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.html index 3a6d4727e21..3c58a238b14 100644 --- a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.html +++ b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.html @@ -192,6 +192,15 @@

class="form-control" /> +
diff --git a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.java b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.java index 22f6a60570c..675e6687a29 100644 --- a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.java +++ b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.java @@ -45,10 +45,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior; import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox; @@ -81,7 +78,6 @@ import com.googlecode.wicket.jquery.core.JQueryBehavior; import com.googlecode.wicket.jquery.core.Options; -import com.googlecode.wicket.jquery.ui.widget.menu.IMenuItem; import com.googlecode.wicket.kendo.ui.KendoDataSource; import com.googlecode.wicket.kendo.ui.form.multiselect.lazy.MultiSelect; import com.googlecode.wicket.kendo.ui.renderer.ChoiceRenderer; @@ -126,6 +122,7 @@ import de.tudarmstadt.ukp.inception.workload.dynamic.workflow.WorkflowExtensionPoint; import de.tudarmstadt.ukp.inception.workload.dynamic.workflow.types.WorkflowType; import de.tudarmstadt.ukp.inception.workload.model.WorkloadManagementService; +import de.tudarmstadt.ukp.inception.workload.ui.ResetAnnotationDocumentConfirmationDialogContentPanel; /** * The workload page. It shall give project admins a fast overview on how each annotators progress @@ -170,7 +167,7 @@ public class DynamicWorkloadManagementPage private DataTable table; // Modal dialog - private ModalDialog modalDialog; + private ModalDialog dialog; private ChallengeResponseDialog resetDocumentDialog; private ContextMenu contextMenu; @@ -243,8 +240,8 @@ public void commonInit() add(createSettingsForm()); add(new LambdaAjaxLink("refresh", this::actionRefresh)); - modalDialog = new BootstrapModalDialog("modalDialog"); - add(modalDialog); + dialog = new BootstrapModalDialog("modalDialog"); + add(dialog); add(resetDocumentDialog = new ChallengeResponseDialog("resetDocumentDialog")); add(contextMenu = new ContextMenu("contextMenu")); @@ -356,15 +353,16 @@ protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) */ public Form createSettingsForm() { - DynamicWorkloadTraits traits = dynamicWorkloadExtension.readTraits(workloadManagementService + var traits = dynamicWorkloadExtension.readTraits(workloadManagementService .loadOrCreateWorkloadManagerConfiguration(currentProject.getObject())); - Form settingsForm = new Form<>("settingsForm", - new CompoundPropertyModel<>(traits)); + var settingsForm = new Form<>("settingsForm", new CompoundPropertyModel<>(traits)); settingsForm.setOutputMarkupId(true); settingsForm.add(new DocLink("workflowHelpLink", "sect_dynamic_workload")); + settingsForm.add(new CheckBox("documentResetAllowed")); + settingsForm.add(new CheckBox("confirmFinishingDocuments")); settingsForm.add(new NumberTextField<>("defaultNumberOfAnnotations", Integer.class) // @@ -372,7 +370,7 @@ public Form createSettingsForm() .setConvertEmptyInputStringToNull(false) // .setRequired(true)); - CheckBox abandonationToggle = new CheckBox("abandonationToggle"); + var abandonationToggle = new CheckBox("abandonationToggle"); abandonationToggle.setModel(new LambdaModelAdapter(() -> { Duration d = settingsForm.getModelObject().getAbandonationTimeout(); return !(d.isNegative() || d.isZero()); @@ -388,7 +386,7 @@ public Form createSettingsForm() _target -> _target.add(settingsForm))); settingsForm.add(abandonationToggle); - Component abandonationTimeout = new NumberTextField<>("abandonationTimeout", Long.class) // + var abandonationTimeout = new NumberTextField<>("abandonationTimeout", Long.class) // .setMinimum(0l) // .setConvertEmptyInputStringToNull(false) // .setRequired(true) @@ -409,8 +407,7 @@ public Form createSettingsForm() _target.add(settingsForm); }).add(visibleWhen(abandonationToggle.getModel()))); - DropDownChoice abandonationState = new DropDownChoice<>( - "abandonationState"); + var abandonationState = new DropDownChoice("abandonationState"); abandonationState.setRequired(true); abandonationState.setNullValid(false); abandonationState.setChoiceRenderer(new EnumChoiceRenderer<>(abandonationState)); @@ -419,7 +416,7 @@ public Form createSettingsForm() abandonationState.add(visibleWhen(abandonationToggle.getModel())); settingsForm.add(abandonationState); - DropDownChoice workflowChoices = new DropDownChoice<>("workflowType"); + var workflowChoices = new DropDownChoice("workflowType"); workflowChoices.setChoiceRenderer( new LambdaChoiceRenderer<>(id -> workflowExtensionPoint.getExtension(id) .map(WorkflowExtension::getLabel).orElse("<" + id + " not available>"))); @@ -641,11 +638,11 @@ public void onSourceDocumentFilterStateChanged(SourceDocumentFilterStateChanged private List getQueue() { - Project project = currentProject.getObject(); + var project = currentProject.getObject(); dynamicWorkloadExtension.freshenStatus(project); - Map> documentMap = new HashMap<>(); + var documentMap = new HashMap>(); documentService.listSourceDocuments(project) .forEach(d -> documentMap.put(d, new ArrayList<>())); @@ -653,11 +650,11 @@ private List getQueue() documentService.listAnnotationDocuments(project).forEach(ad -> documentMap .computeIfAbsent(ad.getDocument(), d -> new ArrayList<>()).add(ad)); - DynamicWorkloadTraits traits = dynamicWorkloadExtension.readTraits(workloadManagementService + var traits = dynamicWorkloadExtension.readTraits(workloadManagementService .loadOrCreateWorkloadManagerConfiguration(currentProject.getObject())); - List queue = new ArrayList<>(); - for (Entry> e : documentMap.entrySet()) { + var queue = new ArrayList(); + for (var e : documentMap.entrySet()) { queue.add(new AnnotationQueueItem(e.getKey(), e.getValue(), traits.getDefaultNumberOfAnnotations(), traits.getAbandonationTimeout())); } @@ -667,10 +664,10 @@ private List getQueue() @OnEvent public void onAnnotatorColumnCellClickEvent(AnnotatorColumnCellClickEvent aEvent) { - AnnotationDocument annotationDocument = documentService + var annotationDocument = documentService .createOrGetAnnotationDocument(aEvent.getSourceDocument(), aEvent.getUser()); - AnnotationDocumentState targetState = oneClickTransition(annotationDocument); + var targetState = oneClickTransition(annotationDocument); documentService.setAnnotationDocumentState(annotationDocument, targetState); @@ -682,9 +679,9 @@ public void onAnnotatorColumnCellClickEvent(AnnotatorColumnCellClickEvent aEvent @OnEvent public void onAnnotatorColumnCellClickEvent(AnnotatorColumnCellShowAnnotatorCommentEvent aEvent) { - AnnotationDocument annDoc = documentService - .getAnnotationDocument(aEvent.getSourceDocument(), aEvent.getUser()); - modalDialog.open(new AnnotatorCommentDialogPanel(ModalDialog.CONTENT_ID, Model.of(annDoc)), + var annDoc = documentService.getAnnotationDocument(aEvent.getSourceDocument(), + aEvent.getUser()); + dialog.open(new AnnotatorCommentDialogPanel(ModalDialog.CONTENT_ID, Model.of(annDoc)), aEvent.getTarget()); } @@ -697,7 +694,7 @@ public void onAnnotatorStateOpenContextMenuEvent(AnnotatorStateOpenContextMenuEv return; } - List items = contextMenu.getItemList(); + var items = contextMenu.getItemList(); items.clear(); // The AnnotatorColumnCellOpenContextMenuEvent is not serializable, so we need to extract @@ -715,11 +712,12 @@ public void onAnnotatorStateOpenContextMenuEvent(AnnotatorStateOpenContextMenuEv private void actionResetAnnotationDocument(AjaxRequestTarget aTarget, SourceDocument aDocument, User aUser) { - resetDocumentDialog.setTitleModel(new ResourceModel("ResetDocumentDialog.title")); - resetDocumentDialog.setMessageModel(new ResourceModel("ResetDocumentDialog.text")); - resetDocumentDialog.setExpectedResponseModel( + var dialogContent = new ResetAnnotationDocumentConfirmationDialogContentPanel( + ModalDialog.CONTENT_ID); + + dialogContent.setExpectedResponseModel( Model.of(aUser.getUiName() + " / " + aDocument.getName())); - resetDocumentDialog.setConfirmAction(_target -> { + dialogContent.setConfirmAction(_target -> { documentService.resetAnnotationCas(aDocument, aUser); success(format("The annotations of document [%s] for user [%s] have been set reset.", @@ -728,13 +726,14 @@ private void actionResetAnnotationDocument(AjaxRequestTarget aTarget, SourceDocu updateTable(_target); }); - resetDocumentDialog.show(aTarget); + + dialog.open(dialogContent, aTarget); } private void actionTouchAnnotationDocument(AjaxRequestTarget aTarget, SourceDocument aDocument, User aUser) { - AnnotationDocument ann = documentService.getAnnotationDocument(aDocument, aUser); + var ann = documentService.getAnnotationDocument(aDocument, aUser); ann.setTimestamp(new Date()); documentService.createAnnotationDocument(ann); diff --git a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.properties b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.properties index dbe010d830d..d26608cec4d 100644 --- a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.properties +++ b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/DynamicWorkloadManagementPage.properties @@ -69,6 +69,7 @@ assignDocument=Assign document(s) unassignDocument=Delete a document stateFilter=Document state confirmFinishingDocuments=Confirm finishing documents +documentResetAllowed=Allow resetting the document to its original state assignDocument.null=Please select a document unassignDocument.null=Please select a document diff --git a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/support/AnnotationStateList.html b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/support/AnnotationStateList.html index 21732a323ca..026fbf32f1f 100644 --- a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/support/AnnotationStateList.html +++ b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/management/support/AnnotationStateList.html @@ -19,7 +19,7 @@ - + diff --git a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/trait/DynamicWorkloadTraits.java b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/trait/DynamicWorkloadTraits.java index 54455e5c956..ac2520fa7b3 100644 --- a/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/trait/DynamicWorkloadTraits.java +++ b/inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/trait/DynamicWorkloadTraits.java @@ -39,6 +39,7 @@ public class DynamicWorkloadTraits private String workflowType; private int defaultNumberOfAnnotations; private boolean confirmFinishingDocuments = true; + private boolean documentResetAllowed = true; private Duration abandonationTimeout; private AnnotationDocumentState abandonationState = IGNORE; @@ -112,4 +113,14 @@ public void setConfirmFinishingDocuments(boolean aConfirmFinishingDocuments) { confirmFinishingDocuments = aConfirmFinishingDocuments; } + + public boolean isDocumentResetAllowed() + { + return documentResetAllowed; + } + + public void setDocumentResetAllowed(boolean aDocumentResetAllowed) + { + documentResetAllowed = aDocumentResetAllowed; + } } diff --git a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/annotation/MatrixWorkflowActionBarItemGroup.java b/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/annotation/MatrixWorkflowActionBarItemGroup.java index 83ef2a92196..c3f7b63606b 100644 --- a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/annotation/MatrixWorkflowActionBarItemGroup.java +++ b/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/annotation/MatrixWorkflowActionBarItemGroup.java @@ -65,9 +65,9 @@ import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; import de.tudarmstadt.ukp.inception.schema.adapter.AnnotationException; import de.tudarmstadt.ukp.inception.workload.matrix.MatrixWorkloadExtension; -import de.tudarmstadt.ukp.inception.workload.matrix.management.ResetAnnotationDocumentConfirmationDialogContentPanel; import de.tudarmstadt.ukp.inception.workload.matrix.trait.MatrixWorkloadTraits; import de.tudarmstadt.ukp.inception.workload.model.WorkloadManagementService; +import de.tudarmstadt.ukp.inception.workload.ui.ResetAnnotationDocumentConfirmationDialogContentPanel; import wicket.contrib.input.events.key.KeyType; public class MatrixWorkflowActionBarItemGroup diff --git a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/MatrixWorkloadManagementPage.java b/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/MatrixWorkloadManagementPage.java index 27cbe50a658..82830a57f13 100755 --- a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/MatrixWorkloadManagementPage.java +++ b/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/MatrixWorkloadManagementPage.java @@ -115,6 +115,7 @@ import de.tudarmstadt.ukp.inception.workload.matrix.management.support.UserSelectToolbar; import de.tudarmstadt.ukp.inception.workload.matrix.trait.MatrixWorkloadTraits; import de.tudarmstadt.ukp.inception.workload.model.WorkloadManagementService; +import de.tudarmstadt.ukp.inception.workload.ui.ResetAnnotationDocumentConfirmationDialogContentPanel; @MountPath(NS_PROJECT + "/${" + PAGE_PARAM_PROJECT + "}/monitoring") public class MatrixWorkloadManagementPage @@ -302,7 +303,7 @@ private void actionToggleBulkChange(AjaxRequestTarget aTarget) private void actionBulkResetDocument(AjaxRequestTarget aTarget) { - List selectedDocuments = selectedAnnotationDocuments().stream() + var selectedDocuments = selectedAnnotationDocuments().stream() .filter(annDoc -> annDoc.getState() == IN_PROGRESS || annDoc.getState() == FINISHED) .collect(Collectors.toList()); diff --git a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.html b/inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.html similarity index 100% rename from inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.html rename to inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.html diff --git a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.java b/inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.java similarity index 97% rename from inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.java rename to inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.java index 9808202ef13..3df4bf1f82b 100644 --- a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.java +++ b/inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.tudarmstadt.ukp.inception.workload.matrix.management; +package de.tudarmstadt.ukp.inception.workload.ui; import java.util.Collection; import java.util.Collections; diff --git a/inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.properties b/inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.properties similarity index 100% rename from inception/inception-workload-matrix/src/main/java/de/tudarmstadt/ukp/inception/workload/matrix/management/ResetAnnotationDocumentConfirmationDialogContentPanel.properties rename to inception/inception-workload/src/main/java/de/tudarmstadt/ukp/inception/workload/ui/ResetAnnotationDocumentConfirmationDialogContentPanel.properties