use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.SpanAdapter in project webanno by webanno.
the class MergeCas method copySpanAnnotation.
/**
* Copy this same annotation from the user annotation to the mergeview
*/
private static void copySpanAnnotation(AnnotatorState aState, AnnotationSchemaService aAnnotationService, AnnotationLayer aAnnotationLayer, AnnotationFS aOldFs, JCas aJCas) throws AnnotationException {
SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aAnnotationLayer);
// Create the annotation - this also takes care of attaching to an annotation if necessary
int id = adapter.add(aState, aJCas, aOldFs.getBegin(), aOldFs.getEnd());
List<AnnotationFeature> features = aAnnotationService.listAnnotationFeature(adapter.getLayer());
// Copy the features
for (AnnotationFeature feature : features) {
Type oldType = adapter.getAnnotationType(aOldFs.getCAS());
Feature oldFeature = oldType.getFeatureByBaseName(feature.getName());
if (isLinkOrBasicFeatures(aOldFs, oldFeature)) {
continue;
}
Object value = adapter.getFeatureValue(feature, aOldFs);
adapter.setFeatureValue(aState, aJCas, id, feature, value);
}
}
Aggregations