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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations