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);
}
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;
}
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;
}
}
Aggregations