61
61
*/
62
62
public class Neo4jSpatialDataStore extends ContentDataStore implements Constants {
63
63
64
- private List <Name > typeNames ;
65
64
private final Map <String , SimpleFeatureType > simpleFeatureTypeIndex = Collections .synchronizedMap (new HashMap <>());
66
65
private final Map <String , CoordinateReferenceSystem > crsIndex = Collections .synchronizedMap (new HashMap <>());
67
66
private final Map <String , Style > styleIndex = Collections .synchronizedMap (new HashMap <>());
68
67
private final Map <String , ReferencedEnvelope > boundsIndex = Collections .synchronizedMap (new HashMap <>());
69
68
private final Map <String , SimpleFeatureSource > featureSourceIndex = Collections .synchronizedMap (new HashMap <>());
70
69
private final GraphDatabaseService database ;
71
70
private final SpatialDatabaseService spatialDatabase ;
71
+ private List <Name > typeNames ;
72
72
73
73
public Neo4jSpatialDataStore (GraphDatabaseService database ) {
74
74
this .database = database ;
@@ -91,7 +91,7 @@ protected List<Name> createTypeNames() {
91
91
for (String allTypeName : allTypeNames ) {
92
92
// discard empty layers
93
93
System .out .print ("loading layer " + allTypeName );
94
- Layer layer = spatialDatabase .getLayer (tx , allTypeName );
94
+ Layer layer = spatialDatabase .getLayer (tx , allTypeName , true );
95
95
if (!layer .getIndex ().isEmpty (tx )) {
96
96
notEmptyTypes .add (new NameImpl (allTypeName ));
97
97
}
@@ -111,7 +111,7 @@ public SimpleFeatureType buildFeatureType(String typeName) throws IOException {
111
111
SimpleFeatureType result = simpleFeatureTypeIndex .get (typeName );
112
112
if (result == null ) {
113
113
try (Transaction tx = database .beginTx ()) {
114
- Layer layer = spatialDatabase .getLayer (tx , typeName );
114
+ Layer layer = spatialDatabase .getLayer (tx , typeName , true );
115
115
if (layer == null ) {
116
116
throw new IOException ("Layer not found: " + typeName );
117
117
}
@@ -129,7 +129,7 @@ public ReferencedEnvelope getBounds(String typeName) {
129
129
ReferencedEnvelope result = boundsIndex .get (typeName );
130
130
if (result == null ) {
131
131
try (Transaction tx = database .beginTx ()) {
132
- Layer layer = spatialDatabase .getLayer (tx , typeName );
132
+ Layer layer = spatialDatabase .getLayer (tx , typeName , true );
133
133
if (layer != null ) {
134
134
Envelope bbox = Utilities .fromNeo4jToJts (layer .getIndex ().getBoundingBox (tx ));
135
135
result = new ReferencedEnvelope (bbox , getCRS (tx , layer ));
@@ -164,7 +164,7 @@ protected ContentFeatureSource createFeatureSource(ContentEntry contentEntry) th
164
164
ArrayList <SpatialDatabaseRecord > records = new ArrayList <>();
165
165
String [] extraPropertyNames ;
166
166
try (Transaction tx = database .beginTx ()) {
167
- layer = spatialDatabase .getLayer (tx , contentEntry .getTypeName ());
167
+ layer = spatialDatabase .getLayer (tx , contentEntry .getTypeName (), false );
168
168
SearchRecords results = layer .getIndex ().search (tx , new SearchAll ());
169
169
// We need to pull all records during this transaction, so that later readers do not have a transaction violation
170
170
// TODO: See if there is a more memory efficient way of doing this, perhaps create a transaction at read time in the reader?
@@ -194,7 +194,7 @@ private CoordinateReferenceSystem getCRS(Transaction tx, Layer layer) {
194
194
195
195
private Object getLayerStyle (String typeName ) {
196
196
try (Transaction tx = database .beginTx ()) {
197
- Layer layer = spatialDatabase .getLayer (tx , typeName );
197
+ Layer layer = spatialDatabase .getLayer (tx , typeName , true );
198
198
tx .commit ();
199
199
if (layer == null ) {
200
200
return null ;
0 commit comments