-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to publish data belonging to all DB schemas
- Loading branch information
Showing
33 changed files
with
2,206 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ogc-features/src/main/java/com/camptocamp/geotools/data/decorate/DecoratingDataStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.camptocamp.geotools.data.decorate; | ||
|
||
import org.geotools.api.data.DataStore; | ||
|
||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Delegate; | ||
|
||
/** | ||
* Abstract {@link DataStore} decorator forwarding all method calls to the | ||
* decorated object | ||
*/ | ||
@RequiredArgsConstructor | ||
public abstract class DecoratingDataStore implements DataStore { | ||
|
||
@Delegate | ||
protected final @NonNull DataStore delegate; | ||
} |
14 changes: 14 additions & 0 deletions
14
...features/src/main/java/com/camptocamp/geotools/data/decorate/DecoratingFeatureSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.camptocamp.geotools.data.decorate; | ||
|
||
import org.geotools.api.data.SimpleFeatureSource; | ||
|
||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Delegate; | ||
|
||
@RequiredArgsConstructor | ||
public class DecoratingFeatureSource implements SimpleFeatureSource { | ||
|
||
@Delegate | ||
protected final @NonNull SimpleFeatureSource delegate; | ||
} |
66 changes: 66 additions & 0 deletions
66
...ures/src/main/java/com/camptocamp/geotools/data/decorate/DecoratingReadOnlyDataStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.camptocamp.geotools.data.decorate; | ||
|
||
import static com.camptocamp.geotools.data.decorate.ReadOnlyDataStore.readOnlyException; | ||
|
||
import org.geotools.api.data.DataStore; | ||
import org.geotools.api.data.FeatureWriter; | ||
import org.geotools.api.data.Transaction; | ||
import org.geotools.api.feature.simple.SimpleFeature; | ||
import org.geotools.api.feature.simple.SimpleFeatureType; | ||
import org.geotools.api.feature.type.Name; | ||
import org.geotools.api.filter.Filter; | ||
|
||
import lombok.NonNull; | ||
|
||
/** | ||
* A read-only {@link DecoratingDataStore}, where all mutating methods throw an | ||
* {@link UnsupportedOperationException} | ||
*/ | ||
public abstract class DecoratingReadOnlyDataStore extends DecoratingDataStore implements ReadOnlyDataStore { | ||
|
||
protected DecoratingReadOnlyDataStore(@NonNull DataStore delegate) { | ||
super(delegate); | ||
} | ||
|
||
@Override | ||
public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName, Filter filter, | ||
Transaction transaction) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName, Transaction transaction) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(String typeName, | ||
Transaction transaction) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public void createSchema(SimpleFeatureType featureType) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public void updateSchema(Name typeName, SimpleFeatureType featureType) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public void removeSchema(Name typeName) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public void updateSchema(String typeName, SimpleFeatureType featureType) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
public void removeSchema(String typeName) { | ||
throw readOnlyException(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../ogc-features/src/main/java/com/camptocamp/geotools/data/decorate/PrefixingDataStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.camptocamp.geotools.data.decorate; | ||
|
||
import static org.springframework.util.ObjectUtils.isEmpty; | ||
|
||
import java.util.function.Supplier; | ||
import java.util.function.UnaryOperator; | ||
|
||
import org.geotools.api.data.DataStore; | ||
|
||
import lombok.NonNull; | ||
|
||
/** | ||
* {@link RenamingDataStore} whose rename/undo functions apply or remove a given | ||
* prefix to all FeatureType names | ||
*/ | ||
public class PrefixingDataStore extends RenamingDataStore { | ||
|
||
public PrefixingDataStore(@NonNull DataStore delegate, @NonNull Supplier</* Nullable */String> typeNamePrefix) { | ||
super(delegate, rename(typeNamePrefix), undo(typeNamePrefix)); | ||
} | ||
|
||
/** | ||
* Function to apply the FeatureType name prefix as the renaming function of | ||
* RenamingDataStore | ||
*/ | ||
private static @NonNull UnaryOperator<String> rename(Supplier<String> typeNamePrefix) { | ||
return name -> isEmpty(typeNamePrefix.get()) ? name : "%s%s".formatted(typeNamePrefix.get(), name); | ||
} | ||
|
||
/** | ||
* Function remote the FeatureType name prefix as the undo renaming function of | ||
* RenamingDataStore | ||
*/ | ||
private static @NonNull UnaryOperator<String> undo(Supplier<String> typeNamePrefix) { | ||
return prefixedName -> isEmpty(typeNamePrefix.get()) ? prefixedName | ||
: prefixedName.substring(typeNamePrefix.get().length()); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...s/ogc-features/src/main/java/com/camptocamp/geotools/data/decorate/ReadOnlyDataStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.camptocamp.geotools.data.decorate; | ||
|
||
import org.geotools.api.data.DataStore; | ||
import org.geotools.api.data.FeatureWriter; | ||
import org.geotools.api.data.LockingManager; | ||
import org.geotools.api.data.Transaction; | ||
import org.geotools.api.feature.simple.SimpleFeature; | ||
import org.geotools.api.feature.simple.SimpleFeatureType; | ||
import org.geotools.api.feature.type.Name; | ||
import org.geotools.api.filter.Filter; | ||
import org.geotools.data.InProcessLockingManager; | ||
|
||
/** | ||
* Read-only {@link DataStore} interface extension where all mutating methods | ||
* throw an {@link UnsupportedOperationException} | ||
*/ | ||
public interface ReadOnlyDataStore extends DataStore { | ||
|
||
LockingManager IN_PROCESS_LOCKING = new InProcessLockingManager(); | ||
|
||
@Override | ||
default LockingManager getLockingManager() { | ||
return IN_PROCESS_LOCKING; | ||
} | ||
|
||
@Override | ||
default FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName, Filter filter, | ||
Transaction transaction) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName, Transaction transaction) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(String typeName, | ||
Transaction transaction) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default void createSchema(SimpleFeatureType featureType) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default void updateSchema(Name typeName, SimpleFeatureType featureType) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default void removeSchema(Name typeName) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default void updateSchema(String typeName, SimpleFeatureType featureType) { | ||
throw readOnlyException(); | ||
} | ||
|
||
@Override | ||
default void removeSchema(String typeName) { | ||
throw readOnlyException(); | ||
} | ||
|
||
static UnsupportedOperationException readOnlyException() { | ||
return new UnsupportedOperationException("read only"); | ||
} | ||
} |
Oops, something went wrong.