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);
}
}
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);
}
}
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();
}
Aggregations