Search in sources :

Example 11 with Version

use of de.catma.tag.Version in project catma by forTEXT.

the class TeiTagLibrarySerializer method write.

private void write(TagDefinition td, TeiElement fsdDecl) {
    TeiElement fsDecl = new TeiElement(TeiElementName.fsDecl);
    fsDecl.setID(td.getUuid());
    // TODO: to be backward compatible will be replaced by the revision hash
    fsDecl.setAttributeValue(Attribute.n, new Version().toString());
    fsDecl.setAttributeValue(Attribute.type, td.getUuid());
    if (!td.getParentUuid().isEmpty()) {
        fsDecl.setAttributeValue(Attribute.fsDecl_baseTypes, td.getParentUuid());
    }
    fsdDecl.appendChild(fsDecl);
    TeiElement fsDescr = new TeiElement(TeiElementName.fsDescr);
    fsDescr.appendChild(td.getName());
    fsDecl.appendChild(fsDescr);
    for (PropertyDefinition pd : td.getSystemPropertyDefinitions()) {
        write(pd, fsDecl);
    }
    for (PropertyDefinition pd : td.getUserDefinedPropertyDefinitions()) {
        write(pd, fsDecl);
    }
}
Also used : Version(de.catma.tag.Version) PropertyDefinition(de.catma.tag.PropertyDefinition)

Example 12 with Version

use of de.catma.tag.Version in project catma by forTEXT.

the class XmlMarkupCollectionSerializationHandler method deserialize.

@Override
public AnnotationCollection deserialize(SourceDocument sourceDocument, String id, InputStream inputStream) throws IOException {
    try {
        Builder builder = new Builder();
        Document document = builder.build(inputStream);
        Map<String, String> namespacePrefixToTagsetIdMap = new HashMap<>();
        for (int idx = 0; idx < document.getRootElement().getNamespaceDeclarationCount(); idx++) {
            String prefix = document.getRootElement().getNamespacePrefix(idx);
            String namespaceURI = document.getRootElement().getNamespaceURI(prefix);
            if (namespaceURI != null && !namespaceURI.isEmpty()) {
                String tagsetId = idGenerator.generateTagsetId(namespaceURI);
                if (tagManager.getTagLibrary().getTagsetDefinition(tagsetId) == null) {
                    TagsetDefinition tagsetDefinition = new TagsetDefinition(tagsetId, namespaceURI, new Version());
                    tagManager.addTagsetDefinition(tagsetDefinition);
                }
                namespacePrefixToTagsetIdMap.put(prefix, tagsetId);
            }
        }
        String defaultIntrinsicXmlTagsetId = KnownTagsetDefinitionName.DEFAULT_INTRINSIC_XML.asTagsetId();
        StringBuilder contentBuilder = new StringBuilder();
        if (tagManager.getTagLibrary().getTagsetDefinition(defaultIntrinsicXmlTagsetId) == null) {
            TagsetDefinition tagsetDefinition = new TagsetDefinition(defaultIntrinsicXmlTagsetId, null, new Version());
            tagManager.addTagsetDefinition(tagsetDefinition);
        }
        Stack<String> elementStack = new Stack<String>();
        AnnotationCollection userMarkupCollection = new AnnotationCollection(id, new ContentInfoSet("", "Intrinsic Markup", "", DEFAULT_COLLECTION_TITLE), tagManager.getTagLibrary(), sourceDocument.getUuid(), sourceDocument.getRevisionHash());
        scanElements(contentBuilder, document.getRootElement(), elementStack, tagManager, tagManager.getTagLibrary(), namespacePrefixToTagsetIdMap, userMarkupCollection, sourceDocument.getUuid(), sourceDocument.getLength());
        return userMarkupCollection;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : AnnotationCollection(de.catma.document.annotation.AnnotationCollection) HashMap(java.util.HashMap) Builder(nu.xom.Builder) IOException(java.io.IOException) SourceDocument(de.catma.document.source.SourceDocument) Document(nu.xom.Document) IOException(java.io.IOException) Stack(java.util.Stack) TagsetDefinition(de.catma.tag.TagsetDefinition) ContentInfoSet(de.catma.document.source.ContentInfoSet) Version(de.catma.tag.Version)

Example 13 with Version

use of de.catma.tag.Version in project catma by forTEXT.

the class AnnotateResourcePanel method handleAddTagsetRequest.

private void handleAddTagsetRequest() {
    SingleTextInputDialog tagsetNameDlg = new SingleTextInputDialog("Add Tagset", "Please enter the Tagset name:", new SaveCancelListener<String>() {

        @Override
        public void savePressed(String result) {
            IDGenerator idGenerator = new IDGenerator();
            project.getTagManager().addTagsetDefinition(new TagsetDefinition(idGenerator.generateTagsetId(), result, new Version()));
        }
    });
    tagsetNameDlg.show();
}
Also used : TagsetDefinition(de.catma.tag.TagsetDefinition) Version(de.catma.tag.Version) SingleTextInputDialog(de.catma.ui.dialog.SingleTextInputDialog) IDGenerator(de.catma.util.IDGenerator)

Aggregations

Version (de.catma.tag.Version)13 TagsetDefinition (de.catma.tag.TagsetDefinition)8 IDGenerator (de.catma.util.IDGenerator)7 SingleTextInputDialog (de.catma.ui.dialog.SingleTextInputDialog)5 JGitRepoManager (de.catma.repository.git.managers.JGitRepoManager)3 PropertyDefinition (de.catma.tag.PropertyDefinition)3 TagDefinition (de.catma.tag.TagDefinition)3 File (java.io.File)3 ContentInfoSet (de.catma.document.source.ContentInfoSet)2 ILocalGitRepositoryManager (de.catma.repository.git.interfaces.ILocalGitRepositoryManager)2 GitLabServerManagerTest (de.catma.repository.git.managers.GitLabServerManagerTest)2 GitTagDefinition (de.catma.repository.git.serialization.model_wrappers.GitTagDefinition)2 JsonLdWebAnnotationTest (de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotationTest)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 Range (de.catma.document.Range)1 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)1 IndexInfoSet (de.catma.document.source.IndexInfoSet)1 SourceDocument (de.catma.document.source.SourceDocument)1 SourceDocumentInfo (de.catma.document.source.SourceDocumentInfo)1