Search in sources :

Example 1 with IoComponentPropertyType

use of org.geotoolkit.sml.xml.v101.IoComponentPropertyType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method ComponentUnmarshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void ComponentUnmarshallMarshalingTest() throws Exception {
    Unmarshaller unmarshaller = SensorMLMarshallerPool.getInstance().acquireUnmarshaller();
    InputStream is = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/component.xml");
    Object unmarshalled = unmarshaller.unmarshal(is);
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue(unmarshalled instanceof SensorML);
    SensorML result = (SensorML) unmarshalled;
    Member member = new Member();
    member.setRole("urn:x-ogx:def:sensor:OGC:detector");
    ComponentType component = new ComponentType();
    List<JAXBElement<String>> kw = new ArrayList<JAXBElement<String>>();
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("piezometer"));
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("geosciences"));
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("point d'eau"));
    Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-brgm:def:gcmd:keywords"), kw));
    component.setKeywords(keywords);
    Classifier cl1 = new Classifier("intendedApplication", new Term("eaux souterraines", URI.create("urn:x-ogc:def:classifier:OGC:application")));
    CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-brgm:def:GeoPoint:bss");
    Classifier cl2 = new Classifier("sensorType", new Term(cs, "Profondeur", URI.create("urn:sensor:classifier:sensorType")));
    List<Classifier> cls = new ArrayList<Classifier>();
    cls.add(cl1);
    cls.add(cl2);
    ClassifierList claList = new ClassifierList(null, cls);
    Classification classification = new Classification(claList);
    component.setClassification(classification);
    List<Identifier> identifiers = new ArrayList<Identifier>();
    cs = new CodeSpacePropertyType("urn:x-brgm:def:sensorSystem:hydras");
    Identifier id1 = new Identifier("supervisorCode", new Term(cs, "00ARGLELES_2000", URI.create("urn:x-ogc:def:identifier:OGC:modelNumber")));
    Identifier id2 = new Identifier("longName", new Term("Madofil II", URI.create("urn:x-ogc:def:identifier:OGC:longname")));
    identifiers.add(id1);
    identifiers.add(id2);
    IdentifierList identifierList = new IdentifierList(null, identifiers);
    Identification identification = new Identification(identifierList);
    component.setIdentification(identification);
    TimePeriodType period = new TimePeriodType(new TimePositionType("2004-06-01"));
    ValidTime vTime = new ValidTime(period);
    component.setValidTime(vTime);
    Capabilities capabilities = new Capabilities();
    TimeRange timeRange = new TimeRange(Arrays.asList("1987-04-23", "now"));
    DataComponentPropertyType field = new DataComponentPropertyType("periodOfData", "urn:x-brgm:def:property:periodOfData", timeRange);
    DataRecordType record = new DataRecordType("urn:x-brgm:def:property:periodOfData", Arrays.asList(field));
    JAXBElement<? extends AbstractDataRecordType> jbRecord = swe100Factory.createDataRecord(record);
    capabilities.setAbstractDataRecord(jbRecord);
    component.setCapabilities(capabilities);
    Contact contact = new Contact("urn:x-ogc:def:role:manufacturer", new ResponsibleParty("IRIS"));
    component.setContact(contact);
    Position position = new Position("conductivitePosition", "piezometer#piezoPosition");
    component.setPosition(position);
    IoComponentPropertyType io = new IoComponentPropertyType("level", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:level"));
    InputList inputList = new InputList(Arrays.asList(io));
    Inputs inputs = new Inputs(inputList);
    component.setInputs(inputs);
    IoComponentPropertyType io2 = new IoComponentPropertyType("depth", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:depth"));
    OutputList outputList = new OutputList(Arrays.asList(io2));
    Outputs outputs = new Outputs(outputList);
    component.setOutputs(outputs);
    List<DataComponentPropertyType> params = new ArrayList<DataComponentPropertyType>();
    UomPropertyType uom = new UomPropertyType(null, "urn:ogc:unit:minuts");
    QuantityType quantity1 = new QuantityType("urn:x-ogc:def:property:frequency", uom, 60.0);
    DataComponentPropertyType p1 = new DataComponentPropertyType("frequency", "urn:x-ogc:def:property:frequency", quantity1);
    params.add(p1);
    UomPropertyType uom2 = new UomPropertyType("m", null);
    QuantityType quantity2 = new QuantityType("urn:x-ogc:def:property:precision", uom2, 0.05);
    DataComponentPropertyType p2 = new DataComponentPropertyType("precision", "urn:x-ogc:def:property:precision", quantity2);
    params.add(p2);
    QuantityRange quantityRange = new QuantityRange(uom2, Arrays.asList(0.0, 10.0));
    DataComponentPropertyType p3 = new DataComponentPropertyType("validity", "urn:x-ogc:def:property:validity", quantityRange);
    params.add(p3);
    ParameterList paramList = new ParameterList(params);
    Parameters parameters = new Parameters(paramList);
    component.setParameters(parameters);
    component.setPosition(new Position("conductivitePosition", "piezometer#piezoPosition"));
    component.setName(new DefaultIdentifier("Capteur Profondeur de ARGELES"));
    member.setProcess(sml100Factory.createComponent(component));
    SensorML expectedResult = new SensorML("1.0", Arrays.asList(member));
    assertEquals(result.getMember().size(), 1);
    assertTrue(result.getMember().get(0).getProcess() != null);
    assertTrue(result.getMember().get(0).getProcess().getValue() instanceof ComponentType);
    ComponentType resultProcess = (ComponentType) result.getMember().get(0).getProcess().getValue();
    assertEquals(resultProcess.getCapabilities(), component.getCapabilities());
    assertTrue(resultProcess.getContact().size() == 1);
    assertEquals(resultProcess.getContact().get(0).getContactList(), component.getContact().get(0).getContactList());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getContactInfo(), component.getContact().get(0).getResponsibleParty().getContactInfo());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getOrganizationName(), component.getContact().get(0).getResponsibleParty().getOrganizationName());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty(), component.getContact().get(0).getResponsibleParty());
    assertEquals(resultProcess.getContact().get(0), component.getContact().get(0));
    assertEquals(resultProcess.getContact(), component.getContact());
    assertTrue(resultProcess.getClassification().size() == 1);
    assertTrue(resultProcess.getClassification().get(0).getClassifierList().getClassifier().size() == 2);
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm(), component.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0), component.getClassification().get(0).getClassifierList().getClassifier().get(0));
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier(), component.getClassification().get(0).getClassifierList().getClassifier());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList(), component.getClassification().get(0).getClassifierList());
    assertEquals(resultProcess.getClassification().get(0), component.getClassification().get(0));
    assertEquals(resultProcess.getClassification(), component.getClassification());
    assertEquals(resultProcess.getIdentification(), component.getIdentification());
    assertEquals(resultProcess.getValidTime(), component.getValidTime());
    assertEquals(resultProcess.getParameters(), component.getParameters());
    assertEquals(resultProcess.getInputs().getInputList().getInput(), component.getInputs().getInputList().getInput());
    assertEquals(resultProcess.getInputs().getInputList(), component.getInputs().getInputList());
    assertEquals(resultProcess.getInputs(), component.getInputs());
    assertEquals(resultProcess.getOutputs(), component.getOutputs());
    assertEquals(resultProcess.getSMLLocation(), component.getSMLLocation());
    assertEquals(resultProcess.getPosition(), component.getPosition());
    assertEquals(resultProcess.getSpatialReferenceFrame(), component.getSpatialReferenceFrame());
    assertEquals(resultProcess.getDocumentation(), component.getDocumentation());
    assertEquals(resultProcess.getCharacteristics(), component.getCharacteristics());
    assertEquals(resultProcess.getKeywords(), component.getKeywords());
    assertEquals(resultProcess.getParameters(), component.getParameters());
    assertEquals(resultProcess.getName(), component.getName());
    assertEquals(resultProcess, component);
    assertEquals(expectedResult.getMember().get(0), result.getMember().get(0));
    assertEquals(expectedResult.getMember(), result.getMember());
    assertEquals(expectedResult, result);
    SensorMLMarshallerPool.getInstance().recycle(unmarshaller);
}
Also used : DataRecordType(org.geotoolkit.swe.xml.v100.DataRecordType) AbstractDataRecordType(org.geotoolkit.swe.xml.v100.AbstractDataRecordType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) InputList(org.geotoolkit.sml.xml.v100.InputList) ArrayList(java.util.ArrayList) Identification(org.geotoolkit.sml.xml.v100.Identification) Classifier(org.geotoolkit.sml.xml.v100.Classifier) IdentifierList(org.geotoolkit.sml.xml.v100.IdentifierList) ValidTime(org.geotoolkit.sml.xml.v100.ValidTime) UomPropertyType(org.geotoolkit.swe.xml.v100.UomPropertyType) Identifier(org.geotoolkit.sml.xml.v100.Identifier) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) ObservableProperty(org.geotoolkit.swe.xml.v100.ObservableProperty) Classification(org.geotoolkit.sml.xml.v100.Classification) CodeSpacePropertyType(org.geotoolkit.swe.xml.v100.CodeSpacePropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Unmarshaller(javax.xml.bind.Unmarshaller) Member(org.geotoolkit.sml.xml.v100.Member) Inputs(org.geotoolkit.sml.xml.v100.Inputs) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) Parameters(org.geotoolkit.sml.xml.v100.Parameters) Position(org.geotoolkit.sml.xml.v100.Position) InputStream(java.io.InputStream) ClassifierList(org.geotoolkit.sml.xml.v100.ClassifierList) QuantityRange(org.geotoolkit.swe.xml.v100.QuantityRange) JAXBElement(javax.xml.bind.JAXBElement) Term(org.geotoolkit.sml.xml.v100.Term) ResponsibleParty(org.geotoolkit.sml.xml.v100.ResponsibleParty) SensorML(org.geotoolkit.sml.xml.v100.SensorML) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) Contact(org.geotoolkit.sml.xml.v100.Contact) TimeRange(org.geotoolkit.swe.xml.v100.TimeRange) TimePeriodType(org.geotoolkit.gml.xml.v311.TimePeriodType) QuantityType(org.geotoolkit.swe.xml.v100.QuantityType) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) KeywordList(org.geotoolkit.sml.xml.v100.KeywordList) Outputs(org.geotoolkit.sml.xml.v100.Outputs) ParameterList(org.geotoolkit.sml.xml.v100.ParameterList) OutputList(org.geotoolkit.sml.xml.v100.OutputList)

