Search in sources :

Example 1 with TeiUserMarkupCollectionDeserializer

use of de.catma.serialization.tei.TeiUserMarkupCollectionDeserializer in project catma by forTEXT.

the class GraphWorktreeProject method loadAnnotationCollection.

public Pair<AnnotationCollection, List<TagsetDefinitionImportStatus>> loadAnnotationCollection(InputStream inputStream, SourceDocument document) throws IOException {
    TagManager tagManager = new TagManager(new TagLibrary());
    TeiTagLibrarySerializationHandler tagLibrarySerializationHandler = new TeiTagLibrarySerializationHandler(tagManager);
    TagLibrary importedLibrary = tagLibrarySerializationHandler.deserialize(null, inputStream);
    List<String> resourceIds = gitProjectHandler.getResourceIds();
    List<TagsetDefinitionImportStatus> tagsetDefinitionImportStatusList = new ArrayList<>();
    for (TagsetDefinition tagset : importedLibrary) {
        boolean inProjectHistory = resourceIds.contains(tagset.getUuid());
        boolean current = inProjectHistory && (getTagManager().getTagLibrary().getTagsetDefinition(tagset.getUuid()) != null);
        tagsetDefinitionImportStatusList.add(new TagsetDefinitionImportStatus(tagset, inProjectHistory, current));
    }
    String collectionId = idGenerator.generate();
    TeiUserMarkupCollectionDeserializer deserializer = new TeiUserMarkupCollectionDeserializer(tagLibrarySerializationHandler.getTeiDocument(), tagManager.getTagLibrary(), collectionId);
    AnnotationCollection annotationCollection = new AnnotationCollection(collectionId, tagLibrarySerializationHandler.getTeiDocument().getContentInfoSet(), tagManager.getTagLibrary(), deserializer.getTagReferences(), document.getUuid(), document.getRevisionHash());
    return new Pair<>(annotationCollection, tagsetDefinitionImportStatusList);
}
Also used : TagLibrary(de.catma.tag.TagLibrary) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) TeiTagLibrarySerializationHandler(de.catma.serialization.tei.TeiTagLibrarySerializationHandler) ArrayList(java.util.ArrayList) TeiUserMarkupCollectionDeserializer(de.catma.serialization.tei.TeiUserMarkupCollectionDeserializer) TagsetDefinition(de.catma.tag.TagsetDefinition) TagManager(de.catma.tag.TagManager) TagsetDefinitionImportStatus(de.catma.serialization.TagsetDefinitionImportStatus) Pair(de.catma.util.Pair)

Aggregations

AnnotationCollection (de.catma.document.annotation.AnnotationCollection)1 TagsetDefinitionImportStatus (de.catma.serialization.TagsetDefinitionImportStatus)1 TeiTagLibrarySerializationHandler (de.catma.serialization.tei.TeiTagLibrarySerializationHandler)1 TeiUserMarkupCollectionDeserializer (de.catma.serialization.tei.TeiUserMarkupCollectionDeserializer)1 TagLibrary (de.catma.tag.TagLibrary)1 TagManager (de.catma.tag.TagManager)1 TagsetDefinition (de.catma.tag.TagsetDefinition)1 Pair (de.catma.util.Pair)1 ArrayList (java.util.ArrayList)1