This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit bf67cae3fdbd5f3b97c4be6d9442d701b348b54b Author: jsorel <[email protected]> AuthorDate: Fri Sep 11 12:16:54 2026 +0200 feat(Shapefile): add new types of store event --- .../main/module-info.java | 3 + .../storage/internal/shared/AggregationEvent.java | 61 ++++++++++++++ .../sis/storage/internal/shared/ContentEvent.java} | 26 +++--- .../internal/shared/FeatureSetContentEvent.java | 96 +++++++++++++++++++++ .../internal/shared/FeatureSetModelEvent.java | 97 ++++++++++++++++++++++ .../sis/storage/internal/shared/ModelEvent.java} | 21 +++-- .../sis/storage/internal/shared/StorageEvent.java} | 26 +++--- .../internal/shared/TilingContentEvent.java | 88 ++++++++++++++++++++ .../storage/internal/shared/TilingModelEvent.java | 97 ++++++++++++++++++++++ 9 files changed, 482 insertions(+), 33 deletions(-) diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java b/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java index 9bb7b321f2..f46406440a 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java @@ -30,6 +30,9 @@ module org.apache.sis.storage.shapefile { exports org.apache.sis.storage.shapefile.shp; exports org.apache.sis.storage.shapefile.shx; + //todo : move this to endorsed when reviewed + exports org.apache.sis.storage.internal.shared; + provides org.apache.sis.storage.DataStoreProvider with org.apache.sis.storage.shapefile.ShapefileProvider; } diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/AggregationEvent.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/AggregationEvent.java new file mode 100644 index 0000000000..c952105532 --- /dev/null +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/AggregationEvent.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.storage.Resource; +import org.apache.sis.storage.event.StoreEvent; + +/** + * Event raised when a resource has been added or removed from an Aggregation. + * + * @author Johann Sorel (Geomatys) + */ +public class AggregationEvent extends StoreEvent { + + public static final int TYPE_ADD = 1; + public static final int TYPE_REMOVE = 2; + + private final int type; + private final Resource[] changes; + + /** + * + * @param source parent resource of the modified resources + * @param type ADD or REMOVE + * @param changes the resources added or removed. + */ + public AggregationEvent(Resource source, int type, Resource ... changes) { + super(source); + this.type = type; + this.changes = changes; + } + + /** + * @return ADD or REMOVE + */ + public int getType() { + return type; + } + + /** + * @return the resources added or removed. + */ + public Resource[] getChanges() { + return changes; + } + +} diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/ContentEvent.java similarity index 60% copy from incubator/src/org.apache.sis.storage.shapefile/main/module-info.java copy to incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/ContentEvent.java index 9bb7b321f2..782c0a83ed 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/ContentEvent.java @@ -14,22 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.storage.Resource; /** - * Shapefile store. + * Experimental event used to notify the content of the resource has change. + * For FeatureSet this implies features have been added, deleted or updated. + * For GridCoverageResource this implies the coverage samples have change. * * @author Johann Sorel (Geomatys) */ -module org.apache.sis.storage.shapefile { - requires esri.geometry.api; - requires transitive org.apache.sis.storage; +public class ContentEvent extends StorageEvent { + + public ContentEvent(Resource resource) { + super(resource); + } - exports org.apache.sis.storage.shapefile; - exports org.apache.sis.storage.shapefile.cpg; - exports org.apache.sis.storage.shapefile.dbf; - exports org.apache.sis.storage.shapefile.shp; - exports org.apache.sis.storage.shapefile.shx; + @Override + public StorageEvent copy(Resource source) { + return new ContentEvent(source); + } - provides org.apache.sis.storage.DataStoreProvider - with org.apache.sis.storage.shapefile.ShapefileProvider; } diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/FeatureSetContentEvent.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/FeatureSetContentEvent.java new file mode 100644 index 0000000000..b8af83b1d9 --- /dev/null +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/FeatureSetContentEvent.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.storage.internal.shared; + +import java.util.Set; +import org.apache.sis.filter.DefaultFilterFactory; +import org.apache.sis.storage.Resource; +import org.opengis.feature.Feature; +import org.opengis.filter.Filter; +import org.opengis.filter.ResourceId; + +/** + * FeatureSet content event. + * + * @author Johann Sorel (Geomatys) + */ +public class FeatureSetContentEvent extends ContentEvent { + + public static enum Type{ + ADD, + UPDATE, + DELETE + }; + + private final Type type; + private Filter ids; + + public FeatureSetContentEvent(final Resource source, final Type type, final Filter<Feature> identifiers) { + super(source); + this.type = type; + this.ids = identifiers; + } + + public FeatureSetContentEvent(final Resource source, final Type type, final Set<ResourceId> ids){ + this(source, type, resourceId(ids)); + } + + public static Filter<Feature> resourceId(final Set<ResourceId> ids) { + if (ids == null) { + return null; + } + switch (ids.size()) { + case 0: return Filter.exclude(); + case 1: return ids.iterator().next(); + default: return DefaultFilterFactory.forFeatures().or((Set) ids); + } + } + + /** + * Get the event type, can be Add, Update or Delete. + * @return Type of the event , never null. + */ + public Type getType() { + return type; + } + + /** + * Get the modified feature ids related to this event. + * This object may be null if the ids could not be retrieved. + * @return ResourceId or null + */ + public Filter<Feature> getIds() { + return ids; + } + + public FeatureSetContentEvent copy(final Resource source){ + return new FeatureSetContentEvent(source, type, ids); + } + + public static FeatureSetContentEvent createAddEvent(final Resource source, final Filter<Feature> ids){ + return new FeatureSetContentEvent(source, Type.ADD, ids); + } + + public static FeatureSetContentEvent createUpdateEvent(final Resource source, final Filter<Feature> ids){ + return new FeatureSetContentEvent(source, Type.UPDATE, ids); + } + + public static FeatureSetContentEvent createDeleteEvent(final Resource source, final Filter<Feature> ids){ + return new FeatureSetContentEvent(source, Type.DELETE, ids); + } + +} diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/FeatureSetModelEvent.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/FeatureSetModelEvent.java new file mode 100644 index 0000000000..81304dcc90 --- /dev/null +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/FeatureSetModelEvent.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.storage.Resource; +import static org.apache.sis.util.ArgumentChecks.*; +import org.opengis.feature.FeatureType; + +/** + * FeatureSet management event. + * + * @todo work in progress + * @author Johann Sorel (Geomatys) + */ +public class FeatureSetModelEvent extends ModelEvent { + + public static enum Type{ + ADD, + UPDATE, + DELETE + }; + + private final Type type; + private final FeatureType oldType; + private final FeatureType newType; + + private FeatureSetModelEvent(final Resource source, final Type type, final FeatureType oldtype, final FeatureType newtype){ + super(source); + + ensureNonNull("type", type); + if(oldtype == null && newtype == null){ + throw new NullPointerException("Old and new feature type can not be both null."); + } + this.type = type; + this.oldType = oldtype; + this.newType = newtype; + } + + /** + * get the event type, can be Add, Update or Delete. + * @return Type of the event , never null. + */ + public Type getType() { + return type; + } + + /** + * Retrieve the newly created feature type or + * the updated feature type. + * @return FeatureType or null if event is a Delete + */ + public FeatureType getNewFeatureType() { + return newType; + } + + /** + * Retrieve the deleted feature type or + * the old updated feature type. + * + * @return FeatureType or null if event is an Add + */ + public FeatureType getOldFeatureType() { + return oldType; + } + + @Override + public FeatureSetModelEvent copy(Resource source) { + return new FeatureSetModelEvent(source, type, oldType, newType); + } + + public static FeatureSetModelEvent createAddEvent(final Resource source, final FeatureType type){ + return new FeatureSetModelEvent(source, Type.ADD, null, type); + } + + public static FeatureSetModelEvent createUpdateEvent(final Resource source, final FeatureType oldType, final FeatureType newType){ + return new FeatureSetModelEvent(source, Type.UPDATE, oldType, newType); + } + + public static FeatureSetModelEvent createDeleteEvent(final Resource source, final FeatureType type){ + return new FeatureSetModelEvent(source, Type.DELETE, type, null); + } + +} diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/ModelEvent.java similarity index 62% copy from incubator/src/org.apache.sis.storage.shapefile/main/module-info.java copy to incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/ModelEvent.java index 9bb7b321f2..97f30ad989 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/ModelEvent.java @@ -14,22 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.storage.Resource; /** - * Shapefile store. + * Experimental event used to notify the structure of the resource has change. + * For FeatureSet this implies the FeatureType has been updated. + * For GridCoverageResource this implies the GridGeometry has change. * * @author Johann Sorel (Geomatys) */ -module org.apache.sis.storage.shapefile { - requires esri.geometry.api; - requires transitive org.apache.sis.storage; +public abstract class ModelEvent extends StorageEvent { - exports org.apache.sis.storage.shapefile; - exports org.apache.sis.storage.shapefile.cpg; - exports org.apache.sis.storage.shapefile.dbf; - exports org.apache.sis.storage.shapefile.shp; - exports org.apache.sis.storage.shapefile.shx; + public ModelEvent(Resource resource) { + super(resource); + } - provides org.apache.sis.storage.DataStoreProvider - with org.apache.sis.storage.shapefile.ShapefileProvider; } diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/StorageEvent.java similarity index 62% copy from incubator/src/org.apache.sis.storage.shapefile/main/module-info.java copy to incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/StorageEvent.java index 9bb7b321f2..673339a8d4 100644 --- a/incubator/src/org.apache.sis.storage.shapefile/main/module-info.java +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/StorageEvent.java @@ -14,22 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.storage.event.StoreEvent; +import org.apache.sis.storage.Resource; /** - * Shapefile store. + * Storage event. * * @author Johann Sorel (Geomatys) */ -module org.apache.sis.storage.shapefile { - requires esri.geometry.api; - requires transitive org.apache.sis.storage; +public abstract class StorageEvent extends StoreEvent { - exports org.apache.sis.storage.shapefile; - exports org.apache.sis.storage.shapefile.cpg; - exports org.apache.sis.storage.shapefile.dbf; - exports org.apache.sis.storage.shapefile.shp; - exports org.apache.sis.storage.shapefile.shx; + public StorageEvent(final Resource source){ + super(source); + } - provides org.apache.sis.storage.DataStoreProvider - with org.apache.sis.storage.shapefile.ShapefileProvider; + /** + * Copy this event changing it's source. + * @param source new source + * @return StorageEvent + */ + public abstract StorageEvent copy(Resource source); } diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/TilingContentEvent.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/TilingContentEvent.java new file mode 100644 index 0000000000..8f2f61b417 --- /dev/null +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/TilingContentEvent.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.coverage.grid.GridExtent; +import org.apache.sis.storage.Resource; + +/** + * + * @author Johann Sorel (Geomatys) + */ +public class TilingContentEvent extends ContentEvent { + + public static enum Type{ + /** tiles added */ + TILE_ADD, + /** tiles updated */ + TILE_UPDATE, + /** tiles deleted */ + TILE_DELETE + }; + + private final Type type; + private final String pyramidId; + private final String mosaicId; + private final GridExtent tiles; + + + public TilingContentEvent(Resource source, Type type, + String pyramidId, String mosaicId, GridExtent tiles) { + super(source); + this.type = type; + this.pyramidId = pyramidId; + this.mosaicId = mosaicId; + this.tiles = tiles; + } + + public Type getType() { + return type; + } + + public String getPyramidId() { + return pyramidId; + } + + public String getMosaicId() { + return mosaicId; + } + + public GridExtent getTiles() { + return tiles; + } + + @Override + public TilingContentEvent copy(final Resource source){ + return new TilingContentEvent(source, type, pyramidId, mosaicId, tiles); + } + + public static TilingContentEvent createTileAddEvent(final Resource source, + final String pyramidId, final String mosaicId, final GridExtent tiles){ + return new TilingContentEvent(source, Type.TILE_ADD, pyramidId, mosaicId, tiles); + } + + public static TilingContentEvent createTileUpdateEvent(final Resource source, + final String pyramidId, final String mosaicId, final GridExtent tiles){ + return new TilingContentEvent(source, Type.TILE_UPDATE, pyramidId, mosaicId, tiles); + } + + public static TilingContentEvent createTileDeleteEvent(final Resource source, + final String pyramidId, final String mosaicId, final GridExtent tiles){ + return new TilingContentEvent(source, Type.TILE_DELETE, pyramidId, mosaicId, tiles); + } + +} diff --git a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/TilingModelEvent.java b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/TilingModelEvent.java new file mode 100644 index 0000000000..59d8e35509 --- /dev/null +++ b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/internal/shared/TilingModelEvent.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.storage.internal.shared; + +import org.apache.sis.storage.Resource; +import org.opengis.util.GenericName; + +/** + * Coverage store structure change event. + * + * @author Johann Sorel (Geomatys) + */ +public class TilingModelEvent extends ModelEvent { + + public static enum Type{ + PYRAMID_ADD, + PYRAMID_UPDATE, + PYRAMID_DELETE, + MOSAIC_ADD, + MOSAIC_UPDATE, + MOSAIC_DELETE + }; + + private final Type type; + private final String pyramidId; + private final String mosaicId; + + + public TilingModelEvent(Resource source, Type type, String pyramidId, String mosaicId) { + super(source); + this.type = type; + this.pyramidId = pyramidId; + this.mosaicId = mosaicId; + } + + public Type getType() { + return type; + } + + public String getPyramidId() { + return pyramidId; + } + + public String getMosaicId() { + return mosaicId; + } + + @Override + public TilingModelEvent copy(final Resource source){ + return new TilingModelEvent(source, type, pyramidId, mosaicId); + } + + public static TilingModelEvent createPyramidAddEvent( + final Resource source, final GenericName name, final String pyramidId){ + return new TilingModelEvent(source, Type.PYRAMID_ADD, pyramidId, null); + } + + public static TilingModelEvent createPyramidUpdateEvent( + final Resource source, final GenericName name, final String pyramidId){ + return new TilingModelEvent(source, Type.PYRAMID_UPDATE, pyramidId, null); + } + + public static TilingModelEvent createPyramidDeleteEvent( + final Resource source, final GenericName name, final String pyramidId){ + return new TilingModelEvent(source, Type.PYRAMID_DELETE, pyramidId, null); + } + + public static TilingModelEvent createMosaicAddEvent( + final Resource source, final GenericName name, final String pyramidId, final String mosaicId){ + return new TilingModelEvent(source, Type.PYRAMID_ADD, pyramidId, mosaicId); + } + + public static TilingModelEvent createMosaicUpdateEvent( + final Resource source, final GenericName name, final String pyramidId, final String mosaicId){ + return new TilingModelEvent(source, Type.PYRAMID_UPDATE, pyramidId, mosaicId); + } + + public static TilingModelEvent createMosaicDeleteEvent( + final Resource source, final GenericName name, final String pyramidId, final String mosaicId){ + return new TilingModelEvent(source, Type.PYRAMID_DELETE, pyramidId, mosaicId); + } + +}
