Search in sources :

Example 1 with IMap

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

the class DeleteLayerOperation method doWithCommit.

@Override
public IStatus doWithCommit(IProgressMonitor monitor, IAdaptable info) throws Exception {
    assert layer.get().belongsTo(uow.get());
    monitor.beginTask(getLabel(), 2);
    register(uow.get());
    IMap map = layer.get().parentMap.get();
    // if (!map.layers.remove( layer.get() )) {
    // throw new IllegalStateException( "Unable to remove layer from map." );
    // }
    // force commit (https://github.com/Polymap4/polymap4-model/issues/6)
    map.label.set(map.label.get());
    uow.get().removeEntity(layer.get());
    assert !map.layers.contains(layer.get());
    monitor.worked(1);
    uow.get().commit();
    monitor.done();
    return Status.OK_STATUS;
}
Also used : IMap(org.polymap.core.project.IMap)

Example 2 with IMap

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

the class GeoServerLoader method loadGeoServer.

protected void loadGeoServer(GeoServerServlet service) {
    IMap map = service.map;
    log.info("Loading GeoServer...");
    GeoServerInfoImpl gsInfo = new GeoServerInfoImpl(geoserver);
    gsInfo.setTitle("GeoServer powered by mapzone.io");
    gsInfo.setId(simpleName(map.id()) + "-gs");
    // XXX alias is added by ArenaConfig when running in mapzone (see comment there)
    String proxyBaseUrl = GeoServerPlugin.instance().baseUrl.map(s -> !s.contains(service.alias) ? s + service.alias : s).get();
    gsInfo.setProxyBaseUrl(proxyBaseUrl);
    log.info("Proxy base URL: " + gsInfo.getProxyBaseUrl());
    gsInfo.setVerbose(true);
    gsInfo.setVerboseExceptions(true);
    geoserver.setGlobal(gsInfo);
    log.info("GeoServer: " + gsInfo);
    createWMSInfo(map);
    createWFSInfo(map);
}
Also used : ILayer(org.polymap.core.project.ILayer) GMLInfo(org.geoserver.wfs.GMLInfo) WorkspaceInfoImpl(org.geoserver.catalog.impl.WorkspaceInfoImpl) Supplier(java.util.function.Supplier) GeoServerExtensions(org.geoserver.platform.GeoServerExtensions) ArrayList(java.util.ArrayList) WMSInfoImpl(org.geoserver.wms.WMSInfoImpl) Version(org.geotools.util.Version) Lists(com.google.common.collect.Lists) GeoServerServlet(org.polymap.service.geoserver.GeoServerServlet) ServiceLevel(org.geoserver.wfs.WFSInfo.ServiceLevel) GeoServerUtils.simpleName(org.polymap.service.geoserver.GeoServerUtils.simpleName) WFSInfoImpl(org.geoserver.wfs.WFSInfoImpl) GeoServerInitializer(org.geoserver.config.GeoServerInitializer) Catalog(org.geoserver.catalog.Catalog) ServiceInfo(org.geoserver.config.ServiceInfo) WFSInfo(org.geoserver.wfs.WFSInfo) GeoServerReinitializer(org.geoserver.config.GeoServerReinitializer) GeoServerPlugin(org.polymap.service.geoserver.GeoServerPlugin) Keyword(org.geoserver.catalog.Keyword) GeoServerInfoImpl(org.geoserver.config.impl.GeoServerInfoImpl) GeoServer(org.geoserver.config.GeoServer) BeansException(org.springframework.beans.BeansException) Wrapper(org.geoserver.catalog.Wrapper) GeoServerResourceLoader(org.geoserver.platform.GeoServerResourceLoader) GMLInfoImpl(org.geoserver.wfs.GMLInfoImpl) ApplicationContext(org.springframework.context.ApplicationContext) Consumer(java.util.function.Consumer) BeanPostProcessor(org.springframework.beans.factory.config.BeanPostProcessor) List(java.util.List) GeoServerUtils(org.polymap.service.geoserver.GeoServerUtils) SrsNameStyle(org.geoserver.wfs.GMLInfo.SrsNameStyle) PublishedType(org.geoserver.catalog.PublishedType) DisposableBean(org.springframework.beans.factory.DisposableBean) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) IMap(org.polymap.core.project.IMap) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IMap(org.polymap.core.project.IMap) GeoServerInfoImpl(org.geoserver.config.impl.GeoServerInfoImpl)

