Skip to content

Commit

Permalink
Merge pull request #4776 from inception-project/bugfix/4739-Auto-merg…
Browse files Browse the repository at this point in the history
…e-on-open-document-in-curation-mode

#4739 - Auto-merge on open document in curation mode
  • Loading branch information
reckart authored Apr 30, 2024
2 parents cb3f2f3 + 6d54725 commit f4e3687
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 f4e3687

Please sign in to comment.