Search in sources :

Example 1 with IoComponentPropertyType

use of net.opengis.sensorML.x101.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.Test)

Example 2 with IoComponentPropertyType

use of net.opengis.sensorML.x101.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) 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) ProcessMethodType(net.opengis.sensorML.x101.ProcessMethodType) Joiner(com.google.common.base.Joiner) 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) SmlLocation2(net.opengis.sensorML.x101.SmlLocation.SmlLocation2) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) XmlCursor(org.apache.xmlbeans.XmlCursor) ContactInfo(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo) XmlHelper(org.n52.svalbard.util.XmlHelper) MediaType(org.n52.janmayen.http.MediaType) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) Components(net.opengis.sensorML.x101.ComponentsDocument.Components) Lists(com.google.common.collect.Lists) 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) Link(net.opengis.sensorML.x101.LinkDocument.Link) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) 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) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SmlDocumentationList(org.n52.shetland.ogc.sensorML.elements.SmlDocumentationList) ProcedureDescriptionFormat(org.n52.shetland.ogc.sos.ProcedureDescriptionFormat) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) 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) ClassifierList(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList) System(org.n52.shetland.ogc.sensorML.System) 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) Outputs(net.opengis.sensorML.x101.OutputsDocument.Outputs) SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) CollectionHelper(org.n52.shetland.util.CollectionHelper) Person(net.opengis.sensorML.x101.PersonDocument.Person) SupportedType(org.n52.shetland.ogc.SupportedType) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) SmlLink(org.n52.shetland.ogc.sensorML.elements.SmlLink) Position(net.opengis.sensorML.x101.PositionDocument.Position) SystemDocument(net.opengis.sensorML.x101.SystemDocument) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) 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) 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) ProcessModelDocument(net.opengis.sensorML.x101.ProcessModelDocument) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList) Logger(org.slf4j.Logger) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) AbstractOptionalSweDataComponentVisitor(org.n52.shetland.ogc.swe.AbstractOptionalSweDataComponentVisitor) DocumentList(net.opengis.sensorML.x101.DocumentListDocument.DocumentList) Identification(net.opengis.sensorML.x101.IdentificationDocument.Identification) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) 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) Collections(java.util.Collections) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) XmlObject(org.apache.xmlbeans.XmlObject) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Aggregations

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 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)2 Joiner (com.google.common.base.Joiner)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 QName (javax.xml.namespace.QName)1