Package org.geoserver.catalog

Examples of org.geoserver.catalog.LayerGroupInfo


    public static final String GROUP = "group";
   
    public LayerGroupEditPage(PageParameters parameters) {
        String groupName = parameters.getString(GROUP);
        LayerGroupInfo lg = getCatalog().getLayerGroupByName(groupName);
       
        if(lg == null) {
            error(new ParamResourceModel("LayerGroupEditPage.notFound", this, groupName).getString());
            setResponsePage(LayerGroupPage.class);
            return;
View Full Code Here


       
        initUI(lg);
    }
   
    protected void onSubmit() {
        LayerGroupInfo lg = (LayerGroupInfo) lgModel.getObject();
       
        getCatalog().save( lg );
        setResponsePage(LayerGroupPage.class);
    }
View Full Code Here

            List<StyledLayer> layers = new ArrayList<StyledLayer>();
            for(String layerName : request.getLayers()) {
                NamedLayer namedLayer = factory.createNamedLayer();
                layers.add(namedLayer);
                namedLayer.setName(layerName);
                LayerGroupInfo group = wms.getLayerGroupByName(layerName);
                LayerInfo layer = wms.getLayerByName(layerName);
                if(group != null) {
                    // nothing to do, groups have no style
                } else if(layer != null) {
                    Style style = layer.getDefaultStyle().getStyle();
View Full Code Here

        initUI(getCatalog().getFactory().createLayerGroup());
    }

    @Override
    protected void onSubmit() {
        LayerGroupInfo lg = (LayerGroupInfo) lgModel.getObject();

        Catalog catalog = getCatalog();
        try {
            catalog.add(lg);

            lg = catalog.getLayerGroup(lg.getId());
            setResponsePage(LayerGroupPage.class);
        } catch (Exception e) {
            error(e);
            LOGGER.log(Level.WARNING, "Error creating new layer group.", e);
        }
View Full Code Here

    void validate(LayerGroupInfo layerGroup, boolean isNew) {
        if (isNull(layerGroup.getName())) {
            throw new NullPointerException("Layer group name must not be null");
        }

        LayerGroupInfo existing = getLayerGroupByName(layerGroup.getName());
        if (existing != null && !existing.getId().equals(layerGroup.getId())) {
            throw new IllegalArgumentException("Layer group named '" + layerGroup.getName()
                    + "' already exists.");
        }

        if (!isNew) {
View Full Code Here

        }
        return createProxyList(layerGroups, LayerGroupInfo.class);
    }

    public LayerGroupInfo getLayerGroup(String id) {
        final LayerGroupInfo layerGroup = catalogDAO.getLayerGroup(id);
        if (layerGroup != null) {
            resolve(layerGroup);
            return createProxy(layerGroup, LayerGroupInfo.class);
        } else
            return null;
View Full Code Here

            return null;

    }

    public LayerGroupInfo getLayerGroupByName(String name) {
        LayerGroupInfo layerGroup = catalogDAO.getLayerGroupByName(name);
        if (layerGroup != null) {
            resolve(layerGroup);
            return createProxy(layerGroup, LayerGroupInfo.class);
        } else
            return null;
View Full Code Here

        catalog.add(ns);

        LayerInfo layer1 = createLayer(ws, "cs1", "cov1", "ncov1", "test coverage 1", "testlayer1");
        LayerInfo layer2 = createLayer(ws, "cs2", "cov2", "ncov2", "test coverage 2", "testlayer2");

        LayerGroupInfo layerGroupInfo = catalog.getFactory().createLayerGroup();
        layerGroupInfo.setName("TestLayerGroup");
        layerGroupInfo.getLayers().add(layer1);
        layerGroupInfo.getLayers().add(layer2);

        ReferencedEnvelope re = new ReferencedEnvelope(10, 20, -20, -10, DefaultGeographicCRS.WGS84);
        layerGroupInfo.setBounds(re);

        catalog.add(layerGroupInfo);

        endTransaction();
        startNewTransaction();

        LayerGroupInfo reloaded = catalog.getLayerGroup(layerGroupInfo.getId());
        assertNotNull(reloaded);

        ReferencedEnvelope reReloaded = reloaded.getBounds();
        assertNotNull(reReloaded);
        assertEquals(re.getMinX(), reReloaded.getMinX());
    }
View Full Code Here

        catalog.add(ns);

        LayerInfo layer1 = createLayer(ws, "cs1", "cov1", "ncov1", "test coverage 1", "testlayer1");
        LayerInfo layer2 = createLayer(ws, "cs2", "cov2", "ncov2", "test coverage 2", "testlayer2");

        LayerGroupInfo layerGroupInfo = catalog.getFactory().createLayerGroup();
        layerGroupInfo.setName("TestLayerGroup_SAVE_UPDATE");
        layerGroupInfo.getLayers().add(layer1);
        layerGroupInfo.getLayers().add(layer2);

        ReferencedEnvelope re = new ReferencedEnvelope(10, 20, -20, -10, DefaultGeographicCRS.WGS84);
        layerGroupInfo.setBounds(re);

        StyleInfo style = catalog.getFactory().createStyle();
        style.setName("style_test");
        style.setFilename("style_test");
        catalog.add(style);

        layerGroupInfo.getStyles().add(style);
        layerGroupInfo.getStyles().add(null);

        catalog.add(layerGroupInfo);

        assertEquals(2, layerGroupInfo.getStyles().size());

        endTransaction();

        {
            startNewTransaction();

            LayerGroupInfo reloaded = catalog.getLayerGroup(layerGroupInfo.getId());
            assertNotNull(reloaded);

            assertEquals("Styles has not been saved", 2, reloaded.getStyles().size());

            reloaded.getLayers().remove(1);
            reloaded.getStyles().remove(1);

            assertEquals("GroupedLayer is broken", 1, reloaded.getStyles().size());
            assertEquals("GroupedLayer is broken", 1, reloaded.getLayers().size());

            LOGGER.info("A Layer was removed from the group, total should be 1 - SAVING");
            catalog.save(reloaded);
            LOGGER.info("After saving, IN transaction, 1 expected:  " + reloaded);
            endTransaction();
            LOGGER.info("After saving, OUT transaction, 1 expected: " + reloaded);

            assertEquals(layerGroupInfo.getId(), reloaded.getId());
            assertFalse(layerGroupInfo == reloaded);
        }


        {
            startNewTransaction();
            LayerGroupInfo reloaded2 = catalog.getLayerGroup(layerGroupInfo.getId());
            assertNotNull(reloaded2);

            assertEquals("GroupedLayer remove/update is broken", 1, reloaded2.getStyles().size());
            assertEquals("GroupedLayer remove/update is broken", 1, reloaded2.getLayers().size());

            endTransaction();
            startNewTransaction();

            reloaded2.getLayers().add(layer2);
            reloaded2.getStyles().add(null);

            LOGGER.info("A Layer was added to the group, total should be 2 - SAVING");
            catalog.save(reloaded2);
            LOGGER.info("After saving, IN transaction, 2 expected:  " + reloaded2);
            endTransaction();
            LOGGER.info("After saving, OUT transaction, 2 expected: " + reloaded2);
        }

        {
            startNewTransaction();

            LayerGroupInfo reloaded3 = catalog.getLayerGroup(layerGroupInfo.getId());
            assertNotNull(reloaded3);

            assertEquals("GroupedLayer add/update is broken", 2, reloaded3.getStyles().size());
            assertEquals("GroupedLayer add/update is broken", 2, reloaded3.getLayers().size());
        }

    }
View Full Code Here

        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
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.LayerGroupInfo

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.