Search in sources :

Example 6 with Property

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

the class AnnotationConflict method createCombinedTagInstance.

private List<TagReference> createCombinedTagInstance() throws Exception {
    TagInstance combinedInstance = new TagInstance(masterTagInstance.getUuid(), masterTagInstance.getTagDefinitionId(), masterTagInstance.getAuthor(), masterTagInstance.getTimestamp(), Collections.emptySet(), masterTagInstance.getTagsetId());
    for (Property property : masterTagInstance.getUserDefinedProperties()) {
        HashSet<String> values = new HashSet<>();
        values.addAll(property.getPropertyValueList());
        Property devUserDefinedProperty = devTagInstance.getUserDefinedPropetyByUuid(property.getPropertyDefinitionId());
        if (devUserDefinedProperty != null) {
            values.addAll(devUserDefinedProperty.getPropertyValueList());
        }
        combinedInstance.addUserDefinedProperty(new Property(property.getPropertyDefinitionId(), values));
    }
    List<TagReference> references = new ArrayList<>();
    for (TagReference tagReference : masterTagReferences) {
        references.add(new TagReference(combinedInstance, tagReference.getTarget().toString(), tagReference.getRange(), tagReference.getUserMarkupCollectionUuid()));
    }
    return references;
}
Also used : TagInstance(de.catma.tag.TagInstance) ArrayList(java.util.ArrayList) TagReference(de.catma.document.annotation.TagReference) Property(de.catma.tag.Property) HashSet(java.util.HashSet)

Example 7 with Property

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

the class GraphWorktreeProject method update.

@Override
public void update(AnnotationCollection collection, TagInstance tagInstance, Collection<Property> properties) throws IOException {
    try {
        for (Property property : properties) {
            tagInstance.addUserDefinedProperty(property);
        }
        gitProjectHandler.addOrUpdate(collection.getUuid(), collection.getTagReferences(tagInstance), tagManager.getTagLibrary());
        graphProjectHandler.updateProperties(GraphWorktreeProject.this.rootRevisionHash, collection, tagInstance, properties);
        propertyChangeSupport.firePropertyChange(RepositoryChangeEvent.propertyValueChanged.name(), tagInstance, properties);
    } catch (Exception e) {
        propertyChangeSupport.firePropertyChange(RepositoryChangeEvent.exceptionOccurred.name(), null, e);
    }
}
Also used : Property(de.catma.tag.Property) IOException(java.io.IOException)

Example 8 with Property

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

the class GraphWriter method addTagReferences.

