Search in sources :

Example 1 with EnhancedStaxDriver

use of org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.EnhancedStaxDriver in project ddf by codice.

the class TestGenericFeatureConverter method testMetacardCollectionToFeatureCollectionXml.

@Test
public void testMetacardCollectionToFeatureCollectionXml() {
    XStream xstream = new XStream(new EnhancedStaxDriver());
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.registerConverter(new FeatureCollectionConverterWfs10());
    xstream.registerConverter(new GenericFeatureConverter());
    xstream.registerConverter(new GmlGeometryConverter());
    // Required the Implementing class. The interface would not work...
    xstream.alias("wfs:FeatureCollection", WfsFeatureCollection.class);
    Metacard mc = new SampleMetacard().getMetacard();
    WfsFeatureCollection wfc = new WfsFeatureCollection();
    wfc.getFeatureMembers().add(mc);
    MetacardImpl mc2 = new SampleMetacard().getMetacard();
    // Ignore the hack stuff, this was just to imitate having two different
    // "MetacardTypes"
    mc2.setType(new MetacardType() {

        @Override
        public String getName() {
            return "otherType";
        }

        @Override
        public Set<AttributeDescriptor> getAttributeDescriptors() {
            return BasicTypes.BASIC_METACARD.getAttributeDescriptors();
        }

        @Override
        public AttributeDescriptor getAttributeDescriptor(String arg0) {
            return BasicTypes.BASIC_METACARD.getAttributeDescriptor(arg0);
        }
    });
    wfc.getFeatureMembers().add(mc2);
    xstream.toXML(wfc);
}
Also used : Set(java.util.Set) GmlGeometryConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter) XStream(com.thoughtworks.xstream.XStream) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) MetacardType(ddf.catalog.data.MetacardType) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Metacard(ddf.catalog.data.Metacard) GenericFeatureConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter) EnhancedStaxDriver(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.EnhancedStaxDriver) WfsFeatureCollection(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection) Test(org.junit.Test)

Example 2 with EnhancedStaxDriver

use of org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.EnhancedStaxDriver in project ddf by codice.

the class TestGenericFeatureConverter method testMetacardCollectionToFeatureCollectionXml.

@Test
public void testMetacardCollectionToFeatureCollectionXml() {
    XStream xstream = new XStream(new EnhancedStaxDriver());
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.registerConverter(new FeatureCollectionConverterWfs20());
    xstream.registerConverter(new GenericFeatureConverterWfs20());
    xstream.registerConverter(new GmlGeometryConverter());
    // Required the Implementing class. The interface would not work...
    xstream.alias(Wfs20Constants.WFS_NAMESPACE_PREFIX + ":" + "FeatureCollection", Wfs20FeatureCollection.class);
    Metacard mc = new SampleMetacard().getMetacard();
    Wfs20FeatureCollection wfc = new Wfs20FeatureCollection();
    wfc.getMembers().add(mc);
    MetacardImpl mc2 = new SampleMetacard().getMetacard();
    // Ignore the hack stuff, this was just to imitate having two different
    // "MetacardTypes"
    mc2.setType(new MetacardType() {

        @Override
        public String getName() {
            return "otherType";
        }

        @Override
        public Set<AttributeDescriptor> getAttributeDescriptors() {
            return BasicTypes.BASIC_METACARD.getAttributeDescriptors();
        }

        @Override
        public AttributeDescriptor getAttributeDescriptor(String arg0) {
            return BasicTypes.BASIC_METACARD.getAttributeDescriptor(arg0);
        }
    });
    wfc.getMembers().add(mc2);
    String xml = xstream.toXML(wfc);
}
Also used : Set(java.util.Set) GmlGeometryConverter(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter) XStream(com.thoughtworks.xstream.XStream) Wfs20FeatureCollection(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) MetacardType(ddf.catalog.data.MetacardType) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Metacard(ddf.catalog.data.Metacard) EnhancedStaxDriver(org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.EnhancedStaxDriver) Test(org.junit.Test)

Aggregations

XStream (com.thoughtworks.xstream.XStream)2 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)2 Metacard (ddf.catalog.data.Metacard)2 MetacardType (ddf.catalog.data.MetacardType)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2 Set (java.util.Set)2 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)2 EnhancedStaxDriver (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.EnhancedStaxDriver)2 GmlGeometryConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter)2 Test (org.junit.Test)2 WfsFeatureCollection (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsFeatureCollection)1 GenericFeatureConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GenericFeatureConverter)1 Wfs20FeatureCollection (org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection)1