Search in sources :

Example 1 with GraphPropertiesDictionary

use of org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary in project sdc by onap.

the class InMemoryJanusGraphClient method createJanusGraphSchema.

private void createJanusGraphSchema() {
    JanusGraphManagement graphMgt = graph.openManagement();
    JanusGraphIndex index = null;
    for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
        PropertyKey propKey = null;
        if (!graphMgt.containsPropertyKey(prop.getProperty())) {
            Class<?> clazz = prop.getClazz();
            if (!ArrayList.class.getName().equals(clazz.getName()) && !HashMap.class.getName().equals(clazz.getName())) {
                propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make();
            }
        } else {
            propKey = graphMgt.getPropertyKey(prop.getProperty());
        }
        if (prop.isIndexed()) {
            if (!graphMgt.containsGraphIndex(prop.getProperty())) {
                if (prop.isUnique()) {
                    index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex();
                    // Ensures
                    graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK);
                    // only
                    // one
                    // name
                    // per
                    // vertex
                    // Ensures
                    graphMgt.setConsistency(index, ConsistencyModifier.LOCK);
                // name
                // uniqueness
                // in
                // the
                // graph
                } else {
                    graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex();
                }
            }
        }
    }
    graphMgt.commit();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) GraphPropertiesDictionary(org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) PropertyKey(org.janusgraph.core.PropertyKey)

Example 2 with GraphPropertiesDictionary

use of org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary in project sdc by onap.

the class JanusGraphInitializer method createVertexIndixes.

private static void createVertexIndixes() {
    logger.info("** createVertexIndixes started");
    JanusGraphManagement graphMgt = graph.openManagement();
    JanusGraphIndex index = null;
    for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
        PropertyKey propKey = null;
        if (!graphMgt.containsPropertyKey(prop.getProperty())) {
            Class<?> clazz = prop.getClazz();
            if (!clazz.isAssignableFrom(ArrayList.class) && !clazz.isAssignableFrom(HashMap.class)) {
                propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make();
            }
        } else {
            propKey = graphMgt.getPropertyKey(prop.getProperty());
        }
        if (prop.isIndexed()) {
            if (!graphMgt.containsGraphIndex(prop.getProperty())) {
                if (prop.isUnique()) {
                    index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex();
                    // Ensures
                    graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK);
                    // only
                    // one
                    // name
                    // per
                    // vertex
                    // Ensures
                    graphMgt.setConsistency(index, ConsistencyModifier.LOCK);
                // name
                // uniqueness
                // in
                // the
                // graph
                } else {
                    graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex();
                }
            }
        }
    }
    graphMgt.commit();
    logger.info("** createVertexIndixes ended");
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) GraphPropertiesDictionary(org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) PropertyKey(org.janusgraph.core.PropertyKey)

Example 3 with GraphPropertiesDictionary

use of org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary in project sdc by onap.

the class JanusGraphClient method createJanusGraphSchema.

private void createJanusGraphSchema() {
    JanusGraphManagement graphMgt = graph.openManagement();
    JanusGraphIndex index = null;
    for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
        PropertyKey propKey = null;
        if (!graphMgt.containsPropertyKey(prop.getProperty())) {
            Class<?> clazz = prop.getClazz();
            if (!clazz.isAssignableFrom(ArrayList.class) && !clazz.isAssignableFrom(HashMap.class)) {
                propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make();
            }
        } else {
            propKey = graphMgt.getPropertyKey(prop.getProperty());
        }
        if (prop.isIndexed() && !graphMgt.containsGraphIndex(prop.getProperty())) {
            if (prop.isUnique()) {
                index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex();
                // Ensures only one name per vertex
                graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK);
                // Ensures name uniqueness in the graph
                graphMgt.setConsistency(index, ConsistencyModifier.LOCK);
            } else {
                graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex();
            }
        }
    }
    graphMgt.commit();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) GraphPropertiesDictionary(org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) PropertyKey(org.janusgraph.core.PropertyKey)

Example 4 with GraphPropertiesDictionary

use of org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary in project sdc by onap.

the class JanusGraphTestSetup method createVertexIndixes.

private static void createVertexIndixes() {
    logger.info("** createVertexIndixes started");
    JanusGraphManagement graphMgt = graph.openManagement();
    JanusGraphIndex index = null;
    for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
        PropertyKey propKey = null;
        if (!graphMgt.containsPropertyKey(prop.getProperty())) {
            Class<?> clazz = prop.getClazz();
            if (!ArrayList.class.getName().equals(clazz.getName()) && !HashMap.class.getName().equals(clazz.getName())) {
                propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make();
            }
        } else {
            propKey = graphMgt.getPropertyKey(prop.getProperty());
        }
        if (prop.isIndexed()) {
            if (!graphMgt.containsGraphIndex(prop.getProperty())) {
                if (prop.isUnique()) {
                    index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex();
                    // Ensures
                    graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK);
                    // only
                    // one
                    // name
                    // per
                    // vertex
                    // Ensures
                    graphMgt.setConsistency(index, ConsistencyModifier.LOCK);
                // name
                // uniqueness
                // in
                // the
                // graph
                } else {
                    graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex();
                }
            }
        }
    }
    graphMgt.commit();
    logger.info("** createVertexIndixes ended");
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) GraphPropertiesDictionary(org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) PropertyKey(org.janusgraph.core.PropertyKey)

Aggregations

PropertyKey (org.janusgraph.core.PropertyKey)4 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)4 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)4 GraphPropertiesDictionary (org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2