Package org.geoserver.catalog

Examples of org.geoserver.catalog.Catalog


   
    public IStylePanel(String id, LayerInfo l) {
        super(id);
       
        LayerInfo layer = l;
        Catalog catalog = ((GeoServerApplication)getApplication()).getCatalog();
        if ( layer == null ) {
            layer = catalog.getLayers().get(0);
        }
       
        add(mapPanel = new OpenLayersMapPanel("map", layer));

        Form form = new Form("form");
        add(form);
       
        form.add(sldTextArea = new TextArea("editor", new PropertyModel(this, "sld")));
        sldTextArea.setOutputMarkupId(true);
        //sldTextArea.add(new EditAreaBehavior());
       
        updateSLD();
       
        //TODO: do not pass in layers directly, but load them via a detachable model
        form.add(layerChoice =
            new DropDownChoice("layers", new Model(), catalog.getLayers(), new ChoiceRenderer() {
                @Override
                public Object getDisplayValue(Object object) {
                    return ((LayerInfo)object).getName();
                }
        }));
        layerChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                LayerInfo l = (LayerInfo) layerChoice.getModelObject();
                mapPanel.update(l, null, target);

                updateStyles(l);
                target.addComponent(styleChoice);
               
                updateSLD();
                target.addComponent(sldTextArea);
            }
        });
        layerChoice.setModelObject(layer);
        layerChoice.setEnabled(l == null);
       
        form.add(styleChoice =
            new DropDownChoice("styles", new Model(), new ArrayList(layer.getStyles()), new ChoiceRenderer() {
                @Override
                public Object getDisplayValue(Object object) {
                    return ((StyleInfo)object).getName();
                }
        }));
        styleChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                StyleInfo s = (StyleInfo) styleChoice.getModelObject();
                mapPanel.update(null,s,target);
               
                updateSLD();
                target.addComponent(sldTextArea);
            }
        });
        updateStyles(layer);
       
        form.add(new AjaxButton("save", form) {
           
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form form) {
                //sldTextArea.inputChanged();
                //sldTextArea.processInput();
               
                Catalog catalog = ((GeoServerApplication)getApplication()).getCatalog();
                StyleInfo style = (StyleInfo) styleChoice.getModelObject();
               
                try {
                    catalog.getResourcePool().writeStyle(style, new ByteArrayInputStream(sld.getBytes()));
                    catalog.save(style);
                   
                    mapPanel.update(null,style,target);
                }
                catch (IOException e) {
                    throw new RuntimeException(e);
View Full Code Here


        });
    }

    void updateSLD() {
        try {
            Catalog catalog = ((GeoServerApplication)getApplication()).getCatalog();
            BufferedReader r =
                catalog.getResourcePool().readStyle(mapPanel.getCurrentStyle());
           
            StringBuilder builder = new StringBuilder();
            String line = null;
            while ((line = r.readLine()) != null ) {
                builder.append(line).append("\n");
View Full Code Here

    protected CachedHierarchyRegionatingStrategy(GeoServer gs) {
        this.gs = gs;
    }
   
    public Filter getFilter(WMSMapContext context, MapLayer layer) {
        Catalog catalog = gs.getCatalog();
        Set<String> featuresInTile = Collections.emptySet();
        try {
            // grab information needed to reach the db and get a hold to a db
            // connection
            FeatureSource featureSource = layer.getFeatureSource();
            featureType = catalog.getFeatureTypeByName(featureSource.getName());
           
            String dataDir = catalog.getResourceLoader().getBaseDirectory().getCanonicalPath();
            tableName = getDatabaseName(context, layer);

            // grab the features per tile, use a default if user did not
            // provide a decent value. The default should fill up the
            // tile when it shows up.
View Full Code Here

        if (loggingInfo == null) {
            LOGGER.warning("Missing logging info. Creating default.");
            loggingInfo = this.geoserver.getFactory().createLogging();
            geoserver.setLogging(loggingInfo);
        }
        Catalog catalog = geoserver.getCatalog();
        catalog.setResourceLoader(resourceLoader);

        if (catalog instanceof Wrapper && ((Wrapper) catalog).isWrapperFor(Catalog.class)) {
            catalog = ((Wrapper) catalog).unwrap(Catalog.class);
        }
View Full Code Here

        }

        public void encode(Object o) throws IllegalArgumentException {
            FeatureCollection<SimpleFeatureType, SimpleFeature> features = (FeatureCollection) o;
            SimpleFeatureType featureType = features.getSchema();
            Catalog catalog = mapContext.getRequest().getWMS().getGeoServer().getCatalog();

            if (isStandAlone()) {
                start( "kml" );
            }
View Full Code Here

        wms.setGeoServer(config);
        config.add(wms);
    }

    public static void createDefaultXXXXspace(GeoServer geoServer) {
        Catalog resourceCatalog = geoServer.getCatalog();

        NamespaceInfo ns = resourceCatalog.getFactory().createNamespace();
        ns.setPrefix("topp");
        ns.setURI("http://www.opengeo.org");
        resourceCatalog.add(ns);
        resourceCatalog.setDefaultNamespace(ns);

        ns = resourceCatalog.getFactory().createNamespace();
        ns.setPrefix("it.geosolutions");
        ns.setURI("http://www.geo-solutions.it");
        resourceCatalog.add(ns);

        WorkspaceInfoImpl ws = (WorkspaceInfoImpl) resourceCatalog.getFactory()
                .createWorkspace();
        ws.setName("topp");
        resourceCatalog.add(ws);
        resourceCatalog.setDefaultWorkspace(ws);

        ws = (WorkspaceInfoImpl) resourceCatalog.getFactory().createWorkspace();
        ws.setName("it.geosolutions");
        resourceCatalog.add(ws);
    }
View Full Code Here

     * @throws Exception
     */
    public void testInit() throws Exception {
        GWCCatalogListener gwcListener = (GWCCatalogListener) applicationContext.getBean("gwcCatalogListener");
       
        Catalog cat = gwcListener.cat;
       
        TileLayerDispatcher tld = gwcListener.layerDispatcher;
       
        try {
            tld.getTileLayer("");
        } catch (GeoWebCacheException gwce) {
           
        }
       
        List<TileLayer> layerList = gwcListener.getTileLayers(true);
       
        Iterator<TileLayer> tlIter = layerList.iterator();

        assertTrue(tlIter.hasNext());

        // Disabling tests until I have working build
        if (tlIter.hasNext()) {
            return;
        }

        // 1) Check that cite:Lakes
        boolean foundLakes = false;
        while(tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            if(tl.getName().equals("cite:Lakes")) {
                //tl.isInitialized();
                foundLakes = true;
                break;
            }
        }                   
        assertTrue(foundLakes);

        // 2) Check sf:GenerictEntity is present and initialized
        boolean foudAGF = false;
        while(tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            System.out.println(tl.getName());
            if(tl.getName().equals("sf:AggregateGeoFeature")) {
                //tl.isInitialized();
                foudAGF = true;
                GridSubset epsg4326 = tl.getGridSubset(gwcListener.gridSetBroker.WORLD_EPSG4326.getName());
                assertTrue(epsg4326.getGridSetBounds().equals( new BoundingBox(-180.0,-90.0,180.0,90.0)));
                String mime = tl.getMimeTypes().get(1).getMimeType();
                assertTrue(mime.startsWith("image/") || mime.startsWith("application/vnd.google-earth.kml+xml"));
            }
        }
       
        assertTrue(foudAGF);
       
       
        // 3) Basic get
        LayerInfo li = cat.getLayers().get(1);
        String layerName = li.getResource().getPrefixedName();
       
        TileLayer tl = tld.getTileLayer(layerName);
       
        assertEquals(layerName, tl.getName());
       
       
        // 4) Removal of LayerInfo from catalog
        cat.remove(li);
       
        assertTrue(cat.getLayerByName(tl.getName()) == null);
       
        boolean caughtException = false;
        try {
            TileLayer tl2 = tld.getTileLayer(layerName);
        } catch (GeoWebCacheException gwce) {
            caughtException = true;
        }
        assertTrue(caughtException);
       
        // 5) Introducing new LayerInfo
        LayerInfo layerInfo = cat.getFactory().createLayer();
        layerInfo.setName("hithere");
        ResourceInfo resInfo = li.getResource();
        resInfo.setName("hithere");
        resInfo.getNamespace().setPrefix("sf");
        layerInfo.setResource(resInfo);
       
        cat.add(layerInfo);
        TileLayer tl3 = tld.getTileLayer("sf:hithere");
        assertEquals(tl3.getName(),"sf:hithere");
    }
View Full Code Here

        // check the regionating strategy
        RegionatingStrategy regionatingStrategy = null;
        String stratname = (String) mapContext.getRequest().getFormatOptions()
                .get("regionateBy");
        if (("auto").equals(stratname)) {
            Catalog catalog = mapContext.getRequest().getWMS().getGeoServer().getCatalog();
            Name name = layer.getFeatureSource().getName();
            stratname = catalog.getFeatureTypeByName(name).getMetadata().get( "kml.regionateStrategy",String.class );
            if (stratname == null || "".equals( stratname ) ){
                stratname = "best_guess";
                LOGGER.log(
                        Level.FINE,
                        "No default regionating strategy has been configured in " + name
View Full Code Here

   
    @Override
    protected void oneTimeSetUp() throws Exception {
        super.oneTimeSetUp();
        Catalog catalog = getCatalog();
       
        String lakes = MockData.LAKES.getLocalPart();
        String forests = MockData.FORESTS.getLocalPart();
        String bridges = MockData.BRIDGES.getLocalPart();
        LayerGroupInfo lg = catalog.getFactory().createLayerGroup();
        lg.setName("lakesGroup");
        lg.getLayers().add(catalog.getLayerByName(lakes));
        lg.getStyles().add(catalog.getStyleByName(lakes));
        lg.getLayers().add(catalog.getLayerByName(forests));
        lg.getStyles().add(catalog.getStyleByName(forests));
        lg.getLayers().add(catalog.getLayerByName(bridges));
        lg.getStyles().add(catalog.getStyleByName(bridges));
        CatalogBuilder builder = new CatalogBuilder(catalog);
        builder.calculateLayerGroupBounds(lg);
        catalog.add(lg);

        // makes the lakes layer a multi-style one
        LayerInfo lakesLayer = catalog.getLayerByName(getLayerId(MockData.LAKES));
        lakesLayer.getStyles().add(catalog.getStyleByName(MockData.FORESTS.getLocalPart()));
        catalog.save(lakesLayer);
    }
View Full Code Here

     *             DOCUMENT ME!
     */
    public void testSimpleGetMapQuery() throws Exception {

       
        Catalog catalog = getCatalog();
        final FeatureSource fs = catalog.getFeatureTypeByName(MockData.BASIC_POLYGONS.getPrefix(),
                MockData.BASIC_POLYGONS.getLocalPart()).getFeatureSource(null, null);
       
        final Envelope env = fs.getBounds();

        LOGGER.info("about to create map ctx for BasicPolygons with bounds " + env);

        final WMSMapContext map = new WMSMapContext();
        map.setAreaOfInterest(new ReferencedEnvelope(env, DefaultGeographicCRS.WGS84));
        map.setMapWidth(300);
        map.setMapHeight(300);
        map.setBgColor(Color.red);
        map.setTransparent(false);
        map.setRequest(new GetMapRequest(getWMS()));

        StyleInfo styleByName = catalog.getStyleByName("Default");
        Style basicStyle = styleByName.getStyle();
        map.addLayer(fs, basicStyle);

        this.rasterMapProducer.setOutputFormat(getMapFormat());
        this.rasterMapProducer.setMapContext(map);
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.Catalog

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.