Example 2 with IoComponentPropertyType

use of org.geotoolkit.sml.xml.v101.IoComponentPropertyType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method SystemUnmarshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void SystemUnmarshallMarshalingTest() throws Exception {
    Unmarshaller unmarshaller = SensorMLMarshallerPool.getInstance().acquireUnmarshaller();
    InputStream is = SmlXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/sml/system.xml");
    Object unmarshalled = unmarshaller.unmarshal(is);
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue(unmarshalled instanceof SensorML);
    SensorML result = (SensorML) unmarshalled;
    Member member = new Member();
    member.setRole("urn:x-ogx:def:sensor:OGC:detector");
    SystemType system = new SystemType();
    List<JAXBElement<String>> kw = new ArrayList<JAXBElement<String>>();
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("piezometer"));
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("geosciences"));
    kw.add(sml100Factory.createKeywordsKeywordListKeyword("point d'eau"));
    Keywords keywords = new Keywords(new KeywordList(URI.create("urn:x-brgm:def:gcmd:keywords"), kw));
    system.setKeywords(keywords);
    Classifier cl1 = new Classifier("intendedApplication", new Term("eaux souterraines", URI.create("urn:x-ogc:def:classifier:OGC:application")));
    CodeSpacePropertyType cs = new CodeSpacePropertyType("urn:x-brgm:def:GeoPoint:bss");
    Classifier cl2 = new Classifier("sensorType", new Term(cs, "piezometer", URI.create("urn:sensor:classifier:sensorType")));
    CodeSpacePropertyType cs3 = new CodeSpacePropertyType("urn:x-sandre:def:mdo:identifier");
    Classifier cl3 = new Classifier("waterBody", new Term(cs3, "FR6221", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs4 = new CodeSpacePropertyType("urn:x-sandre:def:mdo:name");
    Classifier cl4 = new Classifier("waterBody", new Term(cs4, "Multicouche pliocene et alluvions quaternaires du Roussillon", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs5 = new CodeSpacePropertyType("urn:x-sandre:def:bdhrf:identifier");
    Classifier cl5 = new Classifier("hydrologicalEntity", new Term(cs5, "225", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs6 = new CodeSpacePropertyType("urn:x-sandre:def:bdhrf:name");
    Classifier cl6 = new Classifier("hydrologicalEntity", new Term(cs6, "Pliocene du Roussillon", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs7 = new CodeSpacePropertyType("urn:x-insee:def:commune:identifier");
    Classifier cl7 = new Classifier("commune", new Term(cs7, "66008", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs8 = new CodeSpacePropertyType("urn:x-insee:def:commune:name");
    Classifier cl8 = new Classifier("commune", new Term(cs8, "ARGELES SUR MER", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs9 = new CodeSpacePropertyType("urn:x-sandre:def:network:identifier");
    Classifier cl9 = new Classifier("network", new Term(cs9, "600000221", URI.create("urn:sensor:classifier:references")));
    CodeSpacePropertyType cs10 = new CodeSpacePropertyType("urn:x-sandre:def:network:identifier");
    Classifier cl10 = new Classifier("network", new Term(cs10, "600000025", URI.create("urn:sensor:classifier:references")));
    List<Classifier> cls = new ArrayList<Classifier>();
    cls.add(cl1);
    cls.add(cl2);
    cls.add(cl3);
    cls.add(cl4);
    cls.add(cl5);
    cls.add(cl6);
    cls.add(cl7);
    cls.add(cl8);
    cls.add(cl9);
    cls.add(cl10);
    ClassifierList claList = new ClassifierList(null, cls);
    Classification classification = new Classification(claList);
    system.setClassification(classification);
    List<Identifier> identifiers = new ArrayList<Identifier>();
    cs = new CodeSpacePropertyType("urn:x-brgm:def:samplingStation:bss");
    Identifier id1 = new Identifier("bssCode", new Term(cs, "10972X0137/PONT", URI.create("urn:x-ogc:def:identifier:OGC:modelNumber")));
    cs = new CodeSpacePropertyType("urn:x-brgm:def:sensorSystem:hydras");
    Identifier id2 = new Identifier("supervisorCode", new Term(cs, "00ARGLELES", URI.create("urn:x-ogc:def:identifier:OGC:modelNumber")));
    Identifier id3 = new Identifier("longName", new Term("ARGELES", URI.create("urn:x-ogc:def:identifier:OGC:longname")));
    identifiers.add(id1);
    identifiers.add(id2);
    identifiers.add(id3);
    IdentifierList identifierList = new IdentifierList(null, identifiers);
    Identification identification = new Identification(identifierList);
    system.setIdentification(identification);
    Capabilities capabilities = new Capabilities();
    List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    QuantityType quantity = new QuantityType("urn:x-ogc:def:property:temperature", new UomPropertyType(null, "urn:ogc:unit:degree:celsius"), 0.1);
    DataComponentPropertyType field1 = new DataComponentPropertyType("resolution", "urn:x-ogc:def:property:resolution", quantity);
    fields.add(field1);
    QuantityRange quantityR = new QuantityRange(new UomPropertyType(null, "urn:ogc:unit:percent"), Arrays.asList(-0.5, 0.5));
    quantityR.setDefinition("urn:x-ogc:def:property:absoluteAccuracy");
    DataComponentPropertyType field2 = new DataComponentPropertyType("accuracy", "urn:x-ogc:def:property:accuracy", quantityR);
    fields.add(field2);
    DataRecordType record = new DataRecordType("urn:x-ogc:def:property:measurementProperties", fields);
    record.setDescription("Toutes les informations sur les  contraintes sur les donnees");
    JAXBElement<? extends AbstractDataRecordType> jbRecord = swe100Factory.createDataRecord(record);
    capabilities.setAbstractDataRecord(jbRecord);
    system.setCapabilities(capabilities);
    AddressType address1 = new AddressType("SGR LRO-1039 Rue de Pinville-34000 Montpellier", "MONTPELLIER", null, null, null, "m.blaise@brgm.fr");
    ContactInfo contactInfo1 = new ContactInfo(null, address1);
    ResponsibleParty resp1 = new ResponsibleParty("BLAISE Marion (BRGM)", "BRGM", null, contactInfo1);
    Contact contact1 = new Contact("urn:x-ogc:def:role:producer", resp1);
    AddressType address2 = new AddressType("Hotel du Departement, B.P. 906, 66 906 Perpignan Cedex", "PERPIGNAN", null, null, null, null);
    ContactInfo contactInfo2 = new ContactInfo(null, address2);
    ResponsibleParty resp2 = new ResponsibleParty("ASSENS Martine (CG66)", "CONSEIL GENERAL DES PYRENEES ORIENTALES", null, contactInfo2);
    Contact contact2 = new Contact("urn:x-ogc:def:role:owner", resp2);
    system.setContact(Arrays.asList(contact1, contact2));
    IoComponentPropertyType io = new IoComponentPropertyType("level", new ObservableProperty("urn:x-ogc:def:phenomenon:OGC:level"));
    InputList inputList = new InputList(Arrays.asList(io));
    Inputs inputs = new Inputs(inputList);
    system.setInputs(inputs);
    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);
    outRecord.setId("outputGroup");
    IoComponentPropertyType io2 = new IoComponentPropertyType("piezoMeasurements", swe100Factory.createDataRecord(outRecord));
    OutputList outputList = new OutputList(Arrays.asList(io2));
    Outputs outputs = new Outputs(outputList);
    system.setOutputs(outputs);
    fields = new ArrayList<DataComponentPropertyType>();
    q = new QuantityType("urn:x-ogc:def:property:depth", new UomPropertyType(null, "urn:ogc:unit:m"), 166.0);
    fields.add(new DataComponentPropertyType("MaxDepth", null, q));
    DataRecordType charRecord = new DataRecordType(null, fields);
    List<DataComponentPropertyType> fields2 = new ArrayList<DataComponentPropertyType>();
    fields2.add(new DataComponentPropertyType("physicalProperties", null, swe100Factory.createDataRecord(charRecord)));
    DataRecordType ccharRecord = new DataRecordType("urn:x-ogc:def:property:physicalProperties", fields2);
    Characteristics characteristics = new Characteristics();
    characteristics.setAbstractDataRecord(swe100Factory.createDataRecord(ccharRecord));
    system.setCharacteristics(characteristics);
    DirectPositionType pos = new DirectPositionType("urn:ogc:crs:EPSG:27582", 2, Arrays.asList(65400.0, 1731368.0));
    PointType point = new PointType("STATION_LOCALISATION", pos);
    Location location = new Location(point);
    system.setSMLLocation(location);
    EngineeringDatumType engineeringDatum = new EngineeringDatumType("datum", "Sensor Datum", new CodeType("X, Y et Z sont orthogonal au regard d'un point de reference."));
    EngineeringDatumRefType usesEngineeringDatum = new EngineeringDatumRefType(engineeringDatum);
    EngineeringCRSType engineeringCRS = new EngineeringCRSType("STATION_FRAME", "Position absolue du capteur", new CoordinateSystemRefType("urn:ogc:def:crs:ogc:1.0:xyzFrame"), usesEngineeringDatum);
    SpatialReferenceFrame spatialReferenceFrame = new SpatialReferenceFrame(engineeringCRS);
    system.setSpatialReferenceFrame(spatialReferenceFrame);
    Document doc = new Document("Fiche descriptive de la station", "text/html", Arrays.asList(new OnlineResource("http://ades.eaufrance.fr/FichePtEau.aspx?code=10972X0137/PONT")));
    Documentation documentation = new Documentation(doc);
    documentation.setRole("urn:ogc:role:description");
    system.setDocumentation(Arrays.asList(documentation));
    List<ComponentPropertyType> compos = new ArrayList<ComponentPropertyType>();
    compos.add(new ComponentPropertyType("Profondeur", "urn:x-ogc:def:sensor:detector", "capteur_"));
    ComponentList componentList = new ComponentList(compos);
    Components components = new Components(componentList);
    system.setComponents(components);
    List<CoordinateType> coordinates = new ArrayList<CoordinateType>();
    QuantityType xQuant = new QuantityType("urn:ogc:def:phenomenon:distance", new UomPropertyType("m", null), 0.0);
    xQuant.setAxisID("X");
    CoordinateType xcoord = new CoordinateType("x", xQuant);
    QuantityType yQuant = new QuantityType("urn:ogc:def:phenomenon:distance", new UomPropertyType("m", null), 0.0);
    yQuant.setAxisID("Y");
    CoordinateType ycoord = new CoordinateType("y", yQuant);
    QuantityType zQuant = new QuantityType("urn:ogc:def:phenomenon:distance", new UomPropertyType("m", null), 0.0);
    zQuant.setAxisID("Z");
    CoordinateType zcoord = new CoordinateType("z", zQuant);
    coordinates.add(xcoord);
    coordinates.add(ycoord);
    coordinates.add(zcoord);
    VectorType vect = new VectorType("urn:ogc:def:phenomenon:location", coordinates);
    VectorPropertyType vectP = new VectorPropertyType(vect);
    PositionType Sposition = new PositionType(URI.create("#REFERENCE_POINT"), URI.create("#PIEZOMETER_FRAME"), vectP, null);
    Position position = new Position("piezoPosition", Sposition);
    PositionList positionList = new PositionList(null, Arrays.asList(position));
    Positions positions = new Positions(positionList);
    system.setPositions(positions);
    TemporalReferenceFrame temporalReferenceFrame = new TemporalReferenceFrame(new TemporalCRSType("temporalReference", null, null, "calendrier gregorien en heure d'ete", new TemporalCSRefType("urn:x-brgm:temporalCS:gregorian"), new TemporalDatumRefType("urn:x-brgm:temporalDatum:UniversalTime")));
    system.setTemporalReferenceFrame(temporalReferenceFrame);
    List<Connection> connecL = new ArrayList<Connection>();
    connecL.add(new Connection("inputTolevel", new Link(null, new LinkRef("this/inputs/level"), new LinkRef("piezometer/inputs/level"))));
    Connection c2 = new Connection("depthToOutput", new Link(null, new LinkRef("piezometer/outputs/depth"), new LinkRef("this/outputs/piezoMeasurements/depth")));
    ArrayLink alink = new ArrayLink();
    LinkRef sa = new LinkRef("piezometer/outputs/depth");
    alink.setSourceArray(sa);
    LinkRef si = new LinkRef("this/outputs/piezoMeasurements/depth");
    alink.setSourceIndex(si);
    LinkRef da = new LinkRef("this/outputs/piezoMeasurements/depth");
    alink.setDestinationArray(da);
    LinkRef di = new LinkRef("this/outputs/piezoMeasurements/depth");
    alink.getDestinationIndex().add(di);
    c2.setArrayLink(alink);
    connecL.add(c2);
    ConnectionList connectionList = new ConnectionList(connecL);
    Connections connections = new Connections(connectionList);
    system.setConnections(connections);
    LayerPropertyType applicationLayer = new LayerPropertyType(new Category("urn:ogc:def:protocol:applicationLink", "urn:x-brgm:def:protocol:hydrasIRIS"));
    LayerPropertyType dataLinkLayer = new LayerPropertyType(new Category("urn:ogc:def:protocol:dataLink", "urn:x-brgm:def:dataLink:RTC"));
    InterfaceDefinition definition = new InterfaceDefinition(null, applicationLayer, dataLinkLayer);
    Interface i1 = new Interface("RS-232", definition);
    List<Interface> interfaceL = new ArrayList<Interface>();
    interfaceL.add(i1);
    InterfaceList interfaceList = new InterfaceList(null, interfaceL);
    Interfaces interfaces = new Interfaces(interfaceList);
    system.setInterfaces(interfaces);
    Rights rights = new Rights(true, true, new Documentation(new Document("Donnees sous copyright du BRGM")));
    LegalConstraint legalConstraint = new LegalConstraint(rights);
    system.setLegalConstraint(legalConstraint);
    system.setDescription("information about the piezometer");
    system.setName(new DefaultIdentifier("Piezometer Test"));
    member.setProcess(sml100Factory.createSystem(system));
    SensorML expectedResult = new SensorML("1.0", Arrays.asList(member));
    assertEquals(result.getMember().size(), 1);
    assertTrue(result.getMember().get(0).getProcess() != null);
    assertTrue(result.getMember().get(0).getProcess().getValue() instanceof SystemType);
    SystemType resultProcess = (SystemType) result.getMember().get(0).getProcess().getValue();
    assertEquals(resultProcess.getCapabilities().size(), system.getCapabilities().size());
    assertTrue(resultProcess.getCapabilities().get(0).getAbstractDataRecord().getValue() instanceof DataRecordType);
    DataRecordType resultRecord = (DataRecordType) resultProcess.getCapabilities().get(0).getAbstractDataRecord().getValue();
    DataRecordType expRecord = (DataRecordType) system.getCapabilities().get(0).getAbstractDataRecord().getValue();
    assertEquals(resultRecord.getField().get(0), expRecord.getField().get(0));
    assertEquals(resultRecord.getField().get(1), expRecord.getField().get(1));
    assertEquals(resultRecord.getField(), expRecord.getField());
    assertEquals(resultProcess.getCapabilities().get(0).getAbstractDataRecord().getValue(), system.getCapabilities().get(0).getAbstractDataRecord().getValue());
    assertEquals(resultProcess.getCapabilities().get(0), system.getCapabilities().get(0));
    assertEquals(resultProcess.getCapabilities(), system.getCapabilities());
    assertTrue(resultProcess.getContact().size() == 2);
    assertEquals(resultProcess.getContact().get(0).getContactList(), system.getContact().get(0).getContactList());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getContactInfo(), system.getContact().get(0).getResponsibleParty().getContactInfo());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty().getOrganizationName(), system.getContact().get(0).getResponsibleParty().getOrganizationName());
    assertEquals(resultProcess.getContact().get(0).getResponsibleParty(), system.getContact().get(0).getResponsibleParty());
    assertEquals(resultProcess.getContact().get(0), system.getContact().get(0));
    assertEquals(resultProcess.getContact(), system.getContact());
    assertTrue(resultProcess.getClassification().size() == 1);
    assertTrue(resultProcess.getClassification().get(0).getClassifierList().getClassifier().size() == 10);
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm(), system.getClassification().get(0).getClassifierList().getClassifier().get(0).getTerm());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier().get(0), system.getClassification().get(0).getClassifierList().getClassifier().get(0));
    assertEquals(resultProcess.getClassification().get(0).getClassifierList().getClassifier(), system.getClassification().get(0).getClassifierList().getClassifier());
    assertEquals(resultProcess.getClassification().get(0).getClassifierList(), system.getClassification().get(0).getClassifierList());
    assertEquals(resultProcess.getClassification().get(0), system.getClassification().get(0));
    assertEquals(resultProcess.getClassification(), system.getClassification());
    assertEquals(resultProcess.getIdentification(), system.getIdentification());
    assertEquals(resultProcess.getValidTime(), system.getValidTime());
    assertEquals(resultProcess.getParameters(), system.getParameters());
    assertEquals(resultProcess.getInputs().getInputList().getInput(), system.getInputs().getInputList().getInput());
    assertEquals(resultProcess.getInputs().getInputList(), system.getInputs().getInputList());
    assertEquals(resultProcess.getInputs(), system.getInputs());
    assertEquals(resultProcess.getOutputs(), system.getOutputs());
    assertEquals(resultProcess.getSMLLocation(), system.getSMLLocation());
    assertEquals(resultProcess.getPosition(), system.getPosition());
    assertEquals(resultProcess.getSpatialReferenceFrame(), system.getSpatialReferenceFrame());
    assertEquals(resultProcess.getDocumentation(), system.getDocumentation());
    assertEquals(resultProcess.getCharacteristics(), system.getCharacteristics());
    assertEquals(resultProcess.getComponents(), system.getComponents());
    assertEquals(resultProcess.getPositions(), system.getPositions());
    assertEquals(resultProcess.getTemporalReferenceFrame(), system.getTemporalReferenceFrame());
    assertEquals(resultProcess.getConnections().getConnectionList().getConnection().get(0), system.getConnections().getConnectionList().getConnection().get(0));
    assertEquals(resultProcess.getConnections().getConnectionList().getConnection().get(1), system.getConnections().getConnectionList().getConnection().get(1));
    assertEquals(resultProcess.getConnections().getConnectionList().getConnection(), system.getConnections().getConnectionList().getConnection());
    assertEquals(resultProcess.getConnections().getConnectionList(), system.getConnections().getConnectionList());
    assertEquals(resultProcess.getConnections(), system.getConnections());
    assertEquals(resultProcess.getInterfaces(), system.getInterfaces());
    assertEquals(resultProcess.getLegalConstraint(), system.getLegalConstraint());
    assertEquals(resultProcess.getKeywords(), system.getKeywords());
    assertEquals(resultProcess.getId(), system.getId());
    assertEquals(resultProcess.getName(), system.getName());
    assertEquals(resultProcess, system);
    assertEquals(expectedResult.getMember().get(0), result.getMember().get(0));
    assertEquals(expectedResult.getMember(), result.getMember());
    assertEquals(expectedResult, result);
    SensorMLMarshallerPool.getInstance().recycle(unmarshaller);
}
Also used : Connections(org.geotoolkit.sml.xml.v100.Connections) LayerPropertyType(org.geotoolkit.sml.xml.v100.LayerPropertyType) InterfaceDefinition(org.geotoolkit.sml.xml.v100.InterfaceDefinition) ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v100.SystemType) InterfaceList(org.geotoolkit.sml.xml.v100.InterfaceList) IdentifierList(org.geotoolkit.sml.xml.v100.IdentifierList) EngineeringDatumType(org.geotoolkit.gml.xml.v311.EngineeringDatumType) Document(org.geotoolkit.sml.xml.v100.Document) Components(org.geotoolkit.sml.xml.v100.Components) VectorPropertyType(org.geotoolkit.swe.xml.v100.VectorPropertyType) Rights(org.geotoolkit.sml.xml.v100.Rights) Identifier(org.geotoolkit.sml.xml.v100.Identifier) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) ObservableProperty(org.geotoolkit.swe.xml.v100.ObservableProperty) Classification(org.geotoolkit.sml.xml.v100.Classification) ContactInfo(org.geotoolkit.sml.xml.v100.ContactInfo) Unmarshaller(javax.xml.bind.Unmarshaller) Member(org.geotoolkit.sml.xml.v100.Member) Position(org.geotoolkit.sml.xml.v100.Position) ClassifierList(org.geotoolkit.sml.xml.v100.ClassifierList) CoordinateSystemRefType(org.geotoolkit.gml.xml.v311.CoordinateSystemRefType) Documentation(org.geotoolkit.sml.xml.v100.Documentation) TemporalCRSType(org.geotoolkit.gml.xml.v311.TemporalCRSType) JAXBElement(javax.xml.bind.JAXBElement) Term(org.geotoolkit.sml.xml.v100.Term) ArrayLink(org.geotoolkit.sml.xml.v100.ArrayLink) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) OnlineResource(org.geotoolkit.sml.xml.v100.OnlineResource) QuantityType(org.geotoolkit.swe.xml.v100.QuantityType) EngineeringDatumRefType(org.geotoolkit.gml.xml.v311.EngineeringDatumRefType) Outputs(org.geotoolkit.sml.xml.v100.Outputs) EngineeringCRSType(org.geotoolkit.gml.xml.v311.EngineeringCRSType) Link(org.geotoolkit.sml.xml.v100.Link) ArrayLink(org.geotoolkit.sml.xml.v100.ArrayLink) OutputList(org.geotoolkit.sml.xml.v100.OutputList) DataRecordType(org.geotoolkit.swe.xml.v100.DataRecordType) AbstractDataRecordType(org.geotoolkit.swe.xml.v100.AbstractDataRecordType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) Category(org.geotoolkit.swe.xml.v100.Category) InputList(org.geotoolkit.sml.xml.v100.InputList) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v100.ComponentPropertyType) ConnectionList(org.geotoolkit.sml.xml.v100.ConnectionList) PositionList(org.geotoolkit.sml.xml.v100.PositionList) TemporalDatumRefType(org.geotoolkit.gml.xml.v311.TemporalDatumRefType) LegalConstraint(org.geotoolkit.sml.xml.v100.LegalConstraint) Identification(org.geotoolkit.sml.xml.v100.Identification) ComponentList(org.geotoolkit.sml.xml.v100.ComponentList) Classifier(org.geotoolkit.sml.xml.v100.Classifier) TemporalReferenceFrame(org.geotoolkit.sml.xml.v100.TemporalReferenceFrame) TemporalCSRefType(org.geotoolkit.gml.xml.v311.TemporalCSRefType) TimeType(org.geotoolkit.swe.xml.v100.TimeType) UomPropertyType(org.geotoolkit.swe.xml.v100.UomPropertyType) SpatialReferenceFrame(org.geotoolkit.sml.xml.v100.SpatialReferenceFrame) CoordinateType(org.geotoolkit.swe.xml.v100.CoordinateType) VectorType(org.geotoolkit.swe.xml.v100.VectorType) CodeSpacePropertyType(org.geotoolkit.swe.xml.v100.CodeSpacePropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Inputs(org.geotoolkit.sml.xml.v100.Inputs) LinkRef(org.geotoolkit.sml.xml.v100.LinkRef) InputStream(java.io.InputStream) BooleanType(org.geotoolkit.swe.xml.v100.BooleanType) Connection(org.geotoolkit.sml.xml.v100.Connection) QuantityRange(org.geotoolkit.swe.xml.v100.QuantityRange) ResponsibleParty(org.geotoolkit.sml.xml.v100.ResponsibleParty) SensorML(org.geotoolkit.sml.xml.v100.SensorML) Contact(org.geotoolkit.sml.xml.v100.Contact) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) PositionType(org.geotoolkit.swe.xml.v100.PositionType) Interfaces(org.geotoolkit.sml.xml.v100.Interfaces) Characteristics(org.geotoolkit.sml.xml.v100.Characteristics) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) KeywordList(org.geotoolkit.sml.xml.v100.KeywordList) Positions(org.geotoolkit.sml.xml.v100.Positions) PointType(org.geotoolkit.gml.xml.v311.PointType) CodeType(org.geotoolkit.gml.xml.v311.CodeType) AddressType(org.geotoolkit.sml.xml.v100.AddressType) Interface(org.geotoolkit.sml.xml.v100.Interface) Location(org.geotoolkit.sml.xml.v100.Location)

Example 3 with IoComponentPropertyType

use of org.geotoolkit.sml.xml.v101.IoComponentPropertyType in project arctic-sea by 52North.

the class SensorMLEncoderv101 method addIoComponentPropertyType.

/**
 * Adds a SOS SWE simple type to a XML SML IO component.
 *
 * @param ioComponentPropertyType
 *            SML IO component
 * @param sosSMLIO
 *            SOS SWE simple type.
 *
 * @throws EncodingException
 *             if the encoding fails
 */
private void addIoComponentPropertyType(IoComponentPropertyType ioComponentPropertyType, SmlIo sosSMLIO) throws EncodingException {
    ioComponentPropertyType.setName(sosSMLIO.getIoName());
    if (sosSMLIO.isSetHref()) {
        ioComponentPropertyType.setHref(sosSMLIO.getTitle());
        if (sosSMLIO.isSetTitle()) {
            ioComponentPropertyType.setTitle(sosSMLIO.getTitle());
        }
    } else {
        XmlObject encodeObjectToXml;
        XmlObject xml = encodeObjectToXml(SweConstants.NS_SWE_101, sosSMLIO.getIoValue());
        if (xml instanceof DataArrayDocument) {
            encodeObjectToXml = ((DataArrayDocument) xml).getDataArray1();
        } else {
            encodeObjectToXml = xml;
        }
        sosSMLIO.getIoValue().accept(new SweDataComponentAdder(ioComponentPropertyType)).map(h -> (AbstractDataComponentType) h.set(encodeObjectToXml)).ifPresent(h -> sosSMLIO.getIoValue().accept(new SweDataComponentSubstituter(h)));
    }
}
Also used : PositionType(net.opengis.swe.x101.PositionType) SosConstants(org.n52.shetland.ogc.sos.SosConstants) Contact(net.opengis.sensorML.x101.ContactDocument.Contact) Time(org.n52.shetland.ogc.gml.time.Time) PointType(net.opengis.gml.PointType) ParameterList(net.opengis.sensorML.x101.ParametersDocument.Parameters.ParameterList) Phone(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Phone) ComponentList(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList) SmlLocation(org.n52.shetland.ogc.sensorML.elements.SmlLocation) SweAggregateType(org.n52.shetland.ogc.swe.SweConstants.SweAggregateType) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) ProcessMethod(org.n52.shetland.ogc.sensorML.ProcessMethod) Map(java.util.Map) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument) SchemaType(org.apache.xmlbeans.SchemaType) CodeType(org.n52.shetland.ogc.gml.CodeType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) VectorType(net.opengis.swe.x101.VectorType) SensorML(org.n52.shetland.ogc.sensorML.SensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) IoComponentPropertyType(net.opengis.sensorML.x101.IoComponentPropertyType) Set(java.util.Set) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Connections(net.opengis.sensorML.x101.ConnectionsDocument.Connections) Inputs(net.opengis.sensorML.x101.InputsDocument.Inputs) SchemaLocation(org.n52.shetland.w3c.SchemaLocation) SmlDocumentation(org.n52.shetland.ogc.sensorML.elements.SmlDocumentation) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SmlClassifier(org.n52.shetland.ogc.sensorML.elements.SmlClassifier) AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) QName(javax.xml.namespace.QName) Joiner(com.google.common.base.Joiner) ProcessMethodType(net.opengis.sensorML.x101.ProcessMethodType) ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlPosition(org.n52.shetland.ogc.sensorML.elements.SmlPosition) SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SmlLocation2(net.opengis.sensorML.x101.SmlLocation.SmlLocation2) XmlCursor(org.apache.xmlbeans.XmlCursor) XmlHelper(org.n52.svalbard.util.XmlHelper) ContactInfo(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo) MediaType(org.n52.janmayen.http.MediaType) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) Lists(com.google.common.collect.Lists) Components(net.opengis.sensorML.x101.ComponentsDocument.Components) ComponentType(net.opengis.sensorML.x101.ComponentType) ConnectionList(net.opengis.sensorML.x101.ConnectionsDocument.Connections.ConnectionList) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) Link(net.opengis.sensorML.x101.LinkDocument.Link) AbstractSmlDocumentation(org.n52.shetland.ogc.sensorML.elements.AbstractSmlDocumentation) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) SmlConnection(org.n52.shetland.ogc.sensorML.elements.SmlConnection) ProcessModelType(net.opengis.sensorML.x101.ProcessModelType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SweField(org.n52.shetland.ogc.swe.SweField) XmlException(org.apache.xmlbeans.XmlException) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordType(net.opengis.swe.x101.DataRecordType) Address(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Address) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) LoggerFactory(org.slf4j.LoggerFactory) Documentation(net.opengis.sensorML.x101.DocumentationDocument.Documentation) SmlContact(org.n52.shetland.ogc.sensorML.SmlContact) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) ComponentDocument(net.opengis.sensorML.x101.ComponentDocument) MethodPropertyType(net.opengis.sensorML.x101.MethodPropertyType) SmlDocumentationList(org.n52.shetland.ogc.sensorML.elements.SmlDocumentationList) ProcedureDescriptionFormat(org.n52.shetland.ogc.sos.ProcedureDescriptionFormat) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) ImmutableSet(com.google.common.collect.ImmutableSet) AbstractVoidSweDataComponentVisitor(org.n52.shetland.ogc.swe.AbstractVoidSweDataComponentVisitor) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) ImmutableMap(com.google.common.collect.ImmutableMap) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList) Classifier(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList.Classifier) Classification(net.opengis.sensorML.x101.ClassificationDocument.Classification) Sets(com.google.common.collect.Sets) System(org.n52.shetland.ogc.sensorML.System) ClassifierList(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList) Objects(java.util.Objects) List(java.util.List) Characteristics(net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics) GmlConstants(org.n52.shetland.ogc.gml.GmlConstants) Identifier(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) Outputs(net.opengis.sensorML.x101.OutputsDocument.Outputs) SmlParameter(org.n52.shetland.ogc.sensorML.elements.SmlParameter) CollectionHelper(org.n52.shetland.util.CollectionHelper) SupportedType(org.n52.shetland.ogc.SupportedType) Person(net.opengis.sensorML.x101.PersonDocument.Person) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) SmlLink(org.n52.shetland.ogc.sensorML.elements.SmlLink) Position(net.opengis.sensorML.x101.PositionDocument.Position) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) SystemDocument(net.opengis.sensorML.x101.SystemDocument) Document(net.opengis.sensorML.x101.DocumentDocument.Document) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) RulesDefinition(net.opengis.sensorML.x101.ProcessMethodType.Rules.RulesDefinition) SensorMLConstants(org.n52.shetland.ogc.sensorML.SensorMLConstants) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) SystemType(net.opengis.sensorML.x101.SystemType) EnvelopeType(net.opengis.swe.x101.EnvelopeType) DataArrayType(net.opengis.swe.x101.DataArrayType) SweConstants(org.n52.shetland.ogc.swe.SweConstants) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) XmlObject(org.apache.xmlbeans.XmlObject) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty) ProcessModelDocument(net.opengis.sensorML.x101.ProcessModelDocument) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Logger(org.slf4j.Logger) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) AbstractOptionalSweDataComponentVisitor(org.n52.shetland.ogc.swe.AbstractOptionalSweDataComponentVisitor) DocumentList(net.opengis.sensorML.x101.DocumentListDocument.DocumentList) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) Identification(net.opengis.sensorML.x101.IdentificationDocument.Identification) Term(net.opengis.sensorML.x101.TermDocument.Term) XmlOptions(org.apache.xmlbeans.XmlOptions) Sos1Constants(org.n52.shetland.ogc.sos.Sos1Constants) InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) CodingHelper(org.n52.svalbard.util.CodingHelper) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Parameters(net.opengis.sensorML.x101.ParametersDocument.Parameters) Collections(java.util.Collections) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) XmlObject(org.apache.xmlbeans.XmlObject) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Example 4 with IoComponentPropertyType

