From d14e58cd61423753f2bfe2082ae97e8d2cf31c39 Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Wed, 24 Apr 2024 20:56:31 +0200 Subject: [PATCH] #4762 - Re-merging via the curation sidebar always uses the project settings instead of the dialog settings - Pass the dialog settings on to the merge operation --- .../ui/curation/sidebar/CurationSidebar.java | 7 ++-- .../sidebar/CurationSidebarService.java | 10 ++++++ .../sidebar/CurationSidebarServiceImpl.java | 32 +++++++++++++++---- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebar.java b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebar.java index 88399b2c0e7..bc4114c97d6 100644 --- a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebar.java +++ b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebar.java @@ -177,15 +177,16 @@ private void actionMerge(AjaxRequestTarget aTarget, Form aForm) { var state = getModelObject(); var dataOwner = state.getUser(); + var curationWorkflow = curationWorkflowModel.getObject(); if (aForm.getModelObject().isSaveSettingsAsDefault()) { - curationService.createOrUpdateCurationWorkflow(curationWorkflowModel.getObject()); + curationService.createOrUpdateCurationWorkflow(curationWorkflow); success("Updated project merge strategy settings"); } try { - var mergeStrategyFactory = curationSidebarService.merge(state, dataOwner.getUsername(), - selectedUsers.getModelObject()); + var mergeStrategyFactory = curationSidebarService.merge(state, curationWorkflow, + dataOwner.getUsername(), selectedUsers.getModelObject()); success("Re-merge using [" + mergeStrategyFactory.getLabel() + "] finished!"); aTarget.addChildren(getPage(), IFeedback.class); } diff --git a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarService.java b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarService.java index 9ea455947e8..4fbfe63992e 100644 --- a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarService.java +++ b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarService.java @@ -33,6 +33,8 @@ import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; import de.tudarmstadt.ukp.clarin.webanno.security.model.User; import de.tudarmstadt.ukp.inception.curation.merge.MergeStrategyFactory; +import de.tudarmstadt.ukp.inception.curation.merge.strategy.MergeStrategy; +import de.tudarmstadt.ukp.inception.curation.model.CurationWorkflow; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; public interface CurationSidebarService @@ -133,4 +135,12 @@ List listUsersReadyForCuration(String aUsername, Project aProject, MergeStrategyFactory merge(AnnotatorState aState, String aCurator, Collection aUsers) throws IOException, UIMAException; + + void merge(AnnotatorState aState, MergeStrategy aStrategy, String aCurator, + Collection aUsers) + throws IOException, UIMAException; + + MergeStrategyFactory merge(AnnotatorState aState, CurationWorkflow aWorkflow, + String aCurator, Collection aUsers) + throws IOException, UIMAException; } diff --git a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java index 6359ba92194..46daa2f53b8 100644 --- a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java +++ b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java @@ -64,8 +64,10 @@ import de.tudarmstadt.ukp.inception.annotation.events.DocumentOpenedEvent; import de.tudarmstadt.ukp.inception.curation.config.CurationServiceAutoConfiguration; import de.tudarmstadt.ukp.inception.curation.merge.MergeStrategyFactory; +import de.tudarmstadt.ukp.inception.curation.merge.strategy.MergeStrategy; import de.tudarmstadt.ukp.inception.curation.model.CurationSettings; import de.tudarmstadt.ukp.inception.curation.model.CurationSettingsId; +import de.tudarmstadt.ukp.inception.curation.model.CurationWorkflow; import de.tudarmstadt.ukp.inception.curation.service.CurationMergeService; import de.tudarmstadt.ukp.inception.curation.service.CurationService; import de.tudarmstadt.ukp.inception.curation.sidebar.CurationSidebarProperties; @@ -541,10 +543,33 @@ public boolean isCurationFinished(AnnotatorState aState, String aSessionOwner) && sourceDoc.getState().equals(CURATION_FINISHED)); } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public MergeStrategyFactory merge(AnnotatorState aState, String aCurator, Collection aUsers) throws IOException, UIMAException + { + var workflow = curationService.readOrCreateCurationWorkflow(aState.getProject()); + return merge(aState, workflow, aCurator, aUsers); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public MergeStrategyFactory merge(AnnotatorState aState, CurationWorkflow aWorkflow, + String aCurator, Collection aUsers) + throws IOException, UIMAException + { + MergeStrategyFactory factory = curationService.getMergeStrategyFactory(aWorkflow); + var traits = factory.readTraits(aWorkflow); + var mergeStrategy = factory.makeStrategy(traits); + merge(aState, mergeStrategy, aCurator, aUsers); + return factory; + } + + @Override + public void merge(AnnotatorState aState, MergeStrategy aStrategy, String aCurator, + Collection aUsers) + throws IOException, UIMAException { var doc = aState.getDocument(); var aTargetCas = retrieveCurationCAS(aCurator, doc.getProject().getId(), doc).orElseThrow( @@ -555,18 +580,13 @@ public MergeStrategyFactory merge(AnnotatorState aState, String aCurator, // FIXME: should merging not overwrite the current users annos? (can result in // deleting the users annotations!!!), currently fixed by warn message to user // prepare merged CAS - var workflow = curationService.readOrCreateCurationWorkflow(aState.getProject()); - MergeStrategyFactory factory = curationService.getMergeStrategyFactory(workflow); - var mergeStrategy = factory.makeStrategy(factory.readTraits(workflow)); curationMergeService.mergeCasses(doc, aState.getUser().getUsername(), aTargetCas, userCases, - mergeStrategy, aState.getAnnotationLayers()); + aStrategy, aState.getAnnotationLayers()); // write back and update timestamp writeCurationCas(aTargetCas, aState, doc.getProject().getId()); LOG.debug("Merge done"); - - return factory; } private class CurationSession