Skip to content

Commit 4124d8b

Browse files
authored
Upgrade to neo4j 5.13 + update dependencies (#394)
* Update to neo4j 5.13 * Update and cleanup dependencies + resolve dependency conflicts * adjust version * wrap usages of `ResourceIterable` in try with resources
1 parent a727340 commit 4124d8b

File tree

66 files changed

+1052
-983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1052
-983
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Over the years there have been various efforts to make the library more appropri
3030
* 0.25: Addition of GeoHash indexes for point layers
3131
* 0.26: Support for native Neo4j point types
3232
* 0.27: Major port to Neo4j 4.x which deprecated many of the Neo4j API's the library depended on
33+
* 0.29: Port to Neo4j 5.13
3334

3435
However, despite all these improvements, the core of the library only exposes the rich capabilities of JTS and GeoTools
3536
if used in an embedded environment.
@@ -359,7 +360,7 @@ The Neo4j Spatial Plugin is available for inclusion in the server version of Neo
359360
* [v0.27.2 for Neo4j 4.2.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.27.2-neo4j-4.2.3/neo4j-spatial-0.27.2-neo4j-4.2.3-server-plugin.jar?raw=true)
360361
* [v0.28.0 for Neo4j 4.2.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.28.0-neo4j-4.2.3/neo4j-spatial-0.28.0-neo4j-4.2.3-server-plugin.jar?raw=true)
361362
* [v0.28.1 for Neo4j 4.3.10](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.28.1-neo4j-4.3.10/neo4j-spatial-0.28.1-neo4j-4.3.10-server-plugin.jar?raw=true)
362-
* [v0.28.1 for Neo4j 4.4.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.28.1-neo4j-4.4.3/neo4j-spatial-0.28.1-neo4j-4.4.3-server-plugin.jar?raw=true)
363+
* [v0.28.1 for Neo4j 4.4.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.30.0-neo4j-5.13.0/neo4j-spatial-0.30.0-neo4j-5.13.0-server-plugin.jar?raw=true)
363364

364365
For versions up to 0.15-neo4j-2.3.4:
365366

@@ -476,7 +477,7 @@ Add the following repositories and dependency to your project's pom.xml:
476477
<dependency>
477478
<groupId>org.neo4j</groupId>
478479
<artifactId>neo4j-spatial</artifactId>
479-
<version>0.28.1-neo4j-4.4.3</version>
480+
<version>0.30.0-neo4j-5.13.0</version>
480481
</dependency>
481482
~~~
482483

pom.xml

Lines changed: 148 additions & 198 deletions
Large diffs are not rendered by default.

src/main/java/org/geotools/data/neo4j/DefaultResourceInfo.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,17 @@
2323
import java.util.HashSet;
2424
import java.util.Set;
2525

26-
import org.apache.log4j.Logger;
27-
import org.geotools.data.ResourceInfo;
26+
import org.geotools.api.data.ResourceInfo;
2827
import org.geotools.feature.FeatureTypes;
2928
import org.geotools.geometry.jts.ReferencedEnvelope;
30-
import org.opengis.referencing.crs.CoordinateReferenceSystem;
29+
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
3130

3231
/**
3332
* ResourceInfo implementation.
34-
*
33+
*
3534
* @author Davide Savazzi, Andreas Wilhelm
3635
*/
3736
public class DefaultResourceInfo implements ResourceInfo {
38-
39-
private static final Logger LOG = Logger.getLogger(DefaultResourceInfo.class.getName());
4037

4138
private String name;
4239
private String description = "";
@@ -45,7 +42,7 @@ public class DefaultResourceInfo implements ResourceInfo {
4542
private ReferencedEnvelope bbox;
4643

4744
/**
48-
*
45+
*
4946
* @param name
5047
* @param crs
5148
* @param bbox
@@ -55,48 +52,48 @@ public DefaultResourceInfo(String name, CoordinateReferenceSystem crs, Reference
5552
this.crs = crs;
5653
this.bbox = bbox;
5754
}
58-
55+
5956
/**
60-
*
57+
*
6158
*/
6259
public String getName() {
6360
return name;
6461
}
6562
/**
66-
*
63+
*
6764
*/
6865
public String getTitle() {
6966
return name;
70-
}
67+
}
7168
/**
72-
*
69+
*
7370
*/
7471
public String getDescription() {
7572
return description;
7673
}
7774
/**
78-
*
75+
*
7976
*/
8077
public Set<String> getKeywords() {
8178
return keywords;
8279
}
8380
/**
84-
*
81+
*
8582
*/
8683
public URI getSchema() {
8784
return FeatureTypes.DEFAULT_NAMESPACE;
8885
}
8986
/**
90-
*
87+
*
9188
*/
9289
public CoordinateReferenceSystem getCRS() {
9390
return crs;
94-
}
91+
}
9592
/**
96-
*
93+
*
9794
*/
9895
public ReferencedEnvelope getBounds() {
9996
return bbox;
10097
}
10198

102-
}
99+
}

