Search in sources :

Example 11 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class UVFEncoder method encodeToUvf.

private File encodeToUvf(ObservationStream observationStream, File tempDir, MediaType contentType) throws IOException, EncodingException {
    List<OmObservation> mergeObservations = mergeTotoList(observationStream);
    String ending = getLineEnding(contentType);
    String filename = getFilename(mergeObservations);
    File uvfFile = new File(tempDir, filename);
    try (Writer fw = new OutputStreamWriter(new FileOutputStream(uvfFile), "UTF-8")) {
        for (OmObservation o : mergeObservations) {
            if (o.isSetValue() && !checkForSingleObservationValue(o.getValue()) && !checkForMultiObservationValue(o.getValue())) {
                String errorMessage = String.format("The resulting values are not of numeric type " + "which is only supported by this encoder '%s'.", this.getClass().getName());
                LOGGER.error(errorMessage);
                throw new EncodingException(errorMessage);
            }
            /*
                 * HEADER: Metadata
                 */
            writeFunktionInterpretation(fw, o, ending);
            writeIndex(fw, ending);
            writeMessGroesse(fw, o, ending);
            writeMessEinheit(fw, o, ending);
            writeMessStellennummer(fw, o, ending);
            writeMessStellenname(fw, o, ending);
            /*
                 * HEADER: Lines 1 - 4
                 */
            writeLine1(fw, ending);
            TimePeriod temporalBBox = getTemporalBBoxFromObservations(mergeObservations);
            writeLine2(fw, o, temporalBBox, ending);
            writeLine3(fw, o, ending);
            writeLine4(fw, temporalBBox, ending);
            /*
                 * Observation Data
                 */
            writeObservationValue(fw, o, ending);
        }
    }
    return uvfFile;
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) FileOutputStream(java.io.FileOutputStream) OmObservation(org.n52.shetland.ogc.om.OmObservation) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 12 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class AbstractCapabilitiesBaseTypeDecoder method parseDomain.

private OwsDomain parseDomain(DomainType domain) {
    if (domain == null) {
        return null;
    }
    OwsValue defaultValue = parseValue(domain.getDefaultValue());
    Collection<OwsMetadata> metadata = parseMetadata(domain.getMetadataArray());
    OwsDomainMetadata meaning = parseDomainMetadata(domain.getMeaning());
    OwsDomainMetadata dataType = parseDomainMetadata(domain.getDataType());
    OwsValuesUnit valuesUnit = Stream.of(parseUom(domain.getUOM()), parseReferenceSystem(domain.getReferenceSystem())).filter(Objects::nonNull).findFirst().orElse(null);
    OwsPossibleValues possibleValues = Stream.of(parseAnyValue(domain.getAnyValue()), parseAllowedValues(domain.getAllowedValues()), parseValuesReference(domain.getValuesReference()), parseNoValues(domain.getNoValues())).filter(Objects::nonNull).findFirst().orElse(null);
    return new OwsDomain(domain.getName(), possibleValues, defaultValue, meaning, dataType, valuesUnit, metadata);
}
Also used : OwsDomain(org.n52.shetland.ogc.ows.OwsDomain) OwsDomainMetadata(org.n52.shetland.ogc.ows.OwsDomainMetadata) OwsMetadata(org.n52.shetland.ogc.ows.OwsMetadata) OwsValuesUnit(org.n52.shetland.ogc.ows.OwsValuesUnit) Objects(java.util.Objects) OwsPossibleValues(org.n52.shetland.ogc.ows.OwsPossibleValues) OwsValue(org.n52.shetland.ogc.ows.OwsValue)

Example 13 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class AbstractCapabilitiesBaseTypeDecoder method parseMetadata.

