Search in sources :

Example 1 with GetCollectionInformationResponse

use of de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse in project webanno by webanno.

the class CasToBratJsonTest method testGenerateBratJsonGetCollection.

/**
 * generate BRAT JSON for the collection informations
 *
 * @throws IOException
 *             if an I/O error occurs.
 */
@Test
public void testGenerateBratJsonGetCollection() throws IOException {
    MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
    String jsonFilePath = "target/test-output/output_cas_to_json_collection.json";
    GetCollectionInformationResponse collectionInformation = new GetCollectionInformationResponse();
    List<AnnotationLayer> layerList = new ArrayList<>();
    AnnotationLayer layer = new AnnotationLayer();
    layer.setId(1l);
    layer.setDescription("span annoattion");
    layer.setName("pos");
    layer.setType(WebAnnoConst.SPAN_TYPE);
    TagSet tagset = new TagSet();
    tagset.setId(1l);
    tagset.setDescription("pos");
    tagset.setLanguage("de");
    tagset.setName("STTS");
    Tag tag = new Tag();
    tag.setId(1l);
    tag.setDescription("noun");
    tag.setName("NN");
    tag.setTagSet(tagset);
    layerList.add(layer);
    collectionInformation.addCollection("/Collection1/");
    collectionInformation.addCollection("/Collection2/");
    collectionInformation.addCollection("/Collection3/");
    collectionInformation.addDocument("/Collection1/doc1");
    collectionInformation.addDocument("/Collection2/doc1");
    collectionInformation.addDocument("/Collection3/doc1");
    collectionInformation.addDocument("/Collection1/doc2");
    collectionInformation.addDocument("/Collection2/doc2");
    collectionInformation.addDocument("/Collection3/doc2");
    collectionInformation.setSearchConfig(new ArrayList<>());
    List<String> tagSetNames = new ArrayList<>();
    tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.POS);
    tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.DEPENDENCY);
    tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.NAMEDENTITY);
    tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.COREFERENCE);
    tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.COREFRELTYPE);
    JSONUtil.generatePrettyJson(jsonConverter, collectionInformation, new File(jsonFilePath));
    assertThat(linesOf(new File("src/test/resources/output_cas_to_json_collection_expected.json"), "UTF-8")).isEqualTo(linesOf(new File(jsonFilePath), "UTF-8"));
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) TagSet(de.tudarmstadt.ukp.clarin.webanno.model.TagSet) ArrayList(java.util.ArrayList) Tag(de.tudarmstadt.ukp.clarin.webanno.model.Tag) GetCollectionInformationResponse(de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) File(java.io.File) Test(org.junit.Test)

Example 2 with GetCollectionInformationResponse

use of de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse in project webanno by webanno.

the class SuggestionViewPanel method getCollectionInformation.

private String getCollectionInformation(AnnotationSchemaService aAnnotationService, CurationContainer aCurationContainer) throws IOException {
    GetCollectionInformationResponse info = new GetCollectionInformationResponse();
    info.setEntityTypes(BratRenderer.buildEntityTypes(aCurationContainer.getAnnotatorState().getAnnotationLayers(), aAnnotationService));
    return JSONUtil.toInterpretableJsonString(info);
}
Also used : GetCollectionInformationResponse(de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse)

Example 3 with GetCollectionInformationResponse

use of de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse in project webanno by webanno.

the class BratAnnotationEditor method bratLoadCollectionCommand.

private String bratLoadCollectionCommand() {
    GetCollectionInformationResponse response = new GetCollectionInformationResponse();
    response.setEntityTypes(BratRenderer.buildEntityTypes(getModelObject().getAnnotationLayers(), annotationService));
    String json = toJson(response);
    return "Wicket.$('" + vis.getMarkupId() + "').dispatcher.post('collectionLoaded', [" + json + "]);";
}
Also used : GetCollectionInformationResponse(de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse)

Aggregations

GetCollectionInformationResponse (de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse)3 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 Tag (de.tudarmstadt.ukp.clarin.webanno.model.Tag)1 TagSet (de.tudarmstadt.ukp.clarin.webanno.model.TagSet)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)1