use of de.catma.tag.TagDefinition in project catma by forTEXT.
the class ProjectResourceExportApiRequestHandler method serializeProjectResources.
private String serializeProjectResources() {
try {
Export export = new Export();
for (SourceDocument sourceDocument : project.getSourceDocuments()) {
ArrayList<AnnotationCollection> annotationCollections = new ArrayList<>();
for (AnnotationCollectionReference annotationCollectionReference : sourceDocument.getUserMarkupCollectionRefs()) {
annotationCollections.add(project.getUserMarkupCollection(annotationCollectionReference));
}
ArrayList<TagDefinition> tagDefinitions = new ArrayList<>();
ArrayList<TagReference> tagReferences = new ArrayList<>();
for (AnnotationCollection annotationCollection : annotationCollections) {
for (TagsetDefinition tagsetDefinition : annotationCollection.getTagLibrary().getTagsetDefinitions()) {
tagDefinitions.addAll(tagsetDefinition.stream().collect(Collectors.toList()));
}
tagReferences.addAll(annotationCollection.getTagReferences());
}
ExportDocument exportDocument = new ExportDocument(new PreApiSourceDocument(sourceDocument, String.format("%s%s/doc/%s", BASE_URL, handlerPath.substring(1), sourceDocument.getUuid().toLowerCase())), tagDefinitions.stream().map(PreApiTagDefinition::new).collect(Collectors.toList()), tagReferences.stream().map((TagReference tagReference) -> {
try {
return new PreApiAnnotation(tagReference, tagDefinitions.stream().filter(td -> td.getUuid().equals(tagReference.getTagDefinitionId())).findFirst().get(), sourceDocument);
} catch (IOException e) {
logger.log(Level.WARNING, String.format("Error serializing TagReference: %s", tagReference), e);
return null;
}
}).collect(Collectors.toList()));
export.addExportDocument(exportDocument);
}
return new SerializationHelper<Export>().serialize(export);
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to serialize project resources", e);
return "{\"error\": \"Failed to serialize project resources, please contact CATMA support\"}";
}
}
use of de.catma.tag.TagDefinition in project catma by forTEXT.
the class TeiUserMarkupCollectionDeserializer method createTagInstance.
private TagInstance createTagInstance(String tagInstanceID) {
TeiElement tagInstanceElement = teiDocument.getElementByID(tagInstanceID);
TagDefinition tagDefinition = tagLibrary.getTagDefinition(tagInstanceElement.getAttributeValue(Attribute.type));
if (!old2newTagInstanceIDs.containsKey(tagInstanceElement.getID())) {
old2newTagInstanceIDs.put(tagInstanceElement.getID(), new IDGenerator().generate());
}
final TagInstance tagInstance = new TagInstance(old2newTagInstanceIDs.get(tagInstanceElement.getID()), tagDefinition.getUuid(), tagDefinition.getAuthor(), ZonedDateTime.now().format(DateTimeFormatter.ofPattern(Version.DATETIMEPATTERN)), tagDefinition.getUserDefinedPropertyDefinitions(), tagDefinition.getTagsetDefinitionUuid());
Nodes systemPropertyElements = tagInstanceElement.getChildNodes(TeiElementName.f, AttributeValue.f_name_catma_system_property.getStartsWithFilter());
addProperties(tagDefinition, new AddPropertyHandler() {
public void addProperty(Property property) {
tagInstance.addSystemProperty(property);
}
}, systemPropertyElements);
Nodes userDefinedPropertyElements = tagInstanceElement.getChildNodes(TeiElementName.f, AttributeValue.f_name_catma_system_property.getNotStartsWithFilter());
addProperties(tagDefinition, new AddPropertyHandler() {
public void addProperty(Property property) {
tagInstance.addUserDefinedProperty(property);
}
}, userDefinedPropertyElements);
return tagInstance;
}
use of de.catma.tag.TagDefinition in project catma by forTEXT.
the class TeiTagLibraryDeserializer method addTagDefinitions.
private void addTagDefinitions(TagsetDefinition tagsetDefinition, Elements tagDefinitionElements) throws ParseException {
for (int i = 0; i < tagDefinitionElements.size(); i++) {
TeiElement tagDefinitionElement = (TeiElement) tagDefinitionElements.get(i);
TeiElement descriptionElement = tagDefinitionElement.getFirstTeiChildElement(TeiElementName.fsDescr);
String description = "";
if ((descriptionElement != null) && (descriptionElement.getValue() != null)) {
description = descriptionElement.getValue();
}
TagDefinition tagDef = new TagDefinition(tagDefinitionElement.getID(), description, tagDefinitionElement.getAttributeValue(Attribute.fsDecl_baseTypes), tagsetDefinition.getUuid());
tagManager.addTagDefinition(tagsetDefinition, tagDef);
addProperties(tagDef, tagDefinitionElement.getChildNodes(TeiElementName.fDecl, AttributeValue.f_Decl_name_catma_system_property.getStartsWithFilter()), tagDefinitionElement.getChildNodes(TeiElementName.fDecl, AttributeValue.f_Decl_name_catma_system_property.getNotStartsWithFilter()));
}
}
use of de.catma.tag.TagDefinition in project catma by forTEXT.
the class TeiTagLibrarySerializer method write.
private void write(TagsetDefinition tagset, TeiElement encodingDesc) {
TeiElement fsdDecl = new TeiElement(TeiElementName.fsdDecl);
fsdDecl.setID(tagset.getUuid());
fsdDecl.setAttributeValue(Attribute.n, tagset.getName() + " " + tagset.getRevisionHash());
encodingDesc.appendChild(fsdDecl);
for (TagDefinition td : tagset) {
write(td, fsdDecl);
}
}
use of de.catma.tag.TagDefinition in project catma by forTEXT.
the class GitTagDefinition method getTagDefinition.
public TagDefinition getTagDefinition() {
TagDefinition tag = new TagDefinition(uuid, name, parentUuid, tagsetDefinitionUuid);
this.systemPropertyDefinitions.values().forEach(prop -> tag.addSystemPropertyDefinition(prop));
this.userDefinedPropertyDefinitions.values().forEach(prop -> tag.addUserDefinedPropertyDefinition(prop));
return tag;
}
Aggregations