Search in sources :

Example 1 with SosProcedureDescriptionUnknownType

use of org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType in project arctic-sea by 52North.

the class InsertSensorRequestEncoder method addProcedureDescription.

private void addProcedureDescription(InsertSensorRequest request, InsertSensorType insertSensor) throws EncodingException {
    XmlObject xmlObj;
    if (request.getProcedureDescription() instanceof SosProcedureDescriptionUnknownType && request.getProcedureDescription().isSetXml()) {
        try {
            xmlObj = XmlHelper.parseXmlString(request.getProcedureDescription().getXml());
        } catch (DecodingException de) {
            throw new EncodingException("An xml error occured when parsing the request!", de);
        }
    }
    xmlObj = encodeObjectToXml(request.getProcedureDescriptionFormat(), request.getProcedureDescription().getProcedureDescription());
    insertSensor.addNewProcedureDescription().set(xmlObj);
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException)

Example 2 with SosProcedureDescriptionUnknownType

use of org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType in project arctic-sea by 52North.

the class OmEncoderv20Test method createComplexObservation.

protected OmObservation createComplexObservation() {
    DateTime now = new DateTime(DateTimeZone.UTC);
    TimeInstant resultTime = new TimeInstant(now);
    TimeInstant phenomenonTime = new TimeInstant(now);
    TimePeriod validTime = new TimePeriod(now.minusMinutes(5), now.plusMinutes(5));
    OmObservation observation = new OmObservation();
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
    OmCompositePhenomenon observableProperty = new OmCompositePhenomenon(PARENT_OBSERVABLE_PROPERTY);
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_1));
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_2));
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_3));
    observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_4));
    observationConstellation.setObservableProperty(observableProperty);
    observationConstellation.setObservationType(OmConstants.OBS_TYPE_COMPLEX_OBSERVATION);
    observationConstellation.addOffering(OFFERING);
    AbstractFeature procedure = new SosProcedureDescriptionUnknownType(PROCEDURE);
    // procedure.setIdentifier(new CodeWithAuthority(PROCEDURE, CODE_SPACE));
    observationConstellation.setProcedure(procedure);
    observation.setObservationConstellation(observationConstellation);
    observation.setParameter(null);
    observation.setResultTime(resultTime);
    observation.setTokenSeparator(TOKEN_SEPERATOR);
    observation.setTupleSeparator(TUPLE_SEPERATOR);
    observation.setValidTime(validTime);
    ComplexValue complexValue = new ComplexValue();
    SweDataRecord sweDataRecord = new SweDataRecord();
    SweQuantity sweQuantity = new SweQuantity();
    sweQuantity.setDefinition(CHILD_OBSERVABLE_PROPERTY_1);
    sweQuantity.setUom("unit");
    sweQuantity.setValue(42.0);
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_1_NAME, sweQuantity));
    SweBoolean sweBoolean = new SweBoolean();
    sweBoolean.setValue(Boolean.TRUE);
    sweBoolean.setDefinition(CHILD_OBSERVABLE_PROPERTY_2);
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_2_NAME, sweBoolean));
    SweCount sweCount = new SweCount();
    sweCount.setDefinition(CHILD_OBSERVABLE_PROPERTY_3);
    sweCount.setValue(42);
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_3_NAME, sweCount));
    SweText sweText = new SweText();
    sweText.setDefinition(CHILD_OBSERVABLE_PROPERTY_4);
    sweText.setValue("42");
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_4_NAME, sweText));
    SweCategory sweCategory = new SweCategory();
    sweCategory.setDefinition(CHILD_OBSERVABLE_PROPERTY_5);
    sweCategory.setCodeSpace(CODE_SPACE);
    sweCategory.setValue("52");
    sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_5_NAME, sweCategory));
    complexValue.setValue(sweDataRecord);
    observation.setValue(new SingleObservationValue<>(phenomenonTime, complexValue));
    return observation;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) OmCompositePhenomenon(org.n52.shetland.ogc.om.OmCompositePhenomenon) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 3 with SosProcedureDescriptionUnknownType

use of org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType in project arctic-sea by 52North.

the class SensorMLEncoderv101 method encode.

@Override
public XmlObject encode(final Object response, final EncodingContext additionalValues) throws EncodingException {
    XmlObject encodedObject = null;
    if (response instanceof AbstractSensorML) {
        encodedObject = createSensorDescription((AbstractSensorML) response);
    // }
    // FIXME workaround? if of type UnknowProcedureType try to parse the
    // description string, UNIT is missing "NOT_DEFINED"?!
    // else if (response instanceof SosProcedureDescriptionUnknownType)
    // {
    // final String procDescXMLString = ((SosProcedureDescription)
    // response).getXml();
    // final AbstractSensorML sensorDesc = new AbstractSensorML();
    // sensorDesc.setXml(procDescXMLString);
    // encodedObject = createSensorDescriptionFromString(sensorDesc);
    } else {
        throw new UnsupportedEncoderInputException(this, response);
    }
    // check if all gml:id are unique
    XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
    XmlHelper.validateDocument(encodedObject, EncodingException::new);
    return encodedObject;
}
Also used : AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)2 SosProcedureDescriptionUnknownType (org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 DateTime (org.joda.time.DateTime)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 OmCompositePhenomenon (org.n52.shetland.ogc.om.OmCompositePhenomenon)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)1 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)1 ComplexValue (org.n52.shetland.ogc.om.values.ComplexValue)1 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)1 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweField (org.n52.shetland.ogc.swe.SweField)1 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)1 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)1 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)1