void addTagReferences(String revisionHash, Vertex collectionV, List<TagReference> tagReferences) {
    final ArrayListMultimap<TagInstance, Range> tagInstancesAndRanges = ArrayListMultimap.create();
    tagReferences.forEach(tagReference -> {
        tagInstancesAndRanges.put(tagReference.getTagInstance(), tagReference.getRange());
    });
    Map<String, Vertex> tagNodesById = new HashMap<>();
    Set<String> availablePropertyDefIds = new HashSet<>();
    for (TagInstance ti : tagInstancesAndRanges.keySet()) {
        List<Range> ranges = tagInstancesAndRanges.get(ti);
        List<Integer> flatRanges = ranges.stream().sorted().flatMap(range -> Stream.of(range.getStartPoint(), range.getEndPoint())).collect(Collectors.toList());
        if (ti.getAuthor() == null) {
            ti.setAuthor(user.getIdentifier());
        }
        String tagsetId = ti.getTagsetId();
        String tagId = ti.getTagDefinitionId();
        Vertex tagInstanceV = graph.addVertex(nt(TagInstance));
        tagInstanceV.property("tagInstanceId", ti.getUuid());
        tagInstanceV.property("author", ti.getAuthor());
        tagInstanceV.property("timestamp", ti.getTimestamp());
        tagInstanceV.property("ranges", flatRanges);
        collectionV.addEdge(rt(hasInstance), tagInstanceV);
        Vertex tagV = tagNodesById.get(tagId);
        GraphTraversalSource g = graph.traversal();
        if (tagV == null) {
            GraphTraversal<Vertex, Vertex> traversal = g.V().has(nt(ProjectRevision), "revisionHash", revisionHash).outE(rt(hasTagset)).inV().has(nt(Tagset), "tagsetId", tagsetId).outE(rt(hasTag)).inV().has(nt(Tag), "tagId", tagId);
            if (traversal.hasNext()) {
                tagV = traversal.next();
                tagNodesById.put(tagId, tagV);
            }
        }
        if (tagV != null) {
            // usually the Tag should always be present,
            // because we delete stale Annotations when loading the Collection from git
            // if we hit an orphan Annotation at this stage it gets ignored
            // until the next sync might bring the corresponding Tag
            tagV.addEdge(rt(hasInstance), tagInstanceV);
            for (Property property : ti.getUserDefinedProperties()) {
                if (availablePropertyDefIds.contains(property.getPropertyDefinitionId()) || g.V(tagV).outE(rt(hasProperty)).inV().has(nt(Property), "uuid", property.getPropertyDefinitionId()).hasNext()) {
                    Vertex annoPropertyV = graph.addVertex(nt(AnnotationProperty));
                    annoPropertyV.property("uuid", property.getPropertyDefinitionId());
                    annoPropertyV.property("values", property.getPropertyValueList());
                    tagInstanceV.addEdge(rt(hasProperty), annoPropertyV);
                    availablePropertyDefIds.add(property.getPropertyDefinitionId());
                }
            }
        }
    }
}
Also used : Term(de.catma.repository.git.graph.NodeType.Term) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) Graph(org.apache.tinkerpop.gremlin.structure.Graph) RelationType.rt(de.catma.repository.git.graph.RelationType.rt) MarkupCollection(de.catma.repository.git.graph.NodeType.MarkupCollection) Tagset(de.catma.repository.git.graph.NodeType.Tagset) FileInfoProvider(de.catma.repository.git.graph.FileInfoProvider) Gson(com.google.gson.Gson) Map(java.util.Map) TagInstance(de.catma.repository.git.graph.NodeType.TagInstance) RelationType.hasProperty(de.catma.repository.git.graph.RelationType.hasProperty) Path(java.nio.file.Path) RelationType.hasInstance(de.catma.repository.git.graph.RelationType.hasInstance) Tag(de.catma.repository.git.graph.NodeType.Tag) Property(de.catma.repository.git.graph.NodeType.Property) Set(java.util.Set) TagInstance(de.catma.tag.TagInstance) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) SourceDocumentInfo(de.catma.document.source.SourceDocumentInfo) ProjectReference(de.catma.project.ProjectReference) TagReference(de.catma.document.annotation.TagReference) ProjectRevision(de.catma.repository.git.graph.NodeType.ProjectRevision) List(java.util.List) Stream(java.util.stream.Stream) TagDefinition(de.catma.tag.TagDefinition) RelationType.hasPosition(de.catma.repository.git.graph.RelationType.hasPosition) RelationType.isPartOf(de.catma.repository.git.graph.RelationType.isPartOf) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Range(de.catma.document.Range) PropertyDefinition(de.catma.tag.PropertyDefinition) HashMap(java.util.HashMap) User(de.catma.user.User) Level(java.util.logging.Level) HashSet(java.util.HashSet) SourceDocument(de.catma.repository.git.graph.NodeType.SourceDocument) RelationType.hasParent(de.catma.repository.git.graph.RelationType.hasParent) NodeType.nt(de.catma.repository.git.graph.NodeType.nt) TagsetDefinition(de.catma.tag.TagsetDefinition) AnnotationProperty(de.catma.repository.git.graph.NodeType.AnnotationProperty) RelationType.isAdjacentTo(de.catma.repository.git.graph.RelationType.isAdjacentTo) RelationType.hasTagset(de.catma.repository.git.graph.RelationType.hasTagset) Property(de.catma.tag.Property) RelationType.hasDocument(de.catma.repository.git.graph.RelationType.hasDocument) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) RelationType.hasTag(de.catma.repository.git.graph.RelationType.hasTag) FileUtils(org.apache.commons.io.FileUtils) SourceDocument(de.catma.document.source.SourceDocument) AnnotationCollection(de.catma.document.annotation.AnnotationCollection) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Position(de.catma.repository.git.graph.NodeType.Position) RelationType.hasCollection(de.catma.repository.git.graph.RelationType.hasCollection) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) HashMap(java.util.HashMap) Range(de.catma.document.Range) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) TagInstance(de.catma.repository.git.graph.NodeType.TagInstance) TagInstance(de.catma.tag.TagInstance) RelationType.hasProperty(de.catma.repository.git.graph.RelationType.hasProperty) Property(de.catma.repository.git.graph.NodeType.Property) AnnotationProperty(de.catma.repository.git.graph.NodeType.AnnotationProperty) Property(de.catma.tag.Property) HashSet(java.util.HashSet)

