Skip to content

Commit

Permalink
Merge pull request #4763 from inception-project/bugfix/4762-Re-mergin…
Browse files Browse the repository at this point in the history
…g-via-the-curation-sidebar-always-uses-the-project-settings-instead-of-the-dialog-settings

#4762 - Re-merging via the curation sidebar always uses the project settings instead of the dialog settings
  • Loading branch information
reckart authored Apr 24, 2024
2 parents 8a52340 + d14e58c commit 9db2487
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,16 @@ private void actionMerge(AjaxRequestTarget aTarget, Form<State> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,4 +135,12 @@ List<User> listUsersReadyForCuration(String aUsername, Project aProject,

MergeStrategyFactory<?> merge(AnnotatorState aState, String aCurator, Collection<User> aUsers)
throws IOException, UIMAException;

void merge(AnnotatorState aState, MergeStrategy aStrategy, String aCurator,
Collection<User> aUsers)
throws IOException, UIMAException;

MergeStrategyFactory<?> merge(AnnotatorState aState, CurationWorkflow aWorkflow,
String aCurator, Collection<User> aUsers)
throws IOException, UIMAException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<User> 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<User> 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<User> aUsers)
throws IOException, UIMAException
{
var doc = aState.getDocument();
var aTargetCas = retrieveCurationCAS(aCurator, doc.getProject().getId(), doc).orElseThrow(
Expand All @@ -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
Expand Down

0 comments on commit 9db2487

Please sign in to comment.