// private Set<OwsDomainMetadata> parseDomainMetadata(DomainMetadataType[]
// metadata) {
// return
// Optional.ofNullable(metadata).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseDomainMetadata)
// .filter(Objects::nonNull).collect(toSet());
// }
private OwsMetadata parseMetadata(MetadataType metadata) {
    if (metadata == null) {
        return null;
    }
    URI href = Optional.ofNullable(metadata.getHref()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    URI role = Optional.ofNullable(metadata.getRole()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    URI arcrole = Optional.ofNullable(metadata.getArcrole()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    Show show = Optional.ofNullable(metadata.getShow()).map(Object::toString).map(Show::valueOf).orElse(null);
    Actuate actuate = Optional.ofNullable(metadata.getActuate()).map(Object::toString).map(Actuate::valueOf).orElse(null);
    URI about = Optional.ofNullable(metadata.getAbout()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    String title = metadata.getTitle();
    return new OwsMetadata(href, role, arcrole, title, show, actuate, about);
}
Also used : Actuate(org.n52.shetland.w3c.xlink.Actuate) OwsMetadata(org.n52.shetland.ogc.ows.OwsMetadata) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) URI(java.net.URI) Strings(com.google.common.base.Strings)

Example 14 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class AbstractCapabilitiesBaseTypeDecoder method parse.

private <T extends OwsDomainMetadata> T parse(BiFunction<URI, String, T> fun, DomainMetadataType metadata) {
    if (metadata == null) {
        return null;
    }
    URI reference = Optional.ofNullable(metadata.getReference()).map(Strings::emptyToNull).map(URI::create).orElse(null);
    String value = metadata.getStringValue();
    return fun.apply(reference, value);
}
Also used : LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) URI(java.net.URI) Strings(com.google.common.base.Strings)

Example 15 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class SwesDecoderv20 method parseInsertSensor.

private OwsServiceRequest parseInsertSensor(final InsertSensorDocument xbInsSensDoc) throws DecodingException {
    final InsertSensorRequest request = new InsertSensorRequest();
    final InsertSensorType xbInsertSensor = xbInsSensDoc.getInsertSensor();
    request.setService(xbInsertSensor.getService());
    request.setVersion(xbInsertSensor.getVersion());
    // format
    request.setProcedureDescriptionFormat(xbInsertSensor.getProcedureDescriptionFormat());
    // observable properties
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getObservablePropertyArray())) {
        request.setObservableProperty(Arrays.asList(xbInsertSensor.getObservablePropertyArray()));
    }
    // related features
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getRelatedFeatureArray())) {
        request.setRelatedFeature(parseRelatedFeature(xbInsertSensor.getRelatedFeatureArray()));
    }
    // metadata
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getMetadataArray())) {
        request.setMetadata(parseMetadata(xbInsertSensor.getMetadataArray()));
    }
    // extensions
    request.setExtensions(parseExtensibleRequest(xbInsertSensor));
    try {
        final XmlObject xbProcedureDescription = XmlObject.Factory.parse(getNodeFromNodeList(xbInsertSensor.getProcedureDescription().getDomNode().getChildNodes()));
        checkFormatWithNamespace(xbInsertSensor.getProcedureDescriptionFormat(), XmlHelper.getNamespace(xbProcedureDescription));
        final Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(xbInsertSensor.getProcedureDescriptionFormat(), xbProcedureDescription.getClass()));
        if (decoder != null) {
            final Object decodedProcedureDescription = decoder.decode(xbProcedureDescription);
            if (decodedProcedureDescription instanceof SosProcedureDescription) {
                request.setProcedureDescription((SosProcedureDescription) decodedProcedureDescription);
            } else if (decodedProcedureDescription instanceof AbstractFeature) {
                request.setProcedureDescription(new SosProcedureDescription<>((AbstractFeature) decodedProcedureDescription));
            }
        }
    } catch (final XmlException xmle) {
        throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
    }
    return request;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) InsertSensorType(net.opengis.swes.x20.InsertSensorType) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)5 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)5 IoParameters (org.n52.io.request.IoParameters)4 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)4 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)4 Test (org.junit.Test)3 QuantityDatasetMetadata (org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)3 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)3 Strings (com.google.common.base.Strings)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 XmlException (org.apache.xmlbeans.XmlException)2 DateTime (org.joda.time.DateTime)2 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)2 ParameterOutput (org.n52.io.response.ParameterOutput)2 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)2 LocalizedString (org.n52.janmayen.i18n.LocalizedString)2