Search in sources :

Example 6 with PipelineDataStore

use of org.polymap.core.data.PipelineDataStore in project polymap4-core by Polymap4.

the class P4DataStoreInfo method canHandle.

/**
 * Returns a newly created {@link P4DataStoreInfo}, or null if the layer is not
 * connected to a {@link FeatureStore}.
 *
 * @throws Exception
 */
public static P4DataStoreInfo canHandle(Catalog catalog, ILayer layer) throws Exception {
    GeoServerServlet server = GeoServerServlet.instance.get();
    Optional<Pipeline> pipeline = server.getOrCreatePipeline(layer, FeaturesProducer.class);
    if (pipeline.isPresent()) {
        PipelineFeatureSource fs = new PipelineDataStore(pipeline.get()).getFeatureSource();
        // check with P4FeatureTypeInfo
        Name name = new NameImpl(GeoServerUtils.defaultNsInfo.get().getName(), GeoServerUtils.simpleName(layer.label.get()));
        Params params = new Params();
        FeatureRenameProcessor.NAME.rawput(params, name);
        PipelineProcessorSite procSite = new PipelineProcessorSite(params);
        ProcessorDescriptor proc = new ProcessorDescriptor(FeatureRenameProcessor.class, params);
        proc.processor().init(procSite);
        fs.pipeline().addFirst(proc);
        return new P4DataStoreInfo(catalog, layer, fs);
    } else {
        return null;
    }
}
Also used : NameImpl(org.geotools.feature.NameImpl) PipelineProcessorSite(org.polymap.core.data.pipeline.PipelineProcessorSite) PipelineFeatureSource(org.polymap.core.data.PipelineFeatureSource) GeoServerServlet(org.polymap.service.geoserver.GeoServerServlet) Params(org.polymap.core.data.pipeline.PipelineProcessorSite.Params) ProcessorDescriptor(org.polymap.core.data.pipeline.ProcessorDescriptor) Pipeline(org.polymap.core.data.pipeline.Pipeline) PipelineDataStore(org.polymap.core.data.PipelineDataStore) Name(org.opengis.feature.type.Name)

Aggregations

PipelineDataStore (org.polymap.core.data.PipelineDataStore)6 DataSourceProcessor (org.polymap.core.data.feature.DataSourceProcessor)4 Before (org.junit.Before)3 StoreCacheProcessor (org.polymap.core.data.feature.storecache.StoreCacheProcessor)2 SimplePipelineBuilder (org.polymap.core.data.pipeline.SimplePipelineBuilder)2 IOException (java.io.IOException)1 NameImpl (org.geotools.feature.NameImpl)1 Name (org.opengis.feature.type.Name)1 PipelineFeatureSource (org.polymap.core.data.PipelineFeatureSource)1 FullDataStoreSyncStrategy (org.polymap.core.data.feature.storecache.FullDataStoreSyncStrategy)1 NoSyncStrategy (org.polymap.core.data.feature.storecache.NoSyncStrategy)1 DataSourceDescriptor (org.polymap.core.data.pipeline.DataSourceDescriptor)1 Pipeline (org.polymap.core.data.pipeline.Pipeline)1 PipelineBuilder (org.polymap.core.data.pipeline.PipelineBuilder)1 PipelineProcessorSite (org.polymap.core.data.pipeline.PipelineProcessorSite)1 Params (org.polymap.core.data.pipeline.PipelineProcessorSite.Params)1 ProcessorDescriptor (org.polymap.core.data.pipeline.ProcessorDescriptor)1 CachedLazyInit (org.polymap.core.runtime.CachedLazyInit)1 GeoServerServlet (org.polymap.service.geoserver.GeoServerServlet)1