Skip to content

Commit e9b1b3f

Browse files
committed
Major refactoring - Let's call this Spring cleaning 2015.
1 parent 9aabf2b commit e9b1b3f

File tree

12 files changed

+166
-489
lines changed

12 files changed

+166
-489
lines changed

blueprints-neo4j2-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j2/Neo4j2EdgeIterable.java

Lines changed: 0 additions & 59 deletions
This file was deleted.

blueprints-neo4j2-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j2/Neo4j2Graph.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
import org.neo4j.graphdb.DynamicLabel;
1717
import org.neo4j.graphdb.DynamicRelationshipType;
1818
import org.neo4j.graphdb.GraphDatabaseService;
19-
import org.neo4j.graphdb.Label;
2019
import org.neo4j.graphdb.Node;
2120
import org.neo4j.graphdb.NotFoundException;
2221
import org.neo4j.graphdb.PropertyContainer;
2322
import org.neo4j.graphdb.Relationship;
24-
import org.neo4j.graphdb.ResourceIterable;
25-
import org.neo4j.graphdb.ResourceIterator;
2623
import org.neo4j.graphdb.Transaction;
2724
import org.neo4j.graphdb.TransactionFailureException;
2825
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
@@ -45,6 +42,10 @@
4542
import com.tinkerpop.blueprints.Parameter;
4643
import com.tinkerpop.blueprints.TransactionalGraph;
4744
import com.tinkerpop.blueprints.Vertex;
45+
import com.tinkerpop.blueprints.impls.neo4j2.index.Neo4j2EdgeIndex;
46+
import com.tinkerpop.blueprints.impls.neo4j2.index.Neo4j2VertexIndex;
47+
import com.tinkerpop.blueprints.impls.neo4j2.iterate.Neo4j2EdgeIterable;
48+
import com.tinkerpop.blueprints.impls.neo4j2.iterate.Neo4j2VertexIterable;
4849
import com.tinkerpop.blueprints.util.DefaultGraphQuery;
4950
import com.tinkerpop.blueprints.util.ExceptionFactory;
5051
import com.tinkerpop.blueprints.util.KeyIndexableGraphHelper;
@@ -262,28 +263,41 @@ private void logNotGraphDatabaseAPI() {
262263
" Current graph class is " + rawGraph.getClass().getName());
263264
}
264265
}
266+
267+
268+
/**
269+
* Helper method, here only to support the existing methods that pass that Class<T> as an argument.
270+
*/
271+
private <T extends Element> Index<T> _createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) {
272+
if (Vertex.class.isAssignableFrom(indexClass)) {
273+
return (Index<T>) new Neo4j2VertexIndex(indexName, this, indexParameters);
274+
} else {
275+
return (Index<T>) new Neo4j2EdgeIndex(indexName, this, indexParameters);
276+
}
277+
}
278+
265279

266280
public synchronized <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) {
267281
this.autoStartTransaction(true);
268282
if (this.rawGraph.index().existsForNodes(indexName) || this.rawGraph.index().existsForRelationships(indexName)) {
269283
throw ExceptionFactory.indexAlreadyExists(indexName);
270284
}
271-
return new Neo4j2Index(indexName, indexClass, this, indexParameters);
285+
return _createIndex(indexName, indexClass, indexParameters);
272286
}
273287

274288
public <T extends Element> Index<T> getIndex(final String indexName, final Class<T> indexClass) {
275289
this.autoStartTransaction(false);
276290
if (Vertex.class.isAssignableFrom(indexClass)) {
277291
if (this.rawGraph.index().existsForNodes(indexName)) {
278-
return new Neo4j2Index(indexName, indexClass, this);
292+
return _createIndex(indexName, indexClass);
279293
} else if (this.rawGraph.index().existsForRelationships(indexName)) {
280294
throw ExceptionFactory.indexDoesNotSupportClass(indexName, indexClass);
281295
} else {
282296
return null;
283297
}
284298
} else if (Edge.class.isAssignableFrom(indexClass)) {
285299
if (this.rawGraph.index().existsForRelationships(indexName)) {
286-
return new Neo4j2Index(indexName, indexClass, this);
300+
return _createIndex(indexName, indexClass);
287301
} else if (this.rawGraph.index().existsForNodes(indexName)) {
288302
throw ExceptionFactory.indexDoesNotSupportClass(indexName, indexClass);
289303
} else {
@@ -324,11 +338,11 @@ public Iterable<Index<? extends Element>> getIndices() {
324338
final List<Index<? extends Element>> indices = new ArrayList<Index<? extends Element>>();
325339
for (final String name : this.rawGraph.index().nodeIndexNames()) {
326340
if (!name.equals(Neo4j2Tokens.NODE_AUTO_INDEX))
327-
indices.add(new Neo4j2Index(name, Vertex.class, this));
341+
indices.add(new Neo4j2VertexIndex(name, this));
328342
}
329343
for (final String name : this.rawGraph.index().relationshipIndexNames()) {
330344
if (!name.equals(Neo4j2Tokens.RELATIONSHIP_AUTO_INDEX))
331-
indices.add(new Neo4j2Index(name, Edge.class, this));
345+
indices.add(new Neo4j2EdgeIndex(name, this));
332346
}
333347
return indices;
334348
}

blueprints-neo4j2-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j2/Neo4j2Index.java

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)