Skip to content

Commit

Permalink
#4739 - Auto-merge on open document in curation mode
Browse files Browse the repository at this point in the history
- Trigger merge based on source document state and not based on whether the curation CAS exists
- Delete curation CAS as part of bulk reset
  • Loading branch information
reckart committed Apr 29, 2024
1 parent cb3f2f3 commit 6d54725
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasUpgradeMode.FORCE_CAS_UPGRADE;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.CURATOR;
import static de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentState.CURATION_FINISHED;
import static de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentState.CURATION_IN_PROGRESS;
import static de.tudarmstadt.ukp.clarin.webanno.ui.core.page.ProjectPageBase.setProjectPageParameter;
import static de.tudarmstadt.ukp.inception.curation.sidebar.CurationSidebarManagerPrefs.KEY_CURATION_SIDEBAR_MANAGER_PREFS;
import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.CURATION_USER;
Expand Down Expand Up @@ -123,7 +125,7 @@ private void onPreparingToOpenDocumentEvent(PreparingToOpenDocumentEvent aEvent)
var prefs = preferencesService
.loadDefaultTraitsForProject(KEY_CURATION_SIDEBAR_MANAGER_PREFS, project);
if (prefs.isAutoMergeCurationSidebar()) {
if (userService.getCurationUser().getUsername().equals(aEvent.getDocumentOwner())) {
if (userService.getCurationUser().equals(page.getModelObject().getUser())) {
autoMerge(aEvent, page);
}
}
Expand All @@ -137,7 +139,8 @@ private void autoMerge(PreparingToOpenDocumentEvent aEvent, AnnotationPageBase p

try {
var editable = page.isEditable();
if (!curationDocumentService.existsCurationCas(doc) && editable) {
if (!asList(CURATION_IN_PROGRESS, CURATION_FINISHED).contains(doc.getState())
&& editable) {
var state = page.getModelObject();
// We need to force upgrade the editor CAS here already so the merge can succeed
// The annotation page will do this again in the actionLoadDocument, but I don't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ private void actionBulkResetCuration(AjaxRequestTarget aTarget)

documentService.bulkSetSourceDocumentState(documentsToReset, ANNOTATION_IN_PROGRESS);

for (var doc : documentsToReset) {
curationService.deleteCurationCas(doc);
}

success(format("The curation state of %s document(s) has been set reset.",
documentsToReset.size()));
_target.addChildren(getPage(), IFeedback.class);
Expand Down Expand Up @@ -483,9 +487,10 @@ private void actionResetCurationDocument(AjaxRequestTarget aTarget, SourceDocume

dialogContent.setExpectedResponseModel(Model.of(aDocument.getName()));
dialogContent.setConfirmAction(_target -> {
curationService.deleteCurationCas(aDocument);
documentService.setSourceDocumentState(aDocument, ANNOTATION_IN_PROGRESS);

curationService.deleteCurationCas(aDocument);

success(format("The curation of document [%s] has been set reset.",
aDocument.getName()));
_target.addChildren(getPage(), IFeedback.class);
Expand Down

0 comments on commit 6d54725

Please sign in to comment.