src/main/java/org/geotools/data/neo4j/Neo4jFeatureBuilder.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
import org.neo4j.gis.spatial.SpatialDatabaseService;
3636
import org.neo4j.gis.spatial.SpatialRecord;
3737
import org.neo4j.graphdb.Transaction;
38-
import org.opengis.feature.simple.SimpleFeature;
39-
import org.opengis.feature.simple.SimpleFeatureType;
40-
import org.opengis.feature.type.AttributeDescriptor;
41-
import org.opengis.feature.type.GeometryDescriptor;
42-
import org.opengis.feature.type.GeometryType;
43-
import org.opengis.referencing.crs.CoordinateReferenceSystem;
38+
import org.geotools.api.feature.simple.SimpleFeature;
39+
import org.geotools.api.feature.simple.SimpleFeatureType;
40+
import org.geotools.api.feature.type.AttributeDescriptor;
41+
import org.geotools.api.feature.type.GeometryDescriptor;
42+
import org.geotools.api.feature.type.GeometryType;
43+
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
4444

4545
import org.locationtech.jts.geom.Geometry;
4646
import org.locationtech.jts.geom.LineString;
@@ -52,26 +52,26 @@
5252
import org.locationtech.jts.geom.Polygon;
5353

5454
public class Neo4jFeatureBuilder {
55-
55+
5656
private static final String FEATURE_PROP_GEOM = "the_geom";
5757
private final SimpleFeatureBuilder builder;
5858
private final List<String> extraPropertyNames;
59-
59+
6060
/**
61-
*
61+
*
6262
*/
6363
public Neo4jFeatureBuilder(SimpleFeatureType sft, List<String> extraPropertyNames) {
6464
this.builder = new SimpleFeatureBuilder(sft);
6565
this.extraPropertyNames = extraPropertyNames;
6666
}
67-
67+
6868
/**
6969
* If it is necessary to lookup the layer type with a transaction, use this factory method to make the feature builder
7070
*/
7171
public static Neo4jFeatureBuilder fromLayer(Transaction tx, Layer layer) {
7272
return new Neo4jFeatureBuilder(getTypeFromLayer(tx, layer), Arrays.asList(layer.getExtraPropertyNames(tx)));
73-
}
74-
73+
}
74+
7575
public SimpleFeature buildFeature(String id, Geometry geometry, Map<String,Object> properties) {
7676
builder.reset();
7777
builder.set(FEATURE_PROP_GEOM, geometry);
@@ -81,17 +81,17 @@ public SimpleFeature buildFeature(String id, Geometry geometry, Map<String,Objec
8181
}
8282
}
8383

84-
return builder.buildFeature(id);
84+
return builder.buildFeature(id);
8585
}
86-
86+
8787
public SimpleFeature buildFeature(Transaction tx, SpatialRecord rec) {
8888
return buildFeature(rec.getId(), rec.getGeometry(), rec.getProperties(tx));
8989
}
9090

9191
public static SimpleFeatureType getTypeFromLayer(Transaction tx, Layer layer) {
9292
return getType(layer.getName(), layer.getGeometryType(tx), layer.getCoordinateReferenceSystem(tx), layer.getExtraPropertyNames(tx));
9393
}
94-
94+
9595
public static SimpleFeatureType getType(String name, Integer geometryTypeId, CoordinateReferenceSystem crs, String[] extraPropertyNames) {
9696
List<AttributeDescriptor> types = readAttributes(geometryTypeId, crs, extraPropertyNames);
9797

@@ -136,7 +136,7 @@ private static List<AttributeDescriptor> readAttributes(Integer geometryTypeId,
136136
attributes.add(build.buildDescriptor(BasicFeatureTypes.GEOMETRY_ATTRIBUTE_NAME, geometryType));
137137

138138
if (extraPropertyNames != null) {
139-
Set<String> usedNames = new HashSet<String>();
139+
Set<String> usedNames = new HashSet<String>();
140140
// record names in case of duplicates
141141
usedNames.add(BasicFeatureTypes.GEOMETRY_ATTRIBUTE_NAME);
142142

@@ -153,6 +153,6 @@ private static List<AttributeDescriptor> readAttributes(Integer geometryTypeId,
153153
}
154154

155155
return attributes;
156-
}
156+
}
157157
}
158158

