Search in sources :

Example 1 with ProcessMethodType

use of org.geotoolkit.sml.xml.v100.ProcessMethodType 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

StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Marshaller (javax.xml.bind.Marshaller)1 ComponentList (org.geotoolkit.sml.xml.v100.ComponentList)1 ComponentPropertyType (org.geotoolkit.sml.xml.v100.ComponentPropertyType)1 ComponentType (org.geotoolkit.sml.xml.v100.ComponentType)1 IoComponentPropertyType (org.geotoolkit.sml.xml.v100.IoComponentPropertyType)1 MethodPropertyType (org.geotoolkit.sml.xml.v100.MethodPropertyType)1 ObjectFactory (org.geotoolkit.sml.xml.v100.ObjectFactory)1 OutputList (org.geotoolkit.sml.xml.v100.OutputList)1 Outputs (org.geotoolkit.sml.xml.v100.Outputs)1 ProcessMethodType (org.geotoolkit.sml.xml.v100.ProcessMethodType)1 AbstractDataRecordType (org.geotoolkit.swe.xml.v100.AbstractDataRecordType)1 BooleanType (org.geotoolkit.swe.xml.v100.BooleanType)1 DataComponentPropertyType (org.geotoolkit.swe.xml.v100.DataComponentPropertyType)1 DataRecordType (org.geotoolkit.swe.xml.v100.DataRecordType)1 QuantityType (org.geotoolkit.swe.xml.v100.QuantityType)1 TimeType (org.geotoolkit.swe.xml.v100.TimeType)1 UomPropertyType (org.geotoolkit.swe.xml.v100.UomPropertyType)1