use of org.geotoolkit.sml.xml.v101.IoComponentPropertyType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_io_from_sml.

@Test
public void should_decode_io_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    InputList xbInputList = xbSystem.addNewInputs().addNewInputList();
    OutputList xbOutputList = xbSystem.addNewOutputs().addNewOutputList();
    IoComponentPropertyType input1 = xbInputList.addNewInput();
    input1.setName("input1");
    input1.addNewBoolean();
    IoComponentPropertyType input2 = xbInputList.addNewInput();
    input2.setName("input2");
    input2.addNewCount();
    IoComponentPropertyType output1 = xbOutputList.addNewOutput();
    output1.setName("output1");
    output1.addNewQuantity();
    IoComponentPropertyType output2 = xbOutputList.addNewOutput();
    output2.setName("output2");
    DataArrayType dataArray = getDataArray();
    output2.setAbstractDataArray1(dataArray);
    XmlHelper.substituteElement(output2.getAbstractDataArray1(), dataArray);
    IoComponentPropertyType output3 = xbOutputList.addNewOutput();
    output3.setName("output3");
    DataRecordType dataRecord = DataRecordType.Factory.newInstance();
    output3.setAbstractDataRecord(dataRecord);
    XmlHelper.substituteElement(output3.getAbstractDataRecord(), dataRecord);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getInputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Boolean));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Boolean));
    assertThat(absProcess.getInputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.Count));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(1).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Count));
    assertThat(absProcess.getOutputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Quantity));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getOutputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Quantity));
    assertThat(absProcess.getOutputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.DataArray));
    assertThat(absProcess.getOutputs().get(2).getIoValue().getDataComponentType(), is(SweDataComponentType.DataRecord));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) IoComponentPropertyType(net.opengis.sensorML.x101.IoComponentPropertyType) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList) DataArrayType(net.opengis.swe.x101.DataArrayType) Test(org.junit.jupiter.api.Test)

Example 5 with IoComponentPropertyType

use of org.geotoolkit.sml.xml.v101.IoComponentPropertyType 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

ArrayList (java.util.ArrayList)5 InputStream (java.io.InputStream)4 CodeType (org.geotoolkit.gml.xml.v311.CodeType)3 StringWriter (java.io.StringWriter)2 JAXBElement (javax.xml.bind.JAXBElement)2 Marshaller (javax.xml.bind.Marshaller)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 InputList (net.opengis.sensorML.x101.InputsDocument.Inputs.InputList)2 IoComponentPropertyType (net.opengis.sensorML.x101.IoComponentPropertyType)2 OutputList (net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList)2 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)2 SystemType (net.opengis.sensorML.x101.SystemType)2 DataArrayType (net.opengis.swe.x101.DataArrayType)2 DataRecordType (net.opengis.swe.x101.DataRecordType)2 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)2 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)2 Capabilities (org.geotoolkit.sml.xml.v100.Capabilities)2 Classification (org.geotoolkit.sml.xml.v100.Classification)2 Classifier (org.geotoolkit.sml.xml.v100.Classifier)2