use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class InspireEncoderTest method getFullInspireExtendedCapabilities.
private FullInspireExtendedCapabilities getFullInspireExtendedCapabilities() {
InspireResourceLocator resourceLocator = new InspireResourceLocator("http://full.test.org/sos");
resourceLocator.addMediaType(MediaTypes.APPLICATION_SOAP_XML);
// -------------------
InspireTemporalReference temporalReference = new InspireTemporalReference();
temporalReference.setDateOfCreation(new InspireDateOfCreation(new DateTime()));
temporalReference.setDateOfLastRevision(new InspireDateOfLastRevision(new DateTime()));
temporalReference.addDateOfPublication(new InspireDateOfPublication(new DateTime()));
temporalReference.addTemporalExtent(new TimeInstant(new DateTime()));
temporalReference.addTemporalExtent(new TimePeriod(new DateTime(), new DateTime().plus(3456)));
// -------------------
InspireConformityCitation inspireConformityCitation = new InspireConformityCitation("Test", new InspireDateOfCreation(new DateTime()));
InspireConformity conformity = new InspireConformity(inspireConformityCitation, InspireDegreeOfConformity.notEvaluated);
// -------------------
InspireMetadataPointOfContact inspireMetadataPointOfContact = new InspireMetadataPointOfContact("test", "test@test.te");
// -------------------
InspireOriginatingControlledVocabulary inspireOriginatingControlledVocabulary = new InspireOriginatingControlledVocabulary("Test", new InspireDateOfCreation(new DateTime()));
InspireMandatoryKeyword inspireMandatoryKeyword = new InspireMandatoryKeyword(InspireMandatoryKeywordValue.humanServiceEditor, inspireOriginatingControlledVocabulary);
// --------------------
InspireSupportedLanguages inspireSupportedLanguages = new InspireSupportedLanguages(InspireLanguageISO6392B.ENG);
// --------------------
InspireLanguageISO6392B responseLanguage = InspireLanguageISO6392B.ENG;
// --------------------
InspireUniqueResourceIdentifier iuri = new InspireUniqueResourceIdentifier("test");
iuri.setNamespace("http://test.org");
// --------------------
FullInspireExtendedCapabilities inspireExtendedCapabilities = new FullInspireExtendedCapabilities(resourceLocator, inspireSupportedLanguages, responseLanguage, iuri, new InspireSupportedCRS("4326"));
inspireExtendedCapabilities.setResourceType(InspireServiceSpatialDataResourceType.service);
inspireExtendedCapabilities.addKeyword(new InspireKeyword("test"));
inspireExtendedCapabilities.addMandatoryKeyword(inspireMandatoryKeyword);
// -------------------
inspireExtendedCapabilities.setMetadataDate(new TimeInstant(new DateTime()));
// -------------------
inspireExtendedCapabilities.addMetadataPointOfContact(inspireMetadataPointOfContact);
inspireExtendedCapabilities.addConformity(conformity);
inspireExtendedCapabilities.addTemporalReference(temporalReference);
return inspireExtendedCapabilities;
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class AbstractOmV20XmlStreamWriter method writeResultTime.
/**
* Write om:resultTime to stream
*
* @throws XMLStreamException
* If an error occurs when writing to stream
* @throws EncodingException
* If an error occurs when creating elements to be written
*/
protected void writeResultTime() throws XMLStreamException, EncodingException {
OmObservation observation = getElement();
TimeInstant resultTime = observation.getResultTime();
Time phenomenonTime = observation.getPhenomenonTime();
// get result time from SOS result time
if (observation.getResultTime() != null) {
if (resultTime.equals(phenomenonTime)) {
empty(OmConstants.QN_OM_20_RESULT_TIME);
addXlinkHrefAttr("#".concat(phenomenonTime.getGmlId()));
} else {
addResultTime(resultTime);
}
} else if (phenomenonTime instanceof TimeInstant) {
// if result time is not set, get result time from phenomenon time
empty(OmConstants.QN_OM_20_RESULT_TIME);
addXlinkHrefAttr("#".concat(phenomenonTime.getGmlId()));
} else if (phenomenonTime instanceof TimePeriod) {
TimeInstant rsTime = new TimeInstant(((TimePeriod) observation.getPhenomenonTime()).getEnd());
addResultTime(rsTime);
}
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class SosDecoderv20 method checkReferencedElements.
private void checkReferencedElements(final List<OmObservation> observations, final Map<String, Time> phenomenonTimes, final Map<String, TimeInstant> resultTimes, final Map<String, AbstractFeature> features) throws DecodingException {
for (final OmObservation observation : observations) {
// phenomenonTime
final Time phenomenonTime = observation.getPhenomenonTime();
if (phenomenonTime.isReferenced()) {
observation.getValue().setPhenomenonTime(phenomenonTimes.get(phenomenonTime.getGmlId()));
}
// resultTime
final TimeInstant resultTime = observation.getResultTime();
if (resultTime.isReferenced()) {
if (resultTimes.containsKey(resultTime.getGmlId())) {
observation.setResultTime(resultTimes.get(resultTime.getGmlId()));
} else if (phenomenonTimes.containsKey(resultTime.getGmlId())) {
final Time iTime = phenomenonTimes.get(resultTime.getGmlId());
if (iTime instanceof TimeInstant) {
observation.setResultTime((TimeInstant) iTime);
} else if (iTime instanceof TimePeriod) {
final TimePeriod timePeriod = (TimePeriod) iTime;
observation.setResultTime(new TimeInstant(timePeriod.getEnd()));
} else {
throw new DecodingException("observation.resultTime", "The time value type is not supported");
}
}
}
// featureOfInterest
final AbstractFeature featureOfInterest = observation.getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest.isReferenced()) {
observation.getObservationConstellation().setFeatureOfInterest(features.get(featureOfInterest.getGmlId()));
}
}
}
use of org.n52.shetland.ogc.gml.time.TimePeriod 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;
}
use of org.n52.shetland.ogc.gml.time.TimePeriod 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;
}
Aggregations