Search in sources :

Example 21 with Element

use of org.apache.tinkerpop.gremlin.structure.Element in project timbuctoo by HuygensING.

the class Collection method setArchetype.

public void setArchetype(Collection archetypeCollection, String originalArchetypeUri) {
    vertex.edges(Direction.OUT, HAS_ARCHETYPE_RELATION_NAME).forEachRemaining(Element::remove);
    Edge edge = vertex.addEdge(HAS_ARCHETYPE_RELATION_NAME, archetypeCollection.vertex);
    edge.property(RDF_URI_PROP, originalArchetypeUri);
    copyDisplayNameFromArchetype(archetypeCollection);
}
Also used : Element(org.apache.tinkerpop.gremlin.structure.Element) Edge(org.apache.tinkerpop.gremlin.structure.Edge)

Example 22 with Element

use of org.apache.tinkerpop.gremlin.structure.Element in project timbuctoo by HuygensING.

the class Collection method copyDisplayNameFromArchetype.

private void copyDisplayNameFromArchetype(Collection archetypeCollection) {
    final Iterator<Vertex> archetypeDisplayNameT = archetypeCollection.vertex.vertices(Direction.OUT, HAS_DISPLAY_NAME_RELATION_NAME);
    if (archetypeDisplayNameT.hasNext()) {
        final Vertex archetypeDisplayName = archetypeDisplayNameT.next();
        vertex.edges(Direction.OUT, HAS_DISPLAY_NAME_RELATION_NAME).forEachRemaining(Element::remove);
        final Vertex displayName = graphWrapper.getGraph().addVertex(ReadableProperty.DATABASE_LABEL);
        archetypeDisplayName.properties().forEachRemaining(archetypeDisplayNameProp -> {
            final String value = (String) archetypeDisplayNameProp.value();
            final String key = archetypeDisplayNameProp.key();
            if (key.equals(LocalProperty.DATABASE_PROPERTY_NAME)) {
                // FIXME: string manipulation to get unprefixed property name
                final String newValue = value.replaceAll("^.+_", "");
                displayName.property(key, collectionDescription.getEntityTypeName() + "_" + newValue);
            } else {
                displayName.property(key, value);
            }
        });
        vertex.addEdge(HAS_DISPLAY_NAME_RELATION_NAME, displayName);
    }
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Element(org.apache.tinkerpop.gremlin.structure.Element)

Aggregations

Element (org.apache.tinkerpop.gremlin.structure.Element)22 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)10 Traverser (org.apache.tinkerpop.gremlin.process.traversal.Traverser)8 SqlgTraverser (org.umlg.sqlg.structure.SqlgTraverser)6 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)4 Edge (org.apache.tinkerpop.gremlin.structure.Edge)4 Test (org.junit.Test)4 BaseTest (org.umlg.sqlg.test.BaseTest)4 Var (ai.grakn.graql.Var)2 IOException (java.io.IOException)2 java.util (java.util)2 HashMap (java.util.HashMap)2 Collectors (java.util.stream.Collectors)2 DefaultGraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal)2 HasContainer (org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)2 ConfigElement (org.janusgraph.diskstorage.configuration.ConfigElement)2 Concept (ai.grakn.concept.Concept)1 ConceptId (ai.grakn.concept.ConceptId)1 SchemaConcept (ai.grakn.concept.SchemaConcept)1 Match (ai.grakn.graql.Match)1