Search in sources :

Example 1 with PreRendererImpl

use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRendererImpl in project webanno by webanno.

the class BratRendererTest method setup.

@Before
public void setup() {
    initMocks(this);
    project = new Project();
    tokenLayer = new AnnotationLayer(Token.class.getName(), "Token", SPAN_TYPE, null, true, SINGLE_TOKEN, NO_OVERLAP);
    tokenLayer.setId(1l);
    tokenPosFeature = new AnnotationFeature();
    tokenPosFeature.setId(1l);
    tokenPosFeature.setName("pos");
    tokenPosFeature.setEnabled(true);
    tokenPosFeature.setType(POS.class.getName());
    tokenPosFeature.setUiName("pos");
    tokenPosFeature.setLayer(tokenLayer);
    tokenPosFeature.setProject(project);
    tokenPosFeature.setVisible(true);
    posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE, project, true, SINGLE_TOKEN, NO_OVERLAP);
    posLayer.setId(2l);
    posLayer.setAttachType(tokenLayer);
    posLayer.setAttachFeature(tokenPosFeature);
    posFeature = new AnnotationFeature();
    posFeature.setId(2l);
    posFeature.setName("PosValue");
    posFeature.setEnabled(true);
    posFeature.setType(CAS.TYPE_NAME_STRING);
    posFeature.setUiName("PosValue");
    posFeature.setLayer(posLayer);
    posFeature.setProject(project);
    posFeature.setVisible(true);
    FeatureSupportRegistryImpl featureSupportRegistry = new FeatureSupportRegistryImpl(asList(new StringFeatureSupport(), new BooleanFeatureSupport(), new NumberFeatureSupport(), new SlotFeatureSupport(schemaService)));
    featureSupportRegistry.init();
    LayerBehaviorRegistryImpl layerBehaviorRegistry = new LayerBehaviorRegistryImpl(asList());
    layerBehaviorRegistry.init();
    LayerSupportRegistryImpl layerRegistry = new LayerSupportRegistryImpl(asList(new SpanLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new RelationLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry), new ChainLayerSupport(featureSupportRegistry, null, layerBehaviorRegistry)));
    layerRegistry.init();
    when(schemaService.listSupportedLayers(any())).thenReturn(asList(posLayer));
    when(schemaService.listAnnotationLayer(any())).thenReturn(asList(posLayer));
    when(schemaService.listSupportedFeatures(any(Project.class))).thenReturn(asList(posFeature));
    when(schemaService.listAnnotationFeature(any(Project.class))).thenReturn(asList(posFeature));
    when(schemaService.getAdapter(any(AnnotationLayer.class))).then(_call -> {
        AnnotationLayer layer = _call.getArgument(0);
        return layerRegistry.getLayerSupport(layer).createAdapter(layer, () -> asList(posFeature));
    });
    preRenderer = new PreRendererImpl(layerRegistry, schemaService);
}
Also used : SlotFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport) SpanLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.SpanLayerSupport) NumberFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport) RelationLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.RelationLayerSupport) BooleanFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) ChainLayerSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.ChainLayerSupport) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) FeatureSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl) PreRendererImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRendererImpl) LayerSupportRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerSupportRegistryImpl) StringFeatureSupport(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport) LayerBehaviorRegistryImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Before(org.junit.Before)

Aggregations

BooleanFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport)1 FeatureSupportRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl)1 NumberFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport)1 SlotFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport)1 StringFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport)1 ChainLayerSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.ChainLayerSupport)1 LayerBehaviorRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerBehaviorRegistryImpl)1 LayerSupportRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.LayerSupportRegistryImpl)1 RelationLayerSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.RelationLayerSupport)1 SpanLayerSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.layer.SpanLayerSupport)1 PreRendererImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.PreRendererImpl)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)1 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)1 Before (org.junit.Before)1