src/main/java/org/geotools/data/neo4j/Neo4jSpatialDataStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
*/
2020
package org.geotools.data.neo4j;
2121

22-
import org.geotools.data.simple.SimpleFeatureSource;
22+
import org.geotools.api.data.SimpleFeatureSource;
2323
import org.geotools.data.store.ContentDataStore;
2424
import org.geotools.data.store.ContentEntry;
2525
import org.geotools.data.store.ContentFeatureSource;
2626
import org.geotools.feature.NameImpl;
2727
import org.geotools.geometry.jts.ReferencedEnvelope;
28-
import org.geotools.styling.Style;
29-
import org.geotools.styling.StyleFactory;
28+
import org.geotools.api.style.Style;
29+
import org.geotools.api.style.StyleFactory;
3030
import org.geotools.styling.StyleFactoryImpl;
3131
import org.geotools.xml.styling.SLDParser;
3232
import org.locationtech.jts.geom.Envelope;
@@ -38,9 +38,9 @@
3838
import org.neo4j.graphdb.Transaction;
3939
import org.neo4j.internal.kernel.api.security.SecurityContext;
4040
import org.neo4j.kernel.internal.GraphDatabaseAPI;
41-
import org.opengis.feature.simple.SimpleFeatureType;
42-
import org.opengis.feature.type.Name;
43-
import org.opengis.referencing.crs.CoordinateReferenceSystem;
41+
import org.geotools.api.feature.simple.SimpleFeatureType;
42+
import org.geotools.api.feature.type.Name;
43+
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
4444

4545
import java.io.File;
4646
import java.io.FileReader;
@@ -233,4 +233,4 @@ private EditableLayer getEditableLayer(String typeName) throws IOException {
233233
return (EditableLayer) layer;
234234
}
235235
}
236-
}
236+
}

src/main/java/org/geotools/data/neo4j/Neo4jSpatialDataStoreFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
*/
2020
package org.geotools.data.neo4j;
2121

