Search in sources :

Example 6 with SmlIo

use of org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_encode_single_contact_person.

// @Test
// public void should_encode_features_of_interest() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addFeatureOfInterest(TEST_ID_1);
// system.addFeatureOfInterest(TEST_ID_2);
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME + 1,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME + 2,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_2);
// }
// 
// @Test
// public void should_encode_offerings() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addOffering(new SosOffering(TEST_ID_1, TEST_NAME_1));
// system.addOffering(new SosOffering(TEST_ID_2, TEST_NAME_2));
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_OFFERINGS, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], TEST_NAME_1, SensorMLConstants.OFFERING_FIELD_DEFINITION,
// TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], TEST_NAME_2, SensorMLConstants.OFFERING_FIELD_DEFINITION,
// TEST_ID_2);
// }
// 
// @Test
// public void should_encode_parent_procedures() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addParentProcedure(TEST_ID_1);
// system.addParentProcedure(TEST_ID_2);
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_PARENT_PROCEDURES, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], SensorMLConstants.PARENT_PROCEDURE_FIELD_NAME + 1,
// SensorMLConstants.PARENT_PROCEDURE_FIELD_DEFINITION, TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], SensorMLConstants.PARENT_PROCEDURE_FIELD_NAME + 2,
// SensorMLConstants.PARENT_PROCEDURE_FIELD_DEFINITION, TEST_ID_2);
// }
// 
// @Test
// public void should_encode_child_procedures() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// final System childProcedure = new System();
// childProcedure.setIdentifier(TEST_CHILD_1);
// system.addChildProcedure(childProcedure);
// childProcedure.addFeatureOfInterest(TEST_ID_1);
// final SystemType xbSystemType = encodeSystem(sensorMl);
// assertThat(xbSystemType.getComponents().getComponentList().sizeOfComponentArray(), is(1));
// final Component xbComponent = xbSystemType.getComponents().getComponentList().getComponentArray(0);
// assertThat(xbComponent.getProcess(), instanceOf(SystemType.class));
// final SystemType xbComponentSystem = (SystemType) xbComponent.getProcess();
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(xbComponentSystem, SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST, 1);
// validateField(xbSimpleDataRecord.getFieldArray(0), SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_1);
// }
// 
// @Test
// @SuppressWarnings("unchecked")
// public void should_aggregate_child_outputs() throws EncodingException {
// final SweQuantity q1 = new SweQuantity();
// q1.setDefinition("def1");
// q1.setUom("uom1");
// final SmlIo<?> output1 = new SmlIo<SweQuantity>(q1);
// 
// final SweQuantity q2 = new SweQuantity();
// q2.setDefinition("def2");
// q2.setUom("uom2");
// final SmlIo<?> output2 = new SmlIo<SweQuantity>(q2);
// 
// final SweQuantity q3 = new SweQuantity();
// q3.setDefinition("def3");
// q3.setUom("uom3");
// final SmlIo<?> output3 = new SmlIo<SweQuantity>(q3);
// 
// final SensorML sensorMl = new SensorML();
// sensorMl.setIdentifier("sensorMl");
// final System system = new System();
// system.setIdentifier("system");
// sensorMl.addMember(system);
// system.getOutputs().add(output1);
// 
// final SensorML childSml = new SensorML();
// childSml.setIdentifier("childSml");
// final System childSystem = new System();
// childSystem.setIdentifier("childSystem");
// childSml.addMember(childSystem);
// system.addChildProcedure(childSml);
// childSystem.getOutputs().add(output2);
// 
// final SensorML grandchildSml = new SensorML();
// grandchildSml.setIdentifier("grandchildSml");
// final System grandchildSystem = new System();
// grandchildSystem.setIdentifier("grandchildSystem");
// grandchildSml.addMember(grandchildSystem);
// childSystem.addChildProcedure(grandchildSml);
// grandchildSystem.getOutputs().add(output3);
// 
// encodeSystem(sensorMl);
// 
// assertThat(system.getOutputs(), hasItems(output1, output2, output3));
// assertThat(childSystem.getOutputs(), hasItems(output2, output3));
// assertThat(grandchildSystem.getOutputs(), hasItem(output3));
// }
@Test
public void should_encode_single_contact_person() throws EncodingException {
    final SensorML sensorML = new SensorML();
    final System system = new System();
    sensorML.addMember(system);
    final SmlPerson contact = createPerson("");
    system.addContact(contact);
    final SystemType xbSystem = encodeSystem(sensorML);
    assertThat(xbSystem.sizeOfContactArray(), is(1));
    assertThat(xbSystem.getContactArray(0).getContactList().getMemberArray(0).isSetPerson(), is(true));
    checkPerson(contact, xbSystem.getContactArray(0).getContactList().getMemberArray(0).getPerson());
}
Also used : SystemType(net.opengis.sensorML.x101.SystemType) SensorML(org.n52.shetland.ogc.sensorML.SensorML) System(org.n52.shetland.ogc.sensorML.System) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.Test)

