Search in sources :

Example 1 with PipelineProcessorSite

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

the class StoreCacheProcessor method init.

@Override
public void init(@SuppressWarnings("hiding") PipelineProcessorSite site) throws Exception {
    this.site = site;
    // XXX shouldn't the ressource name come from upstream schema?
    assert cachestore != null : "cachestore is not yet initialized.";
    cacheDs = cachestore.get();
    String resName = site.dsd.get().resourceName.get();
    lastUpdated.computeIfAbsent(site.layerId.get(), k -> new AtomicLong2());
    // init sync strategy
    String classname = getClass().getPackage().getName() + "." + SYNC_TYPE.get(site);
    sync = (SyncStrategy) getClass().getClassLoader().loadClass(classname).newInstance();
    sync.beforeInit(this, site);
    DataSourceDescriptor cacheDsd = new DataSourceDescriptor(cacheDs, resName);
    PipelineProcessorSite cacheSite = new PipelineProcessorSite(Params.EMPTY);
    cacheSite.layerId.set(site.layerId.get());
    cacheSite.usecase.set(site.usecase.get());
    cacheSite.builder.set(site.builder.get());
    cacheSite.dsd.set(cacheDsd);
    cache = new DataSourceProcessor();
    cache.init(cacheSite);
    sync.afterInit(this, site);
}
Also used : DataSourceProcessor(org.polymap.core.data.feature.DataSourceProcessor) PipelineProcessorSite(org.polymap.core.data.pipeline.PipelineProcessorSite) DataSourceDescriptor(org.polymap.core.data.pipeline.DataSourceDescriptor)

Example 2 with PipelineProcessorSite

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

the class StatisticsSupplier method createContents.

@Override
public Control createContents(Composite parent, Param<Object> param, PipelineProcessorSite site) {
    this.layerId = site.layerId.get();
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(FormLayoutFactory.defaults().spacing(3).margins(0, 0, 3, 0).create());
    // Label
    l = new Label(container, SWT.NONE);
    l.setFont(UIUtils.italic(l.getFont()));
    updateUI();
    // 
    Button btn = new Button(container, SWT.PUSH);
    btn.setText("FLUSH CACHE");
    btn.setToolTipText("Reset timestamp so that next access will re-fetch contents from backend store");
    btn.addSelectionListener(UIUtils.selectionListener(ev -> {
        StoreCacheProcessor.lastUpdated.put(layerId, new AtomicLong2());
        updateUI();
    }));
    // layout
    FormDataFactory.on(l).fill().noBottom();
    FormDataFactory.on(btn).top(l).left(30).right(70).bottom(100);
    return container;
}
Also used : PipelineProcessorSite(org.polymap.core.data.pipeline.PipelineProcessorSite) Button(org.eclipse.swt.widgets.Button) Date(java.util.Date) AtomicLong2(org.polymap.core.data.feature.storecache.StoreCacheProcessor.AtomicLong2) DurationFormat(org.polymap.core.runtime.DurationFormat) FormLayoutFactory(org.polymap.core.ui.FormLayoutFactory) Composite(org.eclipse.swt.widgets.Composite) Duration(java.time.Duration) SWT(org.eclipse.swt.SWT) UIUtils(org.polymap.core.ui.UIUtils) FormDataFactory(org.polymap.core.ui.FormDataFactory) Label(org.eclipse.swt.widgets.Label) DateFormat(java.text.DateFormat) Control(org.eclipse.swt.widgets.Control) Param(org.polymap.core.data.pipeline.Param) Polymap(org.polymap.core.runtime.Polymap) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) AtomicLong2(org.polymap.core.data.feature.storecache.StoreCacheProcessor.AtomicLong2)

Example 3 with PipelineProcessorSite

use of org.polymap.core.data.pipeline.PipelineProcessorSite 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

PipelineProcessorSite (org.polymap.core.data.pipeline.PipelineProcessorSite)3 DateFormat (java.text.DateFormat)1 Duration (java.time.Duration)1 Date (java.util.Date)1 SWT (org.eclipse.swt.SWT)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Label (org.eclipse.swt.widgets.Label)1 NameImpl (org.geotools.feature.NameImpl)1 Name (org.opengis.feature.type.Name)1 PipelineDataStore (org.polymap.core.data.PipelineDataStore)1 PipelineFeatureSource (org.polymap.core.data.PipelineFeatureSource)1 DataSourceProcessor (org.polymap.core.data.feature.DataSourceProcessor)1 AtomicLong2 (org.polymap.core.data.feature.storecache.StoreCacheProcessor.AtomicLong2)1 DataSourceDescriptor (org.polymap.core.data.pipeline.DataSourceDescriptor)1 Param (org.polymap.core.data.pipeline.Param)1 Pipeline (org.polymap.core.data.pipeline.Pipeline)1 Params (org.polymap.core.data.pipeline.PipelineProcessorSite.Params)1 ProcessorDescriptor (org.polymap.core.data.pipeline.ProcessorDescriptor)1