Search in sources :

Example 1 with XmlRuntimeException

use of org.apache.xmlbeans.XmlRuntimeException in project arctic-sea by 52North.

the class GmlEncoderv311 method createTimePeriodType.

/**
 * Creates a XML TimePeriod from the SOS time object.
 *
 * @param timePeriod
 *            SOS time object
 * @param timePeriodType
 *            the xml time period (may be {@code null})
 * @return XML TimePeriod
 *
 * @throws EncodingException
 *             if an error occurs.
 */
private TimePeriodType createTimePeriodType(TimePeriod timePeriod, TimePeriodType timePeriodType) throws EncodingException {
    try {
        TimePeriodType tpt;
        if (timePeriodType == null) {
            tpt = TimePeriodType.Factory.newInstance(getXmlOptions());
        } else {
            tpt = timePeriodType;
        }
        if (timePeriod.getGmlId() != null && !timePeriod.getGmlId().isEmpty()) {
            tpt.setId(timePeriod.getGmlId());
        }
        tpt.setBeginPosition(createTimePositionType(timePeriod.getStartTimePosition()));
        tpt.setEndPosition(createTimePositionType(timePeriod.getEndTimePosition()));
        return tpt;
    } catch (XmlRuntimeException | XmlValueDisconnectedException x) {
        throw new EncodingException("Error while creating TimePeriod!", x);
    }
}
Also used : XmlRuntimeException(org.apache.xmlbeans.XmlRuntimeException) XmlValueDisconnectedException(org.apache.xmlbeans.impl.values.XmlValueDisconnectedException) TimePeriodType(net.opengis.gml.TimePeriodType) EncodingException(org.n52.svalbard.encode.exception.EncodingException)

Aggregations

TimePeriodType (net.opengis.gml.TimePeriodType)1 XmlRuntimeException (org.apache.xmlbeans.XmlRuntimeException)1 XmlValueDisconnectedException (org.apache.xmlbeans.impl.values.XmlValueDisconnectedException)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1