Package org.geoserver.catalog

Examples of org.geoserver.catalog.StyleInfo


            return true;
        if (obj == null)
            return false;
        if (!(obj instanceof StyleInfo))
            return false;
        final StyleInfo other = (StyleInfo) obj;
        if (filename == null) {
            if (other.getFilename() != null)
                return false;
        } else if (!filename.equals(other.getFilename()))
            return false;
        if (id == null) {
            if (other.getId() != null)
                return false;
        } else if (!id.equals(other.getId()))
            return false;
        if (name == null) {
            if (other.getName() != null)
                return false;
        } else if (!name.equals(other.getName()))
            return false;
        if (sldVersion == null) {
            if (other.getSLDVersion() != null)
                return false;
        } else if (!sldVersion.equals(other.getSLDVersion()))
            return false;

        return true;
    }
View Full Code Here


                }
                layer.setType(LayerInfo.Type.VECTOR);
              
                String defaultStyleName = ftInfoReader.defaultStyle();
                if ( defaultStyleName != null ) {
                    StyleInfo style = catalog.getStyleByName(defaultStyleName);
                    if ( style != null ) {
                        layer.setDefaultStyle(style);
                    }
                }
                List<String> styles = ftInfoReader.styles();
                if(styles != null) {
                    for (String styleName : styles) {
                        StyleInfo style = catalog.getStyleByName(styleName);
                        if ( style != null ) {
                            layer.getStyles().add(style);
                        }
                    }
                }
               
                Map legendURL = ftInfoReader.legendURL();
                if( legendURL != null ) {
                    LegendInfo legend = factory.createLegend();
                    legend.setHeight( (Integer) legendURL.get( "height" ) );
                    legend.setWidth( (Integer) legendURL.get( "width" ) );
                    legend.setFormat( (String) legendURL.get( "format" ) );
                    legend.setOnlineResource( (String) legendURL.get( "onlineResource" ) );
                    layer.setLegend( legend );
                }
               
                layer.setEnabled(featureType.isEnabled());
                catalog.add(layer);
            } catch( Exception e ) {
                LOGGER.warning( "Error loadin '" + featureTypeDirectory.getName() + "/info.xml', ignoring" );
                LOGGER.log( Level.INFO, "", e );
                continue;
            }
        }
       
        // for each coverage definition in coverage, read it
        File coverages = new File(dir, "coverages");
        if(!coverages.exists())
            coverages.mkdir();
        File[] coverageDirectories = coverages.listFiles();
        for (int i = 0; i < coverageDirectories.length; i++) {
            File coverageDirectory = coverageDirectories[i];
            if (!coverageDirectory.isDirectory() || coverageDirectory.isHidden())
                continue;

            // load info.xml
            File cInfoFile = new File(coverageDirectory, "info.xml");
            if (!cInfoFile.exists()) {
                LOGGER.fine("No info.xml found in directory: '" + coverageDirectory.getName() "', ignoring");
                continue;
            }

            LegacyCoverageInfoReader cInfoReader = new LegacyCoverageInfoReader();
            try {
                cInfoReader.read(cInfoFile);
   
                CoverageInfo coverage = readCoverage(cInfoReader);
                if ( coverage == null ) {
                    continue;
                }
                catalog.add(coverage);
   
                // create a wms layer for the feature type
                LayerInfo layer = factory.createLayer();
                layer.setResource(coverage);
                layer.setName(coverage.getName());
                layer.setPath(cInfoReader.wmsPath());
                if ( layer.getPath() == null ) {
                    layer.setPath( "/" );
                }
                layer.setType(LayerInfo.Type.RASTER);
               
                String defaultStyleName = cInfoReader.defaultStyle();
                if ( defaultStyleName != null ) {
                    StyleInfo style = catalog.getStyleByName(defaultStyleName);
                    if ( style != null ) {
                        layer.setDefaultStyle(style);
                    }
                }
                List<String> styles = cInfoReader.styles();
                if(styles != null) {
                    for (String styleName : styles) {
                        StyleInfo style = catalog.getStyleByName(styleName);
                        if ( style != null ) {
                            layer.getStyles().add(style);
                        }
                    }
                }
View Full Code Here

     * @param styles
     */
    void importStyles(CatalogFactory factory, Map styles) {
        for (Iterator s = styles.entrySet().iterator(); s.hasNext();) {
            Map.Entry entry = (Map.Entry) s.next();
            StyleInfo style = factory.createStyle();
            style.setName((String) entry.getKey());
            style.setFilename((String)entry.getValue());
           
            catalog.add(style);
            LOGGER.info( "Loaded style '" + style.getName() + "'" );
        }
    }
View Full Code Here

                // in the future (when we add support for that)
            } else {
                // add the layer style
                start("Style");

                StyleInfo defaultStyle = layer.getDefaultStyle();
                if (defaultStyle == null) {
                    throw new NullPointerException("Layer " + layer.getName()
                            + " has no default style");
                }
                Style ftStyle;
                try {
                    ftStyle = defaultStyle.getStyle();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                element("Name", defaultStyle.getName());
                element("Title", ftStyle.getTitle());
                element("Abstract", ftStyle.getAbstract());
                handleLegendURL(layer.getName(), layer.getLegend(), null);
                end("Style");
View Full Code Here

      /* Check if it's feature type or coverage */
      if (obj instanceof CoverageInfo) {
        CoverageInfo cvInfo;
        cvInfo = (CoverageInfo) obj;
       
        StyleInfo defaultStyle = layerInfo.getDefaultStyle();
        RasterSymbolizer rasterSymbolizer = getRasterSymbolizer(defaultStyle);
       
        if (rasterSymbolizer == null) {
          throw new RestletException( "RasterSymbolizer SLD expected!", Status.CLIENT_ERROR_EXPECTATION_FAILED);
        }
View Full Code Here

   
    @Override
    public void testGetStyleById() {
        addStyle();
       
        StyleInfo s2 = catalog.getStyle( s.getId() );
        assertNotNull( s2 );
        assertEquals(s,s2);
    }
View Full Code Here

   
    @Override
    public void testGetStyleByName() {
        addStyle();
       
        StyleInfo s2 = catalog.getStyleByName( s.getName() );
        assertNotNull( s2 );
        assertEquals(s,s2);
    }
View Full Code Here

    @Override
    public void testModifyStyle() {
        addStyle();
       
        StyleInfo s2 = catalog.getStyleByName( s.getName() );
        s2.setName( null );
        s2.setFilename( null );
       
        try {
            catalog.save(s2);
            fail("setting name to null should fail");
        }
        catch( Exception e ) {}
       
        s2.setName( "s2Name");
        try {
            catalog.save(s2);
            fail("setting filename to null should fail");
        }
        catch( Exception e ) {}
       
        s2.setFilename( "s2Filename");
        catalog.save( s2 );
       
        StyleInfo s3 = catalog.getStyleByName( "styleName" );
        assertNull( s3 );
       
        s3 = catalog.getStyleByName( s2.getName() );
        assertEquals( s2, s3 );
    }
View Full Code Here

        assertEquals(1, dao.getResourcesByNamespace(ns, CoverageInfo.class).size());
    }
   
    @Test
    public void testAddStyle() throws Exception {
        StyleInfo s = dao.getCatalog().getFactory().createStyle();
        s.setName("blue");
       
        dao.add(s);
       
        assertEquals(s, dao.getStyleByName("blue"));
    }
View Full Code Here

   
    @Test
    public void testModifyStyle() throws Exception {
        testAddStyle();
       
        StyleInfo st = dao.getStyleByName("blue");
        st.setName("red");
        dao.save(st);
       
        assertNull(dao.getStyleByName("blue"));
        assertNotNull(dao.getStyleByName("red"));
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.StyleInfo

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.