22-
import org.geotools.data.DataStore;
22+
import org.geotools.api.data.DataStore;
23+
import org.geotools.api.data.DataStoreFactorySpi;
2324
import org.geotools.util.KVP;
2425
import org.neo4j.dbms.api.DatabaseManagementService;
2526
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
@@ -35,7 +36,7 @@
3536
* DataStoreFactorySpi implementation. It needs an "url" parameter containing a
3637
* path of a Neo4j neostore.id file.
3738
*/
38-
public class Neo4jSpatialDataStoreFactory implements org.geotools.data.DataStoreFactorySpi {
39+
public class Neo4jSpatialDataStoreFactory implements DataStoreFactorySpi {
3940

4041
// TODO: This should change to Neo4j 4.x directory layout and possible multiple databases
4142
/**
@@ -71,7 +72,7 @@ public DataStore createDataStore(Map<String, ?> params) throws IOException {
7172

7273
File neodir = (File) DIRECTORY.lookUp(params);
7374

74-
DatabaseManagementService databases = new DatabaseManagementServiceBuilder(neodir).build();
75+
DatabaseManagementService databases = new DatabaseManagementServiceBuilder(neodir.toPath()).build();
7576
GraphDatabaseService db = databases.database(DEFAULT_DATABASE_NAME);
7677

7778
return new Neo4jSpatialDataStore(db);
@@ -102,4 +103,4 @@ public Param[] getParametersInfo() {
102103
return new Param[]{DBTYPE, DIRECTORY};
103104
}
104105

105-
}
106+
}

src/main/java/org/geotools/data/neo4j/Neo4jSpatialFeatureSource.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
import java.util.Iterator;
2424
import java.util.NoSuchElementException;
2525

26-
import org.apache.log4j.Logger;
27-
import org.geotools.data.FeatureReader;
28-
import org.geotools.data.Query;
26+
import org.geotools.api.data.FeatureReader;
27+
import org.geotools.api.data.Query;
2928
import org.geotools.data.store.ContentEntry;
3029
import org.geotools.data.store.ContentFeatureSource;
3130
import org.geotools.feature.simple.SimpleFeatureBuilder;
@@ -36,18 +35,16 @@
3635
import org.neo4j.gis.spatial.rtree.Envelope;
3736
import org.neo4j.graphdb.GraphDatabaseService;
3837
import org.neo4j.graphdb.Transaction;
39-
import org.opengis.feature.simple.SimpleFeature;
40-
import org.opengis.feature.simple.SimpleFeatureType;
41-
import org.opengis.referencing.crs.CoordinateReferenceSystem;
38+
import org.geotools.api.feature.simple.SimpleFeature;
39+
import org.geotools.api.feature.simple.SimpleFeatureType;
40+
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
4241

4342

4443
/**
4544
* FeatureReader implementation.
4645
* Instances of this class are created by Neo4jSpatialDataStore.
4746
*/
4847
public class Neo4jSpatialFeatureSource extends ContentFeatureSource {
49-
50-
private static final Logger log = Logger.getLogger(Neo4jSpatialFeatureSource.class.getName());
5148
protected static final String FEATURE_PROP_GEOM = "the_geom";
5249

5350
private final GraphDatabaseService database;
@@ -56,7 +53,7 @@ public class Neo4jSpatialFeatureSource extends ContentFeatureSource {
5653
private final SimpleFeatureBuilder builder;
5754
private final Iterable<SpatialDatabaseRecord> results;
5855
private final String[] extraPropertyNames;
59-
56+
6057
public Neo4jSpatialFeatureSource(ContentEntry contentEntry, GraphDatabaseService database, Layer layer, SimpleFeatureType featureType, Iterable<SpatialDatabaseRecord> results, String[] extraPropertyNames) {
6158
super(contentEntry, Query.ALL);
6259
this.database = database;
@@ -66,7 +63,7 @@ public Neo4jSpatialFeatureSource(ContentEntry contentEntry, GraphDatabaseService
6663
this.builder = new SimpleFeatureBuilder(featureType);
6764
this.results = results;
6865
}
69-
66+
7067
protected Layer getLayer() {
7168
return layer;
7269
}
@@ -153,4 +150,4 @@ public boolean hasNext() throws IOException {
153150
public void close() throws IOException {
154151
}
155152
}
156-
}
153+
}

src/main/java/org/geotools/data/neo4j/Neo4jSpatialFeatureStore.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
*/
2020
package org.geotools.data.neo4j;
2121

22-
import org.geotools.data.FeatureReader;
23-
import org.geotools.data.FeatureWriter;
24-
import org.geotools.data.Query;
22+
import org.geotools.api.data.FeatureReader;
23+
import org.geotools.api.data.FeatureWriter;
24+
import org.geotools.api.data.Query;
2525
import org.geotools.data.store.ContentEntry;
2626
import org.geotools.data.store.ContentFeatureStore;
2727
import org.geotools.feature.simple.SimpleFeatureBuilder;
@@ -30,8 +30,8 @@
3030
import org.neo4j.gis.spatial.EditableLayer;
3131
import org.neo4j.graphdb.GraphDatabaseService;
3232
import org.neo4j.graphdb.Transaction;
33-
import org.opengis.feature.simple.SimpleFeature;
34-
import org.opengis.feature.simple.SimpleFeatureType;
33+
import org.geotools.api.feature.simple.SimpleFeature;
34+
import org.geotools.api.feature.simple.SimpleFeatureType;
3535

3636
import java.io.IOException;
3737
import java.util.logging.Logger;
@@ -136,7 +136,7 @@ public void remove() throws IOException {
136136
LOGGER.fine("Removing " + live);
137137

138138
try (Transaction tx = database.beginTx()) {
139-
layer.delete(tx, Long.parseLong(live.getID()));
139+
layer.delete(tx, live.getID());
140140
tx.commit();
141141
}
142142

@@ -163,7 +163,7 @@ public void write() throws IOException {
163163
if (!live.equals(current)) {
164164
LOGGER.fine("Updating " + current);
165165
try (Transaction tx = database.beginTx()) {
166-
layer.update(tx, Long.parseLong(current.getID()), (Geometry) current.getDefaultGeometry());
166+
layer.update(tx, current.getID(), (Geometry) current.getDefaultGeometry());
167167
tx.commit();
168168
}
169169

@@ -199,4 +199,4 @@ public void close() throws IOException {
199199
reader.close();
200200
}
201201
}
202-
}
202+
}

0 commit comments

Comments
 (0)