"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/plugin/mongodb/src/main/java/org/geotools/data/mongodb/complex/MongoNestedMapping.java" between
geotools-24.0-project.zip and geotools-24.1-project.zip

About: GeoTools (The Open Source Java GIS Toolkit) is a Java code library which provides standards compliant methods for the manipulation of geospatial data.

MongoNestedMapping.java  (geotools-24.0-project):MongoNestedMapping.java  (geotools-24.1-project)
skipping to change at line 19 skipping to change at line 19
* License as published by the Free Software Foundation; * License as published by the Free Software Foundation;
* version 2.1 of the License. * version 2.1 of the License.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
*/ */
package org.geotools.data.mongodb.complex; package org.geotools.data.mongodb.complex;
import static org.geotools.data.mongodb.complex.MongoComplexUtilities.extractFea
ture;
import static org.geotools.data.mongodb.complex.MongoComplexUtilities.getTransfo
rmer;
import static org.geotools.data.mongodb.complex.MongoComplexUtilities.invalidFea
ture;
import com.mongodb.DBObject; import com.mongodb.DBObject;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Supplier;
import org.geotools.data.DataAccess; import org.geotools.data.DataAccess;
import org.geotools.data.FeatureListener; import org.geotools.data.FeatureListener;
import org.geotools.data.FeatureSource; import org.geotools.data.FeatureSource;
import org.geotools.data.Query; import org.geotools.data.Query;
import org.geotools.data.QueryCapabilities; import org.geotools.data.QueryCapabilities;
import org.geotools.data.ResourceInfo; import org.geotools.data.ResourceInfo;
import org.geotools.data.complex.AppSchemaDataAccess; import org.geotools.data.complex.AppSchemaDataAccess;
import org.geotools.data.complex.FeatureTypeMapping; import org.geotools.data.complex.FeatureTypeMapping;
import org.geotools.data.complex.MappingFeatureCollection; import org.geotools.data.complex.MappingFeatureCollection;
import org.geotools.data.complex.MappingFeatureSource; import org.geotools.data.complex.MappingFeatureSource;
import org.geotools.data.complex.NestedAttributeMapping; import org.geotools.data.complex.NestedAttributeMapping;
import org.geotools.data.complex.util.XPathUtil; import org.geotools.data.complex.util.XPathUtil;
import org.geotools.data.memory.MemoryFeatureCollection; import org.geotools.data.memory.MemoryFeatureCollection;
import org.geotools.data.mongodb.MongoFeature; import org.geotools.data.mongodb.MongoFeature;
import org.geotools.feature.FeatureCollection; import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator; import org.geotools.feature.FeatureIterator;
import org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer;
import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.feature.Feature; import org.opengis.feature.Feature;
import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.type.FeatureType; import org.opengis.feature.type.FeatureType;
import org.opengis.feature.type.Name; import org.opengis.feature.type.Name;
import org.opengis.filter.Filter; import org.opengis.filter.Filter;
import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.Expression;
import org.opengis.filter.expression.PropertyName; import org.opengis.filter.expression.PropertyName;
import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.xml.sax.helpers.NamespaceSupport; import org.xml.sax.helpers.NamespaceSupport;
skipping to change at line 150 skipping to change at line 156
staticSource, staticSource,
mapping.getTargetFeature(), mapping.getTargetFeature(),
mapping.getDefaultGeometryXPath(), mapping.getDefaultGeometryXPath(),
mapping.getAttributeMappings(), mapping.getAttributeMappings(),
mapping.getNamespaces(), mapping.getNamespaces(),
mapping.isDenormalised()); mapping.isDenormalised());
return new MappingFeatureSource(dataAccess, staticMapping); return new MappingFeatureSource(dataAccess, staticMapping);
} }
private List getSubCollection(Object feature, String collectionPath) { private List getSubCollection(Object feature, String collectionPath) {
feature = MongoComplexUtilities.extractFeature(feature, collectionPath); // let's make sure we have a feature
if (feature instanceof MongoFeature) { // we should have a feature
DBObject mongoObject = ((MongoFeature) feature).getMongoObject(); if (!(feature instanceof Feature)) {
return getSubCollection(mongoObject, collectionPath, Collections.emp // not a feature so nothing to do
tyMap()); throw invalidFeature(feature, collectionPath);
} else if (feature instanceof MongoCollectionFeature) { }
MongoCollectionFeature collectionFeature = (MongoCollectionFeature) Feature f = (Feature) feature;
feature; Feature extracted = extractFeature(feature, collectionPath);
if (extracted instanceof MongoFeature) {
MongoFeature mongoFeature = (MongoFeature) extracted;
DBObject mongoObject = mongoFeature.getMongoObject();
Supplier<GeometryCoordinateSequenceTransformer> transformer =
getTransformer(f, mongoFeature);
return getSubCollection(
mongoObject, collectionPath, Collections.emptyMap(), transfo
rmer);
} else if (extracted instanceof MongoCollectionFeature) {
MongoCollectionFeature collectionFeature = (MongoCollectionFeature)
extracted;
MongoFeature mongoFeature = collectionFeature.getMongoFeature();
Supplier<GeometryCoordinateSequenceTransformer> transformer =
getTransformer(f, mongoFeature);
return getSubCollection( return getSubCollection(
collectionFeature.getMongoFeature().getMongoObject(), mongoFeature.getMongoObject(),
collectionPath, collectionPath,
collectionFeature.getCollectionsIndexes()); collectionFeature.getCollectionsIndexes(),
transformer);
} }
throw new RuntimeException("MongoDB nesting only works with MongoDB feat ures."); throw new RuntimeException("MongoDB nesting only works with MongoDB feat ures.");
} }
private List getSubCollection( private List getSubCollection(
DBObject mongoObject, String collectionPath, Map<String, Integer> co DBObject mongoObject,
llectionsIndexes) { String collectionPath,
Map<String, Integer> collectionsIndexes,
Supplier<GeometryCoordinateSequenceTransformer> transformer) {
Object value = Object value =
MongoComplexUtilities.getValue(mongoObject, collectionsIndexes, MongoComplexUtilities.getValue(
collectionPath); mongoObject, collectionsIndexes, collectionPath, transfo
rmer);
if (value == null) { if (value == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
if (value instanceof List) { if (value instanceof List) {
return (List) value; return (List) value;
} }
throw new RuntimeException("Could not extract collection from path."); throw new RuntimeException("Could not extract collection from path.");
} }
private static final class MongoStaticFeatureSource implements FeatureSource { private static final class MongoStaticFeatureSource implements FeatureSource {
 End of changes. 8 change blocks. 
14 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)