Skip to content

Commit

Permalink
#4618 - Resizing a span does not update annotations on disk
Browse files Browse the repository at this point in the history
- Save editor CAS after a resize action
  • Loading branch information
reckart committed Mar 11, 2024
1 parent 7f36c44 commit 81b202b
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
import java.io.IOException;

import org.apache.uima.cas.CAS;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.request.Request;
import org.springframework.core.annotation.Order;

import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase;
import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanAdapter;
import de.tudarmstadt.ukp.inception.diam.editor.config.DiamAutoConfig;
import de.tudarmstadt.ukp.inception.diam.model.ajax.DefaultAjaxResponse;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.rendering.model.Range;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VID;
import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService;
Expand Down Expand Up @@ -66,12 +63,13 @@ public String getCommand()
public DefaultAjaxResponse handle(AjaxRequestTarget aTarget, Request aRequest)
{
try {
AnnotationPageBase page = getPage();
CAS cas = page.getEditorCas();
var page = getPage();
var cas = page.getEditorCas();
var vid = getVid(aRequest);
AnnotatorState state = getAnnotatorState();
var state = getAnnotatorState();
var range = getRangeFromRequest(state, aRequest.getRequestParameters(), cas);
moveSpan(aTarget, cas, vid, range);
page.writeEditorCas(cas);
return new DefaultAjaxResponse(getAction(aRequest));
}
catch (Exception e) {
Expand All @@ -82,12 +80,11 @@ public DefaultAjaxResponse handle(AjaxRequestTarget aTarget, Request aRequest)
private void moveSpan(AjaxRequestTarget aTarget, CAS aCas, VID aVid, Range aRange)
throws IOException, AnnotationException
{
AnnotatorState state = getAnnotatorState();
var state = getAnnotatorState();

AnnotationFS annoFs = ICasUtil.selectAnnotationByAddr(aCas, aVid.getId());
var annoFs = ICasUtil.selectAnnotationByAddr(aCas, aVid.getId());

SpanAdapter adapter = (SpanAdapter) annotationService.findAdapter(state.getProject(),
annoFs);
var adapter = (SpanAdapter) annotationService.findAdapter(state.getProject(), annoFs);

adapter.move(state.getDocument(), state.getUser().getUsername(), aCas, annoFs,
aRange.getBegin(), aRange.getEnd());
Expand Down

0 comments on commit 81b202b

Please sign in to comment.