Search in sources :

Example 1 with SpanDeletedEvent

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.event.SpanDeletedEvent in project webanno by webanno.

the class SpanAdapter method delete.

@Override
public void delete(AnnotatorState aState, JCas aJCas, VID aVid) {
    AnnotationFS fs = selectByAddr(aJCas, AnnotationFS.class, aVid.getId());
    aJCas.removeFsFromIndexes(fs);
    // delete associated attachFeature
    if (getAttachTypeName() != null) {
        Type theType = CasUtil.getType(aJCas.getCas(), getAttachTypeName());
        Feature attachFeature = theType.getFeatureByBaseName(getAttachFeatureName());
        if (attachFeature != null) {
            CasUtil.selectCovered(aJCas.getCas(), theType, fs.getBegin(), fs.getEnd()).get(0).setFeatureValue(attachFeature, null);
        }
    }
    publishEvent(new SpanDeletedEvent(this, aState.getDocument(), aState.getUser().getUsername(), fs));
}
Also used : SpanDeletedEvent(de.tudarmstadt.ukp.clarin.webanno.api.annotation.event.SpanDeletedEvent) AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) CasUtil.getType(org.apache.uima.fit.util.CasUtil.getType) Feature(org.apache.uima.cas.Feature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

SpanDeletedEvent (de.tudarmstadt.ukp.clarin.webanno.api.annotation.event.SpanDeletedEvent)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 Feature (org.apache.uima.cas.Feature)1 Type (org.apache.uima.cas.Type)1 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)1 CasUtil.getType (org.apache.uima.fit.util.CasUtil.getType)1