Example 7 with SmlIo

use of org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.

the class SensorMLDecoderV20 method parseInput.

@SuppressWarnings({ "rawtypes" })
private SmlIo parseInput(Input xbInput) throws DecodingException {
    final SmlIo sosIo = new SmlIo();
    sosIo.setIoName(xbInput.getName());
    if (xbInput.isSetHref()) {
        parseReference(xbInput, sosIo);
    } else {
        sosIo.setIoValue(parseDataComponentOrObservablePropertyType(xbInput));
    }
    return sosIo;
}
Also used : SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Example 8 with SmlIo

use of org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createInputs.

/**
 * Creates the inputs section of the SensorML description.
 *
 * @param inputs
 *            SOS SWE representation.
 *
 * @return XML Inputs element
 *
 * @throws EncodingException
 *             if an error occurs
 */
private Inputs createInputs(List<SmlIo> inputs) throws EncodingException {
    Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
    InputList xbInputList = xbInputs.addNewInputList();
    int counter = 1;
    for (SmlIo sosSMLIo : inputs) {
        if (!sosSMLIo.isSetName()) {
            sosSMLIo.setIoName("input_" + counter++);
        }
        addIoComponentPropertyType(xbInputList.addNewInput(), sosSMLIo);
    }
    return xbInputs;
}
Also used : InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) Inputs(net.opengis.sensorML.x101.InputsDocument.Inputs)

Example 9 with SmlIo

use of org.n52.shetland.ogc.sensorML.elements.SmlIo 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)

Example 10 with SmlIo

use of org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.

the class SensorMLEncoderv20 method createInputs.

// /**
// * Creates the location section of the SensorML description.
// *
// * @param dot
// *            the described object
// * @param location
// *            SOS location representation.
// *
// * @throws EncodingException
// *             if an error occurs
// */
// private void createLocation(DescribedObjectType dot, SmlLocation location) throws EncodingException {
// dot.addNewLocation().addNewAbstractGeometry().set(encodeObjectToXmlGml32(location.getPoint()));
// }
/**
 * Creates the inputs section of the SensorML description.
 *
 * @param inputs
 *            SOS SWE representation.
 *
 * @return XML Inputs element
 *
 * @throws EncodingException
 *             if an error occurs
 */
private Inputs createInputs(final List<SmlIo> inputs) throws EncodingException {
    final Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
    final InputListType xbInputList = xbInputs.addNewInputList();
    int counter = 1;
    for (final SmlIo sosSMLIo : inputs) {
        if (!sosSMLIo.isSetName()) {
            sosSMLIo.setIoName("input_" + counter++);
        } else {
            sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
        }
        addInput(xbInputList.addNewInput(), sosSMLIo);
    }
    return xbInputs;
}
Also used : InputListType(net.opengis.sensorml.x20.InputListType) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) Inputs(net.opengis.sensorml.x20.AbstractProcessType.Inputs)

Aggregations

SmlIo (org.n52.shetland.ogc.sensorML.elements.SmlIo)8 Inputs (net.opengis.sensorML.x101.InputsDocument.Inputs)2 InputList (net.opengis.sensorML.x101.InputsDocument.Inputs.InputList)2 SystemType (net.opengis.sensorML.x101.SystemType)2 SensorML (org.n52.shetland.ogc.sensorML.SensorML)2 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)2 System (org.n52.shetland.ogc.sensorML.System)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 PointType (net.opengis.gml.PointType)1 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)1