diff --git a/community/graphdb-api/src/main/java/org/neo4j/graphdb/GraphDatabaseService.java b/community/graphdb-api/src/main/java/org/neo4j/graphdb/GraphDatabaseService.java
index 44a970edc13fc..3b19f62fa087b 100644
--- a/community/graphdb-api/src/main/java/org/neo4j/graphdb/GraphDatabaseService.java
+++ b/community/graphdb-api/src/main/java/org/neo4j/graphdb/GraphDatabaseService.java
@@ -176,12 +176,9 @@ public interface GraphDatabaseService
/**
* Returns all relationship types currently in the underlying store.
* Relationship types are added to the underlying store the first time they
- * are used in a successfully commited {@link Node#createRelationshipTo
- * node.createRelationshipTo(...)}. Note that this method is guaranteed to
- * return all known relationship types, but it does not guarantee that it
- * won't return more than that (e.g. it can return "historic"
- * relationship types that no longer have any relationships in the node
- * space).
+ * are used in a successfully committed {@link Node#createRelationshipTo
+ * node.createRelationshipTo(...)}. This method guarantees that it will
+ * return all relationship types currently in use.
*
* @return all relationship types in the underlying store
*/
@@ -189,8 +186,7 @@ public interface GraphDatabaseService
/**
* Returns all labels currently in the underlying store. Labels are added to the store the first time
- * they are used. This method guarantees that it will return all labels currently in use. However,
- * it may also return more than that (e.g. it can return "historic" labels that are no longer used).
+ * they are used. This method guarantees that it will return all labels currently in use.
*
* Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
* inside your transaction to avoid potential blocking of write operations.
diff --git a/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java b/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java
index e4b752cb6ddfe..0b4f1fa2c3ded 100644
--- a/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java
+++ b/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java
@@ -86,7 +86,6 @@
import static org.neo4j.helpers.collection.Iterators.count;
import static org.neo4j.helpers.collection.MapUtil.store;
import static org.neo4j.helpers.collection.MapUtil.stringMap;
-import static org.neo4j.tooling.GlobalGraphOperations.at;
import static org.neo4j.tooling.ImportTool.MULTI_FILE_DELIMITER;
public class ImportToolTest
@@ -193,7 +192,7 @@ public void import4097Labels() throws Exception
// THEN
try ( Transaction tx = dbRule.beginTx() )
{
- long nodeCount = Iterables.count( at( dbRule ).getAllNodes() );
+ long nodeCount = Iterables.count( dbRule.getAllNodes() );
assertEquals( 4097, nodeCount );
tx.success();
@@ -371,7 +370,7 @@ public void shouldIgnoreWhitespaceAroundBooleans() throws Exception
}
}
- long nodeCount = Iterables.count( at( dbRule ).getAllNodes() );
+ long nodeCount = Iterables.count( dbRule.getAllNodes() );
assertEquals( 10, nodeCount );
tx.success();
}
@@ -1271,7 +1270,7 @@ public void shouldAcceptRawAsciiCharacterCodeAsQuoteConfiguration() throws Excep
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() )
{
- for ( Node node : at( db ).getAllNodes() )
+ for ( Node node : db.getAllNodes() )
{
String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
@@ -1370,7 +1369,7 @@ public void shouldAcceptRawEscapedAsciiCodeAsQuoteConfiguration() throws Excepti
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() )
{
- for ( Node node : at( db ).getAllNodes() )
+ for ( Node node : db.getAllNodes() )
{
String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
@@ -1428,7 +1427,7 @@ public void shouldBeEquivalentToUseRawAsciiOrCharacterAsQuoteConfiguration1() th
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() )
{
- for ( Node node : at( db ).getAllNodes() )
+ for ( Node node : db.getAllNodes() )
{
String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
@@ -1514,7 +1513,7 @@ public void shouldBeEquivalentToUseRawAsciiOrCharacterAsQuoteConfiguration2() th
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() )
{
- for ( Node node : at( db ).getAllNodes() )
+ for ( Node node : db.getAllNodes() )
{
String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java
index 679aa5e53427f..ab475a9e32b34 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java
@@ -394,17 +394,41 @@ protected Relationship fetchNextOrNull()
@Override
public ResourceIterable getAllRelationshipTypes()
{
- return all( TokenAccess.RELATIONSHIP_TYPES );
+ return allInUse( TokenAccess.RELATIONSHIP_TYPES );
}
@Override
public ResourceIterable getAllLabels()
{
- return all( TokenAccess.LABELS );
+ return allInUse( TokenAccess.LABELS );
}
@Override
public ResourceIterable getAllPropertyKeys()
+ {
+ return allInUse( TokenAccess.PROPERTY_KEYS );
+ }
+
+ private ResourceIterable allInUse( final TokenAccess tokens )
+ {
+ assertTransactionOpen();
+ return () -> tokens.inUse( spi.currentStatement() );
+ }
+
+ @Override
+ public ResourceIterable getAllExistingRelationshipTypes()
+ {
+ return all( TokenAccess.RELATIONSHIP_TYPES );
+ }
+
+ @Override
+ public ResourceIterable getAllExistingLabelsInUseAndNot()
+ {
+ return all( TokenAccess.LABELS );
+ }
+
+ @Override
+ public ResourceIterable getAllExistingPropertyKeysInUseAndNot()
{
return all( TokenAccess.PROPERTY_KEYS );
}
@@ -412,7 +436,7 @@ public ResourceIterable getAllPropertyKeys()
private ResourceIterable all( final TokenAccess tokens )
{
assertTransactionOpen();
- return () -> tokens.inUse( spi.currentStatement() );
+ return () -> tokens.all( spi.currentStatement() );
}
@Override
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java b/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java
index 3dda0f100a99e..5674f4ffe20d8 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java
@@ -23,6 +23,10 @@
import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.GraphDatabaseService;
+import org.neo4j.graphdb.Label;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.RelationshipType;
+import org.neo4j.graphdb.ResourceIterable;
import org.neo4j.graphdb.security.URLAccessValidationError;
import org.neo4j.kernel.impl.store.StoreId;
@@ -49,4 +53,42 @@ public interface GraphDatabaseAPI extends GraphDatabaseService
URL validateURLAccess( URL url ) throws URLAccessValidationError;
String getStoreDir();
+
+ /**
+ * Returns all relationship types currently in the underlying store.
+ * Relationship types are added to the underlying store the first time they
+ * are used in a successfully committed {@link Node#createRelationshipTo
+ * node.createRelationshipTo(...)}. Note that this method is guaranteed to
+ * return all known relationship types, but it does not guarantee that it
+ * won't return more than that (e.g. it can return "historic"
+ * relationship types that no longer have any relationships in the node
+ * space).
+ *
+ * @return all relationship types in the underlying store
+ */
+ ResourceIterable getAllExistingRelationshipTypes();
+
+ /**
+ * Returns all labels currently in the underlying store. Labels are added to the store the first time
+ * they are used. This method guarantees that it will return all labels currently in use. However,
+ * it may also return more than that (e.g. it can return "historic" labels that are no longer used).
+ *
+ * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
+ * inside your transaction to avoid potential blocking of write operations.
+ *
+ * @return all labels in the underlying store.
+ */
+ ResourceIterable getAllExistingLabelsInUseAndNot();
+
+ /**
+ * Returns all property keys currently in the underlying store. This method guarantees that it will return all
+ * property keys currently in use. However, it may also return more than that (e.g. it can return "historic"
+ * labels that are no longer used).
+ *
+ * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
+ * inside your transaction to avoid potential blocking of write operations.
+ *
+ * @return all property keys in the underlying store.
+ */
+ ResourceIterable getAllExistingPropertyKeysInUseAndNot();
}
diff --git a/community/kernel/src/main/java/org/neo4j/tooling/GlobalGraphOperations.java b/community/kernel/src/main/java/org/neo4j/tooling/GlobalGraphOperations.java
deleted file mode 100644
index 9018360c24980..0000000000000
--- a/community/kernel/src/main/java/org/neo4j/tooling/GlobalGraphOperations.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2002-2016 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.tooling;
-
-import org.neo4j.graphdb.DependencyResolver;
-import org.neo4j.graphdb.GraphDatabaseService;
-import org.neo4j.graphdb.Label;
-import org.neo4j.graphdb.Node;
-import org.neo4j.graphdb.Relationship;
-import org.neo4j.graphdb.RelationshipType;
-import org.neo4j.graphdb.ResourceIterable;
-import org.neo4j.kernel.internal.GraphDatabaseAPI;
-import org.neo4j.kernel.impl.api.TokenAccess;
-import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge;
-
-/**
- * A tool for doing global operations, for example {@link #getAllNodes()}.
- * @deprecated use methods on {@link GraphDatabaseService} instead
- */
-@Deprecated
-public class GlobalGraphOperations
-{
- private final ThreadToStatementContextBridge statementCtxSupplier;
- private final GraphDatabaseService db;
-
- private GlobalGraphOperations( GraphDatabaseService db )
- {
- this.db = db;
- GraphDatabaseAPI dbApi = (GraphDatabaseAPI) db;
- DependencyResolver resolver = dbApi.getDependencyResolver();
- this.statementCtxSupplier = resolver.resolveDependency( ThreadToStatementContextBridge.class );
- }
-
- /**
- * Get a {@link GlobalGraphOperations} for the given {@code db}.
- *
- * @param db the {@link GraphDatabaseService} to get global operations for.
- * @return {@link GlobalGraphOperations} for the given {@code db}.
- */
- public static GlobalGraphOperations at( GraphDatabaseService db )
- {
- return new GlobalGraphOperations( db );
- }
-
- /**
- * Returns all nodes in the graph.
- *
- * @return all nodes in the graph.
- * @deprecated use {@link GraphDatabaseService#getAllNodes()} instead
- */
- @Deprecated
- public ResourceIterable getAllNodes()
- {
- return db.getAllNodes();
- }
-
- /**
- * Returns all relationships in the graph.
- *
- * @return all relationships in the graph.
- * @deprecated use {@link GraphDatabaseService#getAllRelationships()} instead
- */
- @Deprecated
- public Iterable getAllRelationships()
- {
- return db.getAllRelationships();
- }
-
- /**
- * Returns all relationship types currently in the underlying store. Relationship types are
- * added to the underlying store the first time they are used in a successfully committed
- * {@link Node#createRelationshipTo node.createRelationshipTo(...)}. Note that this method is
- * guaranteed to return all known relationship types, but it does not guarantee that it won't
- * return more than that (e.g. it can return "historic" relationship types that no longer
- * have any relationships in the graph).
- *
- * @return all relationship types in the underlying store
- * @deprecated use {@link GraphDatabaseService#getAllRelationshipTypes()} instead
- */
- @Deprecated
- public Iterable getAllRelationshipTypes()
- {
- return all( TokenAccess.RELATIONSHIP_TYPES );
- }
-
- /**
- * Returns all relationship types currently in use in the underlying store. Relationship types are
- * added to the underlying store the first time they are used in a successfully committed
- * {@link Node#createRelationshipTo node.createRelationshipTo(...)}. Note that this method is
- * guaranteed to return all known relationship types, and it guarantees that it won't return
- * "historic" relationship types that no longer have any relationships in the graph.
- *
- * @return all relationship types in use in the underlying store
- * @deprecated use {@link GraphDatabaseService#getAllRelationshipTypes()} instead
- */
- @Deprecated
- public Iterable getAllRelationshipTypesInUse()
- {
- return db.getAllRelationshipTypes();
- }
-
- /**
- * Returns all labels currently in the underlying store. Labels are added to the store the first time
- * they are used. This method guarantees that it will return all labels currently in use. However,
- * it may also return more than that (e.g. it can return "historic" labels that are no longer used).
- *
- * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
- * inside your transaction to avoid potential blocking of write operations.
- *
- * @return all labels in the underlying store.
- * @deprecated use {@link GraphDatabaseService#getAllLabels()} instead
- */
- @Deprecated
- public ResourceIterable getAllLabels()
- {
- return all( TokenAccess.LABELS );
- }
-
- /**
- * Returns all labels currently in use in the underlying store. Labels are added to the store the first time
- * they are used. This method guarantees that it will return all labels currently in use by filtering out
- * "historic" labels that are no longer used.
- *
- * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
- * inside your transaction to avoid potential blocking of write operations.
- *
- * @return all labels in use in the underlying store.
- * @deprecated use {@link GraphDatabaseService#getAllLabels()} instead
- */
- @Deprecated
- public ResourceIterable getAllLabelsInUse()
- {
- return db.getAllLabels();
- }
-
- /**
- * Returns all property keys currently in the underlying store. This method guarantees that it will return all
- * property keys currently in use. However, it may also return more than that (e.g. it can return "historic"
- * labels that are no longer used).
- *
- * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
- * inside your transaction to avoid potential blocking of write operations.
- *
- * @return all property keys in the underlying store.
- * @deprecated use {@link GraphDatabaseService#getAllPropertyKeys()} instead
- */
- @Deprecated
- public ResourceIterable getAllPropertyKeys()
- {
- return all( TokenAccess.PROPERTY_KEYS );
- }
-
- /**
- * Returns all {@link Node nodes} with a specific {@link Label label}.
- *
- * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
- * inside your transaction to avoid potential blocking of write operations.
- *
- * @param label the {@link Label} to return nodes for.
- * @return {@link Iterable} containing nodes with a specific label.
- * @deprecated Use {@link GraphDatabaseService#findNodes(Label)} instead
- */
- @Deprecated
- public ResourceIterable getAllNodesWithLabel( final Label label )
- {
- statementCtxSupplier.assertInUnterminatedTransaction();
- return () -> db.findNodes( label );
- }
-
- private ResourceIterable all( final TokenAccess tokens )
- {
- statementCtxSupplier.assertInUnterminatedTransaction();
- return () -> tokens.all( statementCtxSupplier.get() );
- }
-}
diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/GlobalGraphOperationsFacadeMethods.java b/community/kernel/src/test/java/org/neo4j/graphdb/GlobalGraphOperationsFacadeMethods.java
deleted file mode 100644
index 46b66972f577c..0000000000000
--- a/community/kernel/src/test/java/org/neo4j/graphdb/GlobalGraphOperationsFacadeMethods.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2002-2016 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.graphdb;
-
-import org.neo4j.tooling.GlobalGraphOperations;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.unmodifiableCollection;
-
-public class GlobalGraphOperationsFacadeMethods
-{
- private static final FacadeMethod GET_ALL_NODES =
- new FacadeMethod( "Iterable getAllNodes()" )
- {
- @Override
- public void call( GlobalGraphOperations self )
- {
- self.getAllNodes();
- }
- };
-
- private static final FacadeMethod GET_ALL_RELATIONSHIPS =
- new FacadeMethod( "Iterable getAllRelationships()" )
- {
- @Override
- public void call( GlobalGraphOperations self )
- {
- self.getAllRelationships();
- }
- };
-
- private static final FacadeMethod GET_ALL_RELATIONSHIP_TYPES =
- new FacadeMethod( "Iterable getAllRelationshipTypes()" )
- {
- @Override
- public void call( GlobalGraphOperations self )
- {
- self.getAllRelationshipTypes();
- }
- };
-
- private static final FacadeMethod GET_ALL_LABELS =
- new FacadeMethod( "ResourceIterable getAllLabels()" )
- {
- @Override
- public void call( GlobalGraphOperations self )
- {
- self.getAllLabels();
- }
- };
-
- private static final FacadeMethod GET_ALL_NODES_WITH_LABEL =
- new FacadeMethod( "ResourceIterable getAllNodesWithLabel( Label label )" )
- {
- @Override
- public void call( GlobalGraphOperations self )
- {
- self.getAllNodesWithLabel( Label.label( "Label" ) );
- }
- };
-
- static final Iterable> ALL_GLOBAL_GRAPH_OPERATIONS_FACADE_METHODS =
- unmodifiableCollection( asList(
- GET_ALL_NODES,
- GET_ALL_RELATIONSHIPS,
- GET_ALL_RELATIONSHIP_TYPES,
- GET_ALL_LABELS,
- GET_ALL_NODES_WITH_LABEL
- ) );
-}
-
diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGlobalGraphOperations.java b/community/kernel/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGlobalGraphOperations.java
deleted file mode 100644
index 2b6c8da7be5be..0000000000000
--- a/community/kernel/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGlobalGraphOperations.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2002-2016 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.graphdb;
-
-import org.junit.Test;
-
-import org.neo4j.tooling.GlobalGraphOperations;
-
-import static org.neo4j.graphdb.GlobalGraphOperationsFacadeMethods.ALL_GLOBAL_GRAPH_OPERATIONS_FACADE_METHODS;
-
-public class MandatoryTransactionsForGlobalGraphOperations
- extends AbstractMandatoryTransactionsTest
-{
- @Test
- public void shouldRequireTransactionsWhenCallingGlobalGraphOperations() throws Exception
- {
- assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_GLOBAL_GRAPH_OPERATIONS_FACADE_METHODS );
- }
-
- @Test
- public void shouldTerminateWhenCallingGlobalGraphOperations() throws Exception
- {
- assertFacadeMethodsThrowAfterTerminate( ALL_GLOBAL_GRAPH_OPERATIONS_FACADE_METHODS );
- }
-
- @Override
- protected GlobalGraphOperations obtainEntityInTransaction( GraphDatabaseService graphDatabaseService )
- {
- return GlobalGraphOperations.at( graphDatabaseService );
- }
-}
diff --git a/community/kernel/src/test/java/org/neo4j/test/DatabaseRule.java b/community/kernel/src/test/java/org/neo4j/test/DatabaseRule.java
index d92722a7f6c89..3dd4f2032ef84 100644
--- a/community/kernel/src/test/java/org/neo4j/test/DatabaseRule.java
+++ b/community/kernel/src/test/java/org/neo4j/test/DatabaseRule.java
@@ -383,6 +383,25 @@ public ResourceIterable getAllPropertyKeys()
return database.getAllPropertyKeys();
}
+
+ @Override
+ public ResourceIterable getAllExistingRelationshipTypes()
+ {
+ return database.getAllExistingRelationshipTypes();
+ }
+
+ @Override
+ public ResourceIterable getAllExistingLabelsInUseAndNot()
+ {
+ return database.getAllExistingLabelsInUseAndNot();
+ }
+
+ @Override
+ public ResourceIterable getAllExistingPropertyKeysInUseAndNot()
+ {
+ return database.getAllExistingPropertyKeysInUseAndNot();
+ }
+
@Override
public ResourceIterator findNodes( Label label, String key, Object value )
{
diff --git a/community/kernel/src/test/java/org/neo4j/tooling/GlobalGraphOperationsIT.java b/community/kernel/src/test/java/org/neo4j/tooling/GlobalGraphOperationsIT.java
deleted file mode 100644
index 30fa6f18d514f..0000000000000
--- a/community/kernel/src/test/java/org/neo4j/tooling/GlobalGraphOperationsIT.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2002-2016 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.tooling;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.util.Collections;
-
-import org.neo4j.graphdb.GraphDatabaseService;
-import org.neo4j.graphdb.Label;
-import org.neo4j.graphdb.Node;
-import org.neo4j.graphdb.RelationshipType;
-import org.neo4j.graphdb.Transaction;
-import org.neo4j.helpers.collection.Iterators;
-import org.neo4j.test.ImpermanentDatabaseRule;
-
-import static java.util.Arrays.asList;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.neo4j.helpers.collection.Iterables.asList;
-import static org.neo4j.helpers.collection.Iterables.asSet;
-import static org.neo4j.helpers.collection.Iterables.map;
-
-public class GlobalGraphOperationsIT
-{
-
- @Rule public ImpermanentDatabaseRule dbRule = new ImpermanentDatabaseRule();
-
- @Test
- public void shouldListAllPropertyKeys() throws Exception
- {
- // Given
- GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
- try( Transaction tx = db.beginTx() )
- {
- db.createNode().setProperty( "myProperty", 12);
- tx.success();
- }
-
- // When
- try( Transaction tx = db.beginTx() )
- {
- assertThat( asList( db.getAllPropertyKeys() ), equalTo( asList( "myProperty" ) ) );
- }
- }
-
- @Test
- public void shouldReturnAllLabels()
- {
- // Given
- GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
- Label dead = Label.label( "dead" );
- Label alive = Label.label( "alive" );
- try( Transaction tx = db.beginTx() )
- {
- db.createNode( alive );
- db.createNode( dead );
- tx.success();
- }
-
- try( Transaction tx = db.beginTx() )
- {
- Node node = Iterators.single( db.findNodes( dead ) );
- node.delete();
- tx.success();
- }
-
- // When - Then
- try( Transaction ignored = db.beginTx() )
- {
- assertThat(
- asSet( GlobalGraphOperations.at( db ).getAllLabels() ),
- equalTo( asSet( asList( alive, dead ) ) ) );
- }
- }
-
- @Test
- public void shouldReturnAllInUseLabels()
- {
- // Given
- GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
- Label dead = Label.label( "dead" );
- Label alive = Label.label( "alive" );
- try( Transaction tx = db.beginTx() )
- {
- db.createNode( alive );
- db.createNode( dead );
- tx.success();
- }
-
- try( Transaction tx = db.beginTx() )
- {
- Node node = Iterators.single( db.findNodes( dead ) );
- node.delete();
- tx.success();
- }
-
- // When - Then
- try( Transaction ignored = db.beginTx() )
- {
- assertThat( asSet( db.getAllLabels() ), equalTo( Collections.singleton( alive ) ) );
- }
- }
-
- @Test
- public void shouldReturnAllRelationshipTypes()
- {
- // Given
- GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
- RelationshipType dead = RelationshipType.withName( "DEAD" );
- RelationshipType alive = RelationshipType.withName( "ALIVE" );
- long deadId;
- try( Transaction tx = db.beginTx() )
- {
- db.createNode().createRelationshipTo( db.createNode(), alive );
- deadId = db.createNode().createRelationshipTo( db.createNode(), dead ).getId();
- tx.success();
- }
-
- try( Transaction tx = db.beginTx() )
- {
- db.getRelationshipById( deadId ).delete();
- tx.success();
- }
-
- // When - Then
- try( Transaction ignored = db.beginTx() )
- {
- Iterable result = map( RelationshipType::name, GlobalGraphOperations.at( db ).getAllRelationshipTypes() );
- assertThat( asSet( result ), equalTo( asSet( asList( alive.name(), dead.name() ) ) ) );
- }
- }
-
- @Test
- public void shouldReturnAllInUseRelationshipTypes()
- {
- // Given
- GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
- RelationshipType dead = RelationshipType.withName( "DEAD" );
- RelationshipType alive = RelationshipType.withName( "ALIVE" );
- long deadId;
- try( Transaction tx = db.beginTx() )
- {
- db.createNode().createRelationshipTo( db.createNode(), alive );
- deadId = db.createNode().createRelationshipTo( db.createNode(), dead ).getId();
- tx.success();
- }
-
- try( Transaction tx = db.beginTx() )
- {
- db.getRelationshipById( deadId ).delete();
- tx.success();
- }
-
- // When - Then
- try( Transaction ignored = db.beginTx() )
- {
- Iterable result = map( RelationshipType::name, db.getAllRelationshipTypes() );
- assertThat( asSet( result ) , equalTo( Collections.singleton( alive.name() ) ) );
- }
- }
-}
diff --git a/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseActions.java b/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseActions.java
index 24ea1f671ce64..15dca7102ea1c 100644
--- a/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseActions.java
+++ b/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseActions.java
@@ -102,7 +102,7 @@
import org.neo4j.server.rest.repr.ScoredRelationshipRepresentation;
import org.neo4j.server.rest.repr.ValueRepresentation;
import org.neo4j.server.rest.repr.WeightedPathRepresentation;
-import org.neo4j.tooling.GlobalGraphOperations;
+
import static org.neo4j.graphdb.Label.label;
import static org.neo4j.helpers.collection.Iterables.filter;
@@ -1437,7 +1437,7 @@ protected NodeRepresentation underlyingObjectToObject( Node node )
public ListRepresentation getAllLabels( boolean inUse )
{
- ResourceIterable labels = inUse ? graphDb.getAllLabels() : GlobalGraphOperations.at( graphDb ).getAllLabels();
+ ResourceIterable labels = inUse ? graphDb.getAllLabels() : graphDb.getAllExistingLabelsInUseAndNot();
Collection labelNames = Iterables.asSet( map( new Function()
{
@Override
diff --git a/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseMetadataService.java b/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseMetadataService.java
index b9a6227fc5b04..93483251a121c 100644
--- a/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseMetadataService.java
+++ b/community/server/src/main/java/org/neo4j/server/rest/web/DatabaseMetadataService.java
@@ -28,11 +28,10 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.RelationshipType;
+import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.server.database.Database;
import org.neo4j.server.rest.repr.RepresentationWriteHandler;
-import org.neo4j.tooling.GlobalGraphOperations;
@Path( "/relationship/types" )
public class DatabaseMetadataService
@@ -51,10 +50,10 @@ public Response getRelationshipTypes( @QueryParam( "in_use" ) @DefaultValue( "tr
{
try
{
- GraphDatabaseService db = database.getGraph();
+ GraphDatabaseAPI db = database.getGraph();
Iterable relationshipTypes = inUse
? db.getAllRelationshipTypes()
- : GlobalGraphOperations.at( db ).getAllRelationshipTypes();
+ : db.getAllExistingRelationshipTypes();
return Response.ok()
.type( MediaType.APPLICATION_JSON )
.entity( generateJsonRepresentation( relationshipTypes ) )
diff --git a/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java b/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java
index 300ecc5577115..9235028f8c349 100644
--- a/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java
+++ b/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java
@@ -146,11 +146,6 @@ public Relationship getRelationshipById( long id )
return new ReadOnlyRelationshipProxy( actual.getRelationshipById( id ) );
}
- @Override
- public ResourceIterable getAllRelationshipTypes()
- {
- return actual.getAllRelationshipTypes();
- }
@Override
public ResourceIterable getAllRelationships()
@@ -179,6 +174,13 @@ public void close()
};
}
+
+ @Override
+ public ResourceIterable getAllRelationshipTypes()
+ {
+ return actual.getAllRelationshipTypes();
+ }
+
@Override
public ResourceIterable getAllLabels()
{
@@ -191,6 +193,24 @@ public ResourceIterable getAllPropertyKeys()
return actual.getAllPropertyKeys();
}
+ @Override
+ public ResourceIterable getAllExistingRelationshipTypes()
+ {
+ return actual.getAllExistingRelationshipTypes();
+ }
+
+ @Override
+ public ResourceIterable getAllExistingLabelsInUseAndNot()
+ {
+ return actual.getAllExistingLabelsInUseAndNot();
+ }
+
+ @Override
+ public ResourceIterable getAllExistingPropertyKeysInUseAndNot()
+ {
+ return actual.getAllExistingPropertyKeysInUseAndNot();
+ }
+
@Override
public KernelEventHandler registerKernelEventHandler( KernelEventHandler handler )
{
diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/ClusterTransactionIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/ClusterTransactionIT.java
index 7948a5fc6e414..9bba592d4ed77 100644
--- a/enterprise/ha/src/test/java/org/neo4j/ha/ClusterTransactionIT.java
+++ b/enterprise/ha/src/test/java/org/neo4j/ha/ClusterTransactionIT.java
@@ -36,7 +36,6 @@
import org.neo4j.kernel.lifecycle.LifecycleListener;
import org.neo4j.kernel.lifecycle.LifecycleStatus;
import org.neo4j.test.ha.ClusterRule;
-import org.neo4j.tooling.GlobalGraphOperations;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -157,8 +156,7 @@ public void slaveMustConnectLockManagerToNewMasterAfterTwoOtherClusterMembersRol
HighlyAvailableGraphDatabase master = cluster.getMaster();
try ( Transaction tx = master.beginTx() )
{
- GlobalGraphOperations gops = GlobalGraphOperations.at( master );
- assertThat( Iterables.count( gops.getAllNodes() ), is( 3L ) );
+ assertThat( Iterables.count( master.getAllNodes() ), is( 3L ) );
}
}
}
diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java
index e311911d6f4f8..99871985b3395 100644
--- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java
+++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/HaCountsIT.java
@@ -42,7 +42,6 @@
import static org.junit.Assert.assertTrue;
import static org.neo4j.register.Registers.newDoubleLongRegister;
-import static org.neo4j.tooling.GlobalGraphOperations.at;
public class HaCountsIT
{
@@ -81,7 +80,7 @@ private void clearDatabase() throws InterruptedException
try ( Transaction tx = master.beginTx() )
{
- for ( Node node : at( master ).getAllNodes() )
+ for ( Node node : master.getAllNodes() )
{
for ( Relationship relationship : node.getRelationships() )
{
diff --git a/manual/server-examples/src/main/java/org/neo4j/examples/server/plugins/GetAll.java b/manual/server-examples/src/main/java/org/neo4j/examples/server/plugins/GetAll.java
index a7af8d3d8fe97..8114305865d52 100644
--- a/manual/server-examples/src/main/java/org/neo4j/examples/server/plugins/GetAll.java
+++ b/manual/server-examples/src/main/java/org/neo4j/examples/server/plugins/GetAll.java
@@ -30,7 +30,6 @@
import org.neo4j.server.plugins.PluginTarget;
import org.neo4j.server.plugins.ServerPlugin;
import org.neo4j.server.plugins.Source;
-import org.neo4j.tooling.GlobalGraphOperations;
// START SNIPPET: GetAll
@Description( "An extension to the Neo4j Server for getting all nodes or relationships" )