Package org.geoserver.catalog

Examples of org.geoserver.catalog.FeatureTypeInfo


                    namespaceURI = catalog.getDefaultNamespace().getURI();
                }

                LOGGER.fine("Locating FeatureSource uri:'" + namespaceURI + "' name:'" + name + "'");

                final FeatureTypeInfo meta = catalog.getFeatureTypeByName(namespaceURI, name);

                if (meta == null) {
                    String msg = "Feature type '" + name + "' is not available: ";
                    String handle = (String) EMFUtils.get(element, "handle");
                    throw new WFSTransactionException(msg, (String) null, handle);
                }

                featureTypeInfos.put(typeName, meta);
            }

            // check element validity
            handler.checkValidity(element, featureTypeInfos);

            // go through all feature type infos data objects, and load feature
            // stores
            for (Iterator m = featureTypeInfos.values().iterator(); m.hasNext();) {
                FeatureTypeInfo meta = (FeatureTypeInfo) m.next();
                String typeRef = meta.getStore().getName() + ":" + meta.getName();

                String URI = meta.getNamespace().getURI();
                QName elementName = new QName(URI, meta.getName(),
                        meta.getNamespace().getPrefix());
                QName elementNameDefault = null;

                if (catalog.getDefaultNamespace().getURI().equals(URI)) {
                    elementNameDefault = new QName(meta.getName());
                }

                LOGGER.fine("located FeatureType w/ typeRef '" + typeRef + "' and elementName '"
                    + elementName + "'");

                if (stores.containsKey(elementName)) {
                    // typeName already loaded
                    continue;
                }

                try {
                    FeatureSource<? extends FeatureType, ? extends Feature> source = meta.getFeatureSource(null,null);

                    if (source instanceof FeatureStore) {
                        FeatureStore<? extends FeatureType, ? extends Feature> store;
                        store = (FeatureStore<? extends FeatureType, ? extends Feature>) source;
                        store.setTransaction(transaction);
View Full Code Here


    public void testRelativeToFeatureType() throws IOException {
      
        Object source = tl.findTemplateSource( "dummy.ftl");
        assertNull(source);
       
        FeatureTypeInfo ft = cat.getFeatureTypeByName( "PrimitiveGeoFeature");
        dd.copyToResourceDir( ft, template(), "dummy.ftl");
        tl.setFeatureType( ft );
       
        source = tl.findTemplateSource( "dummy.ftl");
        assertNotNull(source);
View Full Code Here

    }
   
    public void testRelativeToStore() throws IOException {
        assertNull(tl.findTemplateSource( "dummy.ftl"));
       
        FeatureTypeInfo ft = cat.getFeatureTypeByName( "PrimitiveGeoFeature");
        tl.setFeatureType( ft );
        assertNull(tl.findTemplateSource( "dummy.ftl"));
       
        dd.copyToStoreDir( ft.getStore(), template(), "dummy.ftl");
        assertNotNull(tl.findTemplateSource( "dummy.ftl"));
    }
View Full Code Here

    }
   
    public void testRelativeToWorkspace() throws IOException {
        assertNull(tl.findTemplateSource( "dummy.ftl"));
       
        FeatureTypeInfo ft = cat.getFeatureTypeByName( "PrimitiveGeoFeature");
        tl.setFeatureType( ft );
        assertNull(tl.findTemplateSource( "dummy.ftl"));
       
        dd.copyToWorkspaceDir( ft.getStore().getWorkspace(), template(), "dummy.ftl");
        assertNotNull(tl.findTemplateSource( "dummy.ftl"));
    }
View Full Code Here

                       
                        //load feature types
                        for ( File ftd : list(sd,DirectoryFileFilter.INSTANCE) ) {
                            f = new File( ftd, "featuretype.xml" );
                            if( f.exists() ) {
                                FeatureTypeInfo ft = null;
                                try {
                                    ft = depersist(xp,f,FeatureTypeInfo.class);
                                }
                                catch( Exception e ) {
                                    LOGGER.log( Level.WARNING, "Failed to load feature type '" + ftd.getName() +"'", e);
                                    continue;
                                }
                               
                                catalog.add( ft );
                               
                                LOGGER.info( "Loaded feature type '" + ds.getName() +"'");
                               
                                f = new File( ftd, "layer.xml" );
                                if ( f.exists() ) {
                                    try {
                                        LayerInfo l = depersist(xp, f, LayerInfo.class );
                                        catalog.add( l );
                                       
                                        LOGGER.info( "Loaded layer '" + l.getName() + "'" );
                                    }
                                    catch( Exception e ) {
                                        LOGGER.log( Level.WARNING, "Failed to load layer for feature type '" + ft.getName() +"'", e);
                                    }
                                }
                            }
                            else {
                                LOGGER.warning( "Ignoring feature type directory " + ftd.getAbsolutePath() );
View Full Code Here

                List types = (List) entry.getValue();

                StringBuffer typeNames = new StringBuffer();
                String namespaceURI;
                for (Iterator t = types.iterator(); t.hasNext();) {
                    FeatureTypeInfo info = (FeatureTypeInfo) t.next();
                    FeatureType featureType = info.getFeatureType();
                    Object schemaUri = featureType.getUserData().get("schemaURI");
                    if (schemaUri != null) {
                        // should always be a string.. set in AppSchemaDataAccessConfigurator
                        assert schemaUri instanceof String;
                        // schema is supplied by the user.. just import the top level schema instead of
                        // building
                        // the type
                        namespaceURI = featureType.getName().getNamespaceURI();

                        addImport(schema, factory, namespaceURI,
                                (String) schemaUri, importedNamespaces);

                        // ensure there's only 1 import per namespace
                        importedNamespaces.add(namespaceURI);

                    } else {
                        typeNames.append(info.getPrefixedName()).append(",");
                    }
                }
                if (typeNames.length() > 0) {
                    typeNames.setLength(typeNames.length()-1);
                   
View Full Code Here

    public XSDSchema addApplicationTypes( XSDSchema wfsSchema ) throws IOException {
        //incorporate application schemas into the wfs schema
        Collection featureTypeInfos = catalog.getFeatureTypes();

        for (Iterator i = featureTypeInfos.iterator(); i.hasNext();) {
            FeatureTypeInfo meta = (FeatureTypeInfo) i.next();
           
            // don't build schemas for disabled feature types
            if(!meta.enabled())
                continue;

            //build the schema for the types in the single namespace
            XSDSchema schema = build(new FeatureTypeInfo[] { meta }, null);

            //declare the namespace
            String prefix = meta.getNamespace().getPrefix();
            String namespaceURI = meta.getNamespace().getURI();
            wfsSchema.getQNamePrefixToNamespaceMap().put(prefix, namespaceURI);

            //add the types + elements to the wfs schema
            for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext();) {
                wfsSchema.getTypeDefinitions().add(t.next());
View Full Code Here

        NamespaceInfo ns = catalog.getFactory().createNamespace();
        ns.setPrefix( "bar" );
        ns.setURI( "http://bar" );
        catalog.add( ns );
       
        FeatureTypeInfo ft = catalog.getFactory().createFeatureType();
        ft.setName( "foo" );
        ft.setNamespace( ns );
        ft.setStore( catalog.getDataStoreByName( "acme", "foostore"));
        catalog.add( ft );
       
        assertTrue( d.exists() );
    }
View Full Code Here

    }
   
    public void testModifyFeatureType() throws Exception {
        testAddFeatureType();
       
        FeatureTypeInfo ft = catalog.getFeatureTypeByName( "bar", "foo" );
        ft.setTitle( "fooTitle" );
        catalog.save( ft );
       
        File f = new File( testData.getDataDirectoryRoot(),
            "workspaces/acme/foostore/foo/featuretype.xml");
        Document dom = dom( f );
View Full Code Here

       
        File d = new File( testData.getDataDirectoryRoot(),
        "workspaces/acme/foostore/foo");
        assertTrue( d.exists() );
       
        FeatureTypeInfo ft = catalog.getFeatureTypeByName( "bar", "foo" );
        catalog.remove( ft );
       
        assertFalse( d.exists() );
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.FeatureTypeInfo

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.