Example 9 with Property

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

the class AnnotationConflictView method createPropertyTreeDataProvider.

private TreeDataProvider<PropertyTreeItem> createPropertyTreeDataProvider(TagInstance tagInstance, TagDefinition tag) {
    TreeData<PropertyTreeItem> propertyTreeData = new TreeData<>();
    for (Property property : tagInstance.getUserDefinedProperties()) {
        PropertyDefinition propertyDef = tag.getPropertyDefinitionByUuid(property.getPropertyDefinitionId());
        PropertyDataItem propertyDataItem = new PropertyDataItem(propertyDef, property);
        propertyTreeData.addItem(null, propertyDataItem);
        for (String value : property.getPropertyValueList()) {
            propertyTreeData.addItem(propertyDataItem, new PropertyValueDataItem(property, value));
        }
    }
    TreeDataProvider<PropertyTreeItem> propertyTreeDataProvider = new TreeDataProvider<>(propertyTreeData);
    return propertyTreeDataProvider;
}
Also used : TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TreeData(com.vaadin.data.TreeData) Property(de.catma.tag.Property) PropertyDefinition(de.catma.tag.PropertyDefinition)

Example 10 with Property

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

the class EditAnnotationPropertiesDialog method createComponents.

private void createComponents(Project project) {
    propertyTabSheet = new TabSheet();
    propertyTabSheet.setSizeFull();
    String tagId = annotation.getTagInstance().getTagDefinitionId();
    TagDefinition tag = project.getTagManager().getTagLibrary().getTagDefinition(tagId);
    for (PropertyDefinition propertyDef : tag.getUserDefinedPropertyDefinitions()) {
        Property property = annotation.getTagInstance().getUserDefinedPropetyByUuid(propertyDef.getUuid());
        if (property == null) {
            property = new Property(propertyDef.getUuid(), Collections.emptySet());
        }
        propertyTabSheet.addTab(new EditPropertyTab(property, propertyDef.getPossibleValueList()), propertyDef.getName());
    }
}
Also used : TagDefinition(de.catma.tag.TagDefinition) TabSheet(com.vaadin.ui.TabSheet) PropertyDefinition(de.catma.tag.PropertyDefinition) Property(de.catma.tag.Property)

Aggregations

Property (de.catma.tag.Property)27 TagDefinition (de.catma.tag.TagDefinition)16 TagInstance (de.catma.tag.TagInstance)16 PropertyDefinition (de.catma.tag.PropertyDefinition)14 ArrayList (java.util.ArrayList)14 TagReference (de.catma.document.annotation.TagReference)10 List (java.util.List)9 Range (de.catma.document.Range)7 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)6 TagsetDefinition (de.catma.tag.TagsetDefinition)6 IDGenerator (de.catma.util.IDGenerator)6 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)5 SourceDocument (de.catma.document.source.SourceDocument)5 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)4 TagManager (de.catma.tag.TagManager)4 File (java.io.File)4 HashSet (java.util.HashSet)4 Multimap (com.google.common.collect.Multimap)3 EventBus (com.google.common.eventbus.EventBus)3 TreeData (com.vaadin.data.TreeData)3