Search in sources :

Example 1 with DataAvailability

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

the class GetDataAvailabilityV20StreamWriter method writeGetDataAvailabilityResponse.

@Override
protected void writeGetDataAvailabilityResponse() throws XMLStreamException, EncodingException {
    start(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_20_RESPONSE);
    namespace(GetDataAvailabilityConstants.NS_GDA_PREFIX, GetDataAvailabilityConstants.NS_GDA_20);
    namespace(GmlConstants.NS_GML_PREFIX, GmlConstants.NS_GML_32);
    namespace(SweConstants.NS_SWE_PREFIX, SweConstants.NS_SWE_20);
    namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
    schemaLocation(Sets.newHashSet(GetDataAvailabilityConstants.GET_DATA_AVAILABILITY_20_SCHEMA_LOCATION));
    for (DataAvailability da : getElement()) {
        wirteDataAvailabilityMember(da);
    }
    end(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_20_RESPONSE);
}
Also used : DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)

Example 2 with DataAvailability

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

the class GetDataAvailabilityJsonEncoder method encodeResponse.

@Override
protected void encodeResponse(ObjectNode json, GetDataAvailabilityResponse t) throws EncodingException {
    ArrayNode a = json.putArray(GetDataAvailabilityConstants.DATA_AVAILABILITY);
    for (DataAvailability da : t.getDataAvailabilities()) {
        ObjectNode objectNode = a.addObject();
        objectNode.put(JSONConstants.FEATURE_OF_INTEREST, da.getFeatureOfInterest().getHref()).put(JSONConstants.PROCEDURE, da.getProcedure().getHref()).put(JSONConstants.OBSERVED_PROPERTY, da.getObservedProperty().getHref()).set(JSONConstants.PHENOMENON_TIME, encodeObjectToJson(da.getPhenomenonTime()));
        if (t.isSetResponseFormat() && GetDataAvailabilityConstants.NS_GDA_20.equals(t.getResponseFormat())) {
            if (da.isSetOffering()) {
                objectNode.put(JSONConstants.OFFERING, da.getOffering().getHref());
            }
            if (da.isSetFormatDescriptors()) {
                ObjectNode fdNode = objectNode.putObject(GetDataAvailabilityConstants.FORMAT_DESCRIPTOR);
                encodeProcedureFormatDescriptor(da.getFormatDescriptor().getProcedureDescriptionFormatDescriptor(), fdNode);
                encodeObservationFormatDescriptor(da.getFormatDescriptor().getObservationFormatDescriptors(), fdNode);
            }
        }
        if (da.isSetCount()) {
            objectNode.put(JSONConstants.COUNT, da.getCount());
        }
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 3 with DataAvailability

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

the class GetDataAvailabilityStreamWriter method writeGetDataAvailabilityResponse.

@Override
protected void writeGetDataAvailabilityResponse() throws XMLStreamException, EncodingException {
    start(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_RESPONSE);
    namespace(GetDataAvailabilityConstants.NS_GDA_PREFIX, GetDataAvailabilityConstants.NS_GDA);
    namespace(GmlConstants.NS_GML_PREFIX, GmlConstants.NS_GML_32);
    namespace(SweConstants.NS_SWE_PREFIX, SweConstants.NS_SWE_20);
    namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
    schemaLocation(Sets.newHashSet(GetDataAvailabilityConstants.GET_DATA_AVAILABILITY_SCHEMA_LOCATION));
    for (DataAvailability da : getElement()) {
        wirteDataAvailabilityMember(da);
    }
    end(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_RESPONSE);
}
Also used : DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)

Example 4 with DataAvailability

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

the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.

private Collection<DataAvailability> parseDataAvalabilities(net.opengis.sosgda.x20.GetDataAvailabilityResponseType response) throws DecodingException {
    List<DataAvailability> availabilities = Lists.newArrayList();
    if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
        Map<String, TimePeriod> periods = Maps.newHashMap();
        for (net.opengis.sosgda.x20.DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
            ReferenceType procedure = decodeXmlElement(damt.getProcedure());
            ReferenceType offering = decodeXmlElement(damt.getOffering());
            ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
            ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
            TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
            DataAvailability dataAvailability = new DataAvailability(procedure, observedProperty, featureOfInterest, offering, phenomenonTime);
            FormatDescriptor formatDescriptor = createFormatDescriptor(damt.getFormatDescriptor());
            if (formatDescriptor != null) {
                dataAvailability.setFormatDescriptor(formatDescriptor);
            }
            availabilities.add(dataAvailability);
        }
    }
    return availabilities;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ProcedureDescriptionFormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ProcedureDescriptionFormatDescriptor) ObservationFormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ObservationFormatDescriptor) FormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.FormatDescriptor) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType)

Example 5 with DataAvailability

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

the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.

private Collection<DataAvailability> parseDataAvalabilities(GetDataAvailabilityResponseType response) throws DecodingException {
    List<DataAvailability> availabilities = Lists.newArrayList();
    if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
        Map<String, TimePeriod> periods = Maps.newHashMap();
        for (DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
            ReferenceType procedure = decodeXmlElement(damt.getProcedure());
            ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
            ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
            TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
            availabilities.add(new DataAvailability(procedure, observedProperty, featureOfInterest, null, phenomenonTime));
        }
    }
    return availabilities;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) DataAvailabilityMemberType(net.opengis.sosgda.x10.DataAvailabilityMemberType)

Aggregations

DataAvailability (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)6 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 DataAvailabilityMemberType (net.opengis.sosgda.x10.DataAvailabilityMemberType)1 XmlObject (org.apache.xmlbeans.XmlObject)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 GetDataAvailabilityResponse (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse)1 FormatDescriptor (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.FormatDescriptor)1 ObservationFormatDescriptor (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ObservationFormatDescriptor)1 ProcedureDescriptionFormatDescriptor (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ProcedureDescriptionFormatDescriptor)1