Package org.geoserver.catalog

Examples of org.geoserver.catalog.CatalogBuilder


    public void testCoverage() throws Exception {
        // build a feature type (it's already in the catalog, but we just want to
        // check it's built as expected
        // LINES is a feature type with a native SRS, so we want the bounds to be there
        Catalog cat = getCatalog();
        CatalogBuilder cb = new CatalogBuilder(cat);
        cb.setStore(cat.getCoverageStoreByName(MockData.TASMANIA_DEM.getLocalPart()));
        CoverageInfo fti = cb.buildCoverage();
       
        // perform basic checks
        assertEquals(CRS.decode("EPSG:4326", true), fti.getCRS());
        assertEquals("EPSG:4326", fti.getSRS());
        assertNotNull(fti.getNativeCRS());
View Full Code Here


        Catalog cat = getCatalog();
        FeatureTypeInfo fti = cat.getFeatureTypeByName(getLayerId(MockData.POINTS ));
        assertEquals(Point.class, fti.getFeatureType().getGeometryDescriptor().getType().getBinding());
        assertEquals(1, fti.getFeatureSource(null, null).getCount(Query.ALL));
       
        CatalogBuilder cb = new CatalogBuilder(cat);
        cb.setStore(cat.getStoreByName(MockData.CGF_PREFIX, DataStoreInfo.class));
        FeatureTypeInfo built = cb.buildFeatureType(fti.getQualifiedName());
        cb.setupBounds(built);
       
        assertTrue(built.getNativeBoundingBox().getWidth() > 0);
        assertTrue(built.getNativeBoundingBox().getHeight() > 0);
    }
View Full Code Here

               
                try {
                    CoordinateReferenceSystem crs = crsPanel.getCRS();
                    if ( crs != null ) {
                        //ensure the bounds calculated in terms of the user specified crs
                        new CatalogBuilder( getCatalog() ).calculateLayerGroupBounds( lg, crs );
                    }
                    else {
                        //calculate from scratch
                        new CatalogBuilder( getCatalog() ).calculateLayerGroupBounds( lg );
                    }
                   
                    envelopePanel.setModelObject( lg.getBounds() );
                    target.addComponent( envelopePanel );
                   
View Full Code Here

        this.layerInfo = layerInfo;
    }

    public Object getObject() {
        if(layerInfo.getResource().getCatalog() == null)
            new CatalogBuilder(GeoServerApplication.get().getCatalog()).attach(layerInfo);
        return layerInfo;
    }
View Full Code Here

            this.catalog = catalog;
            dataDir = new GeoServerDataDirectory(catalog.getResourceLoader());
        }

        CatalogBuilder builder() {
            return new CatalogBuilder(catalog);
        }
View Full Code Here

                w.write();
            }
            w.close();

            CatalogBuilder builder = builder();
            builder.setStore(parent.store);

            FeatureSource<?,?> source = dataStore.getFeatureSource(name);
            featureType = builder.buildFeatureType(source);
            builder.setupBounds(featureType, source);

            catalog.add(featureType);

        }
View Full Code Here

        //TODO: grab all of the icons
    }

    StyleInfo convertToWorkspaceLocal(StyleInfo s) {
        StyleInfo newStyle = catalog.getFactory().createStyle();
        new CatalogBuilder(catalog).updateStyle(newStyle, s);

        newStyle.setWorkspace(options.workspace());
        return newStyle;
    }
View Full Code Here

            }

            ResourceInfo r = l.getResource();
            r.setSRS(srs);
            try {
                new CatalogBuilder(cat).setupBounds(r);
            } catch (IOException e) {
                throw new RuntimeException("Unable to set projection on resource: " + e.getMessage(), e);
            }
        }
View Full Code Here

        LayerInfo orig = findLayer(ws.getName(), from.str("name"), cat);
        ResourceInfo origResource = orig.getResource();

        CatalogFactory factory = cat.getFactory();

        CatalogBuilder builder = new CatalogBuilder(cat);
        builder.setWorkspace(ws);

        LayerInfo l = factory.createLayer();
        if (origResource instanceof FeatureTypeInfo){
            FeatureTypeInfo resource = (FeatureTypeInfo) origResource;
            FeatureTypeInfo data = factory.createFeatureType();
            builder.updateFeatureType(data, resource);
            l.setResource(data);
        }
        else if (origResource instanceof CoverageInfo){
            CoverageInfo resource = (CoverageInfo) origResource;
            CoverageInfo data = factory.createCoverage();
            builder.updateCoverage( data,  resource);
            l.setResource(data);
        }
        else if (origResource instanceof WMSLayerInfo){
            WMSLayerInfo resource = (WMSLayerInfo) origResource;
            WMSLayerInfo data = factory.createWMSLayer();
            builder.updateWMSLayer( data,  resource);
            l.setResource(data);
        }
        else {
            throw new BadRequestException("Unable to copy layer from " + origResource.getClass().getSimpleName());
        }
View Full Code Here

    LayerInfo createLayerFromResource(JSONObj ref, WorkspaceInfo ws, Catalog cat) throws IOException {
        String storeName = ref.str("store");
        Name resourceName = new NameImpl(ref.str("name"));

        CatalogBuilder builder = new CatalogBuilder(cat);

        StoreInfo store = findStore(ws.getName(), storeName, cat);

        if( store instanceof DataStoreInfo){
            DataStoreInfo dataStore = (DataStoreInfo) store;
            builder.setStore(dataStore);

            // create from the resource
            FeatureTypeInfo ft = null;
            try {
                ft = builder.buildFeatureType(resourceName);
            }
            catch(Exception e) {
                Throwables.propagateIfInstanceOf(e, IOException.class);
                Throwables.propagate(e);
            }

            DataAccess data = dataStore.getDataStore(null);

            FeatureSource source = data.getFeatureSource(resourceName);
            builder.setupBounds(ft, source);

            return builder.buildLayer(ft);
        }
        else if (store instanceof CoverageStoreInfo) {
            CoverageStoreInfo covStore = (CoverageStoreInfo) store;
            builder.setStore(covStore);

            CoverageInfo cov = null;
            try {
                cov = builder.buildCoverage(resourceName.getLocalPart());
            } catch (Exception e) {
                Throwables.propagateIfInstanceOf(e, IOException.class);
                Throwables.propagate(e);
            }

            return builder.buildLayer(cov);
        }
        else {
            throw new UnsupportedOperationException("Copy for non vector/raster layer currently unsupported");
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.CatalogBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.