Example 3 with IMap

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

the class GeoServerLoader method loadCatalog.

protected void loadCatalog(Catalog catalog, GeoServerServlet service) throws Exception {
    log.info("Loading catalog...");
    IMap map = service.map;
    // workspace
    WorkspaceInfoImpl wsInfo = new WorkspaceInfoImpl();
    wsInfo.setId(simpleName(map.id()) + "-ws");
    wsInfo.setDefault(true);
    // simpleName( GeoServerPlugin.instance().baseName.orElse( map.label.get() ) ) );
    wsInfo.setName("the-one-and-only");
    // catalog.add( MapInfo );
    log.info("Workspace: " + wsInfo);
    catalog.add(GeoServerUtils.defaultNsInfo.get());
    log.info("Namespace: " + GeoServerUtils.defaultNsInfo.get());
    for (ILayer layer : map.layers) {
        try {
            // Features
            P4DataStoreInfo dsInfo = P4DataStoreInfo.canHandle(catalog, layer);
            if (dsInfo != null) {
                dsInfo.setWorkspace(wsInfo);
                if (dsInfo.getFeatureSource().getSchema().getGeometryDescriptor() != null) {
                    P4FeatureTypeInfo ftInfo = new P4FeatureTypeInfo(catalog, dsInfo);
                    catalog.add(ftInfo);
                    P4LayerInfo layerInfo = new P4LayerInfo(catalog, layer, ftInfo, PublishedType.VECTOR);
                    layerInfo.createFeatureStyleInfo(service.createSLD(layer), resourceLoader);
                    catalog.add(layerInfo);
                }
                continue;
            }
            // WMS
            P4ImageStoreInfo imInfo = P4ImageStoreInfo.canHandle(catalog, layer);
            if (imInfo != null) {
                imInfo.setWorkspace(wsInfo);
                P4ImageResourceInfo resInfo = new P4ImageResourceInfo(catalog, imInfo);
                catalog.add(resInfo);
                P4LayerInfo layerInfo = new P4LayerInfo(catalog, layer, resInfo, PublishedType.WMS);
                layerInfo.createFeatureStyleInfo(service.createSLD(layer), resourceLoader);
                catalog.add(layerInfo);
                continue;
            }
        // XXX GridCoverage is not handled yet
        } catch (Exception e) {
            // don't break entire GeoServer if upstream WMS/WFS or else fails
            log.warn("Error loading layer: " + layer, e);
        }
    }
    catalog.add(wsInfo);
}
Also used : IMap(org.polymap.core.project.IMap) WorkspaceInfoImpl(org.geoserver.catalog.impl.WorkspaceInfoImpl) ILayer(org.polymap.core.project.ILayer) BeansException(org.springframework.beans.BeansException)

Aggregations

IMap (org.polymap.core.project.IMap)3 WorkspaceInfoImpl (org.geoserver.catalog.impl.WorkspaceInfoImpl)2 ILayer (org.polymap.core.project.ILayer)2 BeansException (org.springframework.beans.BeansException)2 Lists (com.google.common.collect.Lists)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Supplier (java.util.function.Supplier)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Catalog (org.geoserver.catalog.Catalog)1 Keyword (org.geoserver.catalog.Keyword)1 PublishedType (org.geoserver.catalog.PublishedType)1 Wrapper (org.geoserver.catalog.Wrapper)1 GeoServer (org.geoserver.config.GeoServer)1 GeoServerInitializer (org.geoserver.config.GeoServerInitializer)1 GeoServerReinitializer (org.geoserver.config.GeoServerReinitializer)1 ServiceInfo (org.geoserver.config.ServiceInfo)1 GeoServerInfoImpl (org.geoserver.config.impl.GeoServerInfoImpl)1