You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/06/03 02:12:26 UTC

[21/50] [abbrv] incubator-tinkerpop git commit: Neo4j multi-meta settings are now part of Neo4jGraphVariables as hiddens. Its important that once set, a user can not change these as the underlying topology would differ.

Neo4j multi-meta settings are now part of Neo4jGraphVariables as hiddens. Its important that once set, a user can not change these as the underlying topology would differ.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/bbc6a0ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/bbc6a0ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/bbc6a0ed

Branch: refs/heads/preprocessor
Commit: bbc6a0ed6eafe72e895f8d18c0a7c8ec07d8680d
Parents: 2b3a682
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri May 29 13:25:55 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri May 29 13:25:55 2015 -0600

----------------------------------------------------------------------
 .../gremlin/neo4j/structure/Neo4jGraph.java     | 34 ++++++++++++--------
 1 file changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bbc6a0ed/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
index 34a527f..a289bb9 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
@@ -50,6 +50,7 @@ import org.neo4j.tinkerpop.api.Neo4jTx;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Optional;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
@@ -95,15 +96,20 @@ public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
     private void initialize(final Neo4jGraphAPI baseGraph, final Configuration configuration) {
         this.configuration.copy(configuration);
         this.baseGraph = baseGraph;
-        boolean supportsMetaProperties = this.configuration.getBoolean(CONFIG_META_PROPERTIES, false);
-        boolean supportsMultiProperties = this.configuration.getBoolean(CONFIG_MULTI_PROPERTIES, false);
+        this.neo4jGraphVariables = new Neo4jGraphVariables(this);
+        this.tx().readWrite();
+        final Optional<Boolean> hasMultiProperties = this.neo4jGraphVariables.get(Graph.Hidden.hide(CONFIG_MULTI_PROPERTIES));
+        final Optional<Boolean> hasMetaProperties = this.neo4jGraphVariables.get(Graph.Hidden.hide(CONFIG_META_PROPERTIES));
+        boolean supportsMetaProperties = hasMetaProperties.orElse(this.configuration.getBoolean(CONFIG_META_PROPERTIES, false));
+        boolean supportsMultiProperties = hasMultiProperties.orElse(this.configuration.getBoolean(CONFIG_MULTI_PROPERTIES, false));
         if (supportsMultiProperties != supportsMetaProperties)
             throw new IllegalArgumentException(this.getClass().getSimpleName() + " currently supports either both meta-properties and multi-properties or neither");
-        this.neo4jGraphVariables = new Neo4jGraphVariables(this);
-        if (supportsMultiProperties)
-            this.trait = new MultiMetaNeo4jTrait();
-        else
-            this.trait = new NoMultiNoMetaNeo4jTrait();
+        if (!hasMultiProperties.isPresent())
+            this.neo4jGraphVariables.set(Graph.Hidden.hide(CONFIG_MULTI_PROPERTIES), supportsMultiProperties);
+        if (!hasMetaProperties.isPresent())
+            this.neo4jGraphVariables.set(Graph.Hidden.hide(CONFIG_META_PROPERTIES), supportsMetaProperties);
+        this.trait = supportsMultiProperties ? new MultiMetaNeo4jTrait() : new NoMultiNoMetaNeo4jTrait();
+        this.tx().commit();
     }
 
     protected Neo4jGraph(final Neo4jGraphAPI baseGraph, final Configuration configuration) {
@@ -140,6 +146,13 @@ public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
         return open(config);
     }
 
+    /**
+     * Construct a Neo4jGraph instance using an existing Neo4j raw instance.
+     */
+    public static Neo4jGraph open(final Neo4jGraphAPI baseGraph) {
+        return new Neo4jGraph(baseGraph, EMPTY_CONFIGURATION);
+    }
+
     @Override
     public Vertex addVertex(final Object... keyValues) {
         ElementHelper.legalPropertyKeyValueArray(keyValues);
@@ -217,13 +230,6 @@ public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
         }
     }
 
-
-    /**
-     * Construct a Neo4jGraph instance using an existing Neo4j raw instance.
-     */
-    /*public static Neo4jGraph open(final Neo4jGraphAPI baseGraph) {
-        return new Neo4jGraph(Optional.ofNullable(baseGraph).orElseThrow(() -> Graph.Exceptions.argumentCanNotBeNull("baseGraph")));
-    }*/
     @Override
     public <C extends GraphComputer> C compute(final Class<C> graphComputerClass) {
         throw Graph.Exceptions.graphComputerNotSupported();