Search in sources :

Example 1 with DateTimeHelper.parseIsoString2DateTime

use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseTimeRange.

private SweTimeRange parseTimeRange(TimeRange timeRange) throws DecodingException {
    SweTimeRange sosTimeRange = new SweTimeRange();
    if (timeRange.isSetValue()) {
        RangeValue<DateTime> range = new RangeValue<>();
        Iterator<?> iter = timeRange.getValue().iterator();
        if (iter.hasNext()) {
            range.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
            while (iter.hasNext()) {
                range.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
            }
        }
        sosTimeRange.setValue(range);
    }
    if (timeRange.getUom() != null) {
        sosTimeRange.setUom(timeRange.getUom().getHref());
    }
    return sosTimeRange;
}
Also used : SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 2 with DateTimeHelper.parseIsoString2DateTime

use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseAllowedTimes.

@SuppressWarnings({ "unchecked", "rawtypes" })
private SweAllowedTimes parseAllowedTimes(AllowedTimes att) throws DateTimeParseException {
    SweAllowedTimes allowedTimes = new SweAllowedTimes();
    if (att.isSetId()) {
        allowedTimes.setGmlId(att.getId());
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getValueListArray())) {
        for (List list : att.getValueListArray()) {
            if (CollectionHelper.isNotEmpty(list)) {
                for (Object value : list) {
                    allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
                }
            }
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
        for (List interval : att.getIntervalArray()) {
            RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
            Iterator iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            allowedTimes.addInterval(rangeValue);
        }
    }
    return allowedTimes;
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) XmlObject(org.apache.xmlbeans.XmlObject) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 3 with DateTimeHelper.parseIsoString2DateTime

use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseAllowedTimes.

@SuppressWarnings("rawtypes")
private SweAllowedTimes parseAllowedTimes(AllowedTimesType att) throws DateTimeParseException {
    SweAllowedTimes allowedTimes = new SweAllowedTimes();
    if (att.isSetId()) {
        allowedTimes.setGmlId(att.getId());
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getValueArray())) {
        for (Object value : att.getValueArray()) {
            allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
        for (List interval : att.getIntervalArray()) {
            RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
            Iterator iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            allowedTimes.addInterval(rangeValue);
        }
    }
    if (att.isSetSignificantFigures()) {
        allowedTimes.setSignificantFigures(att.getSignificantFigures());
    }
    return allowedTimes;
}
Also used : Iterator(java.util.Iterator) XmlObject(org.apache.xmlbeans.XmlObject) List(java.util.List) ArrayList(java.util.ArrayList) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 4 with DateTimeHelper.parseIsoString2DateTime

use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.

the class GmlDecoderv311 method parseTimePosition.

private TimeInstant parseTimePosition(TimePositionType xbTimePosition) throws DecodingException {
    TimeInstant ti = new TimeInstant();
    String timeString = xbTimePosition.getStringValue();
    if (timeString != null && !timeString.isEmpty()) {
        try {
            // TODO better differnetiate between ISO8601 and an
            // indeterminate value
            DateTime dateTime = DateTimeHelper.parseIsoString2DateTime(timeString);
            ti.setValue(dateTime);
            ti.setRequestedTimeLength(DateTimeHelper.getTimeLengthBeforeTimeZone(timeString));
        } catch (DateTimeParseException ex) {
            ti.setIndeterminateValue(new IndeterminateValue(timeString));
        }
    }
    if (xbTimePosition.getIndeterminatePosition() != null) {
        ti.setIndeterminateValue(new IndeterminateValue(xbTimePosition.getIndeterminatePosition().toString()));
    }
    return ti;
}
Also used : DateTimeParseException(org.n52.shetland.util.DateTimeParseException) IndeterminateValue(org.n52.shetland.ogc.gml.time.IndeterminateValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) DateTime(org.joda.time.DateTime)

Example 5 with DateTimeHelper.parseIsoString2DateTime

use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.

the class FieldDecoderTest method before.

@Before
public void before() throws DecodingException {
    this.decoder = new FieldDecoder();
    this.timeStart = DateTimeHelper.parseIsoString2DateTime(TIME_START);
    this.timeEnd = DateTimeHelper.parseIsoString2DateTime(TIME_END);
    this.validator = JSONValidator.getInstance();
}
Also used : FieldDecoder(org.n52.svalbard.decode.json.FieldDecoder) Before(org.junit.Before)

Aggregations

DateTime (org.joda.time.DateTime)6 RangeValue (org.n52.shetland.ogc.swe.RangeValue)4 XmlObject (org.apache.xmlbeans.XmlObject)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IndeterminateValue (org.n52.shetland.ogc.gml.time.IndeterminateValue)2 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)2 SweAllowedTimes (org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes)2 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)2 DateTimeParseException (org.n52.shetland.util.DateTimeParseException)2 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)1 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)1 Before (org.junit.Before)1 Test (org.junit.Test)1 SweField (org.n52.shetland.ogc.swe.SweField)1 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)1 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)1 FieldDecoder (org.n52.svalbard.decode.json.FieldDecoder)1