Search in sources :

Example 6 with TimeType

use of org.geotoolkit.swe.xml.v100.TimeType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method marshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void marshallMarshalingTest() throws Exception {
    ObjectFactory factory = new ObjectFactory();
    List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    TimeType time = new TimeType("urn:x-ogc:def:phenomenon:observationTime", new UomPropertyType(null, "urn:x-ogc:def:unit:ISO8601"));
    fields.add(new DataComponentPropertyType("time", null, time));
    QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:depth", new UomPropertyType("m", null), null);
    fields.add(new DataComponentPropertyType("depth", null, q));
    BooleanType b = new BooleanType("urn:x-ogc:def:phenomenon:BRGM:validity", null);
    fields.add(new DataComponentPropertyType("validity", null, b));
    DataRecordType outRecord = new DataRecordType(null, fields);
    IoComponentPropertyType io2 = new IoComponentPropertyType("piezoMeasurements", swe100Factory.createDataRecord(outRecord));
    OutputList outputList = new OutputList(Arrays.asList(io2));
    Outputs outputs = new Outputs(outputList);
    Marshaller marshaller = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    StringWriter sw = new StringWriter();
    marshaller.marshal(outputs, sw);
    String result = sw.toString();
    // System.out.println("result:" + result);
    ComponentType component = new ComponentType();
    ProcessMethodType process = new ProcessMethodType();
    component.setMethod(new MethodPropertyType(process));
    List<ComponentPropertyType> cpl = new ArrayList<ComponentPropertyType>();
    ComponentList cl = new ComponentList(cpl);
    sw = new StringWriter();
    marshaller.marshal(factory.createComponent(component), sw);
    result = sw.toString();
    // System.out.println("result:" + result);
    SensorMLMarshallerPool.getInstance().recycle(marshaller);
}
Also used : DataRecordType(org.geotoolkit.swe.xml.v100.DataRecordType) AbstractDataRecordType(org.geotoolkit.swe.xml.v100.AbstractDataRecordType) Marshaller(javax.xml.bind.Marshaller) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v100.ComponentPropertyType) ArrayList(java.util.ArrayList) BooleanType(org.geotoolkit.swe.xml.v100.BooleanType) ComponentList(org.geotoolkit.sml.xml.v100.ComponentList) ProcessMethodType(org.geotoolkit.sml.xml.v100.ProcessMethodType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) MethodPropertyType(org.geotoolkit.sml.xml.v100.MethodPropertyType) TimeType(org.geotoolkit.swe.xml.v100.TimeType) UomPropertyType(org.geotoolkit.swe.xml.v100.UomPropertyType) ObjectFactory(org.geotoolkit.sml.xml.v100.ObjectFactory) StringWriter(java.io.StringWriter) QuantityType(org.geotoolkit.swe.xml.v100.QuantityType) Outputs(org.geotoolkit.sml.xml.v100.Outputs) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) OutputList(org.geotoolkit.sml.xml.v100.OutputList)

Aggregations

DataRecordType (net.opengis.swe.x20.DataRecordType)4 TimeType (net.opengis.swe.x20.TimeType)4 BooleanType (net.opengis.swe.x20.BooleanType)3 CategoryType (net.opengis.swe.x20.CategoryType)3 CountRangeType (net.opengis.swe.x20.CountRangeType)3 CountType (net.opengis.swe.x20.CountType)3 DataArrayType (net.opengis.swe.x20.DataArrayType)3 QuantityRangeType (net.opengis.swe.x20.QuantityRangeType)3 QuantityType (net.opengis.swe.x20.QuantityType)3 TextType (net.opengis.swe.x20.TextType)3 TimeRangeType (net.opengis.swe.x20.TimeRangeType)3 VectorType (net.opengis.swe.x20.VectorType)3 ArrayList (java.util.ArrayList)2 CategoryRangeType (net.opengis.swe.x20.CategoryRangeType)2 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)2 DataChoiceType (net.opengis.swe.x20.DataChoiceType)2 DataRecordDocument (net.opengis.swe.x20.DataRecordDocument)2 MatrixType (net.opengis.swe.x20.MatrixType)2 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)2 InputStream (java.io.InputStream)1