Search in sources :

Example 1 with ObservationTimeExtrema

use of org.n52.sos.ds.hibernate.util.ObservationTimeExtrema in project SOS by 52North.

the class EReportingValueTimeDAO method parseMinMaxPhenomenonTime.

private ObservationTimeExtrema parseMinMaxPhenomenonTime(Object[] result) {
    ObservationTimeExtrema ote = new ObservationTimeExtrema();
    if (result != null) {
        ote.setMinPhenomenonTime(DateTimeHelper.makeDateTime(result[0]));
        ote.setMaxPhenomenonTime(DateTimeHelper.makeDateTime(result[1]));
    }
    return ote;
}
Also used : ObservationTimeExtrema(org.n52.sos.ds.hibernate.util.ObservationTimeExtrema)

Example 2 with ObservationTimeExtrema

use of org.n52.sos.ds.hibernate.util.ObservationTimeExtrema in project SOS by 52North.

the class HibernateSeriesStreamingValue method queryTimes.

@Override
protected void queryTimes() {
    Session session = null;
    try {
        session = getSession();
        ObservationTimeExtrema timeExtrema = seriesValueTimeDAO.getTimeExtremaForSeries((GetObservationRequest) request, series, temporalFilterCriterion, session);
        if (timeExtrema.isSetPhenomenonTimes()) {
            setPhenomenonTime(GmlHelper.createTime(timeExtrema.getMinPhenomenonTime(), timeExtrema.getMaxPhenomenonTime()));
        }
        if (timeExtrema.isSetResultTimes()) {
            setResultTime(new TimeInstant(timeExtrema.getMaxResultTime()));
        }
        if (timeExtrema.isSetValidTime()) {
            setValidTime(GmlHelper.createTime(timeExtrema.getMinValidTime(), timeExtrema.getMaxValidTime()));
        }
    } catch (OwsExceptionReport owse) {
        LOGGER.error("Error while querying times", owse);
    } finally {
        returnSession(session);
    }
}
Also used : ObservationTimeExtrema(org.n52.sos.ds.hibernate.util.ObservationTimeExtrema) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Session(org.hibernate.Session)

Example 3 with ObservationTimeExtrema

use of org.n52.sos.ds.hibernate.util.ObservationTimeExtrema in project SOS by 52North.

the class AbstractSeriesValueTimeDAO method parseMinMaxPhenomenonTime.

private ObservationTimeExtrema parseMinMaxPhenomenonTime(Object[] result) {
    ObservationTimeExtrema ote = new ObservationTimeExtrema();
    if (result != null) {
        ote.setMinPhenomenonTime(DateTimeHelper.makeDateTime(result[0]));
        ote.setMaxPhenomenonTime(DateTimeHelper.makeDateTime(result[1]));
    }
    return ote;
}
Also used : ObservationTimeExtrema(org.n52.sos.ds.hibernate.util.ObservationTimeExtrema)

Example 4 with ObservationTimeExtrema

use of org.n52.sos.ds.hibernate.util.ObservationTimeExtrema in project SOS by 52North.

the class AbstractSeriesValueTimeDAO method getTimeExtremaForSeries.

/**
 * Get {@link ObservationTimeExtrema} for a dataset id with temporal
 * filter.
 *
 * @param request
 *            {@link AbstractObservationRequest} request
 * @param series
 *            {@link Set} of dataset ids to get time extrema for
 * @param temporalFilterCriterion
 *            Temporal filter
 * @param session
 *            Hibernate session
 * @return Time extrema for dataset ids
 * @throws OwsExceptionReport
 *             If an error occurs
 */
public ObservationTimeExtrema getTimeExtremaForSeries(AbstractObservationRequest request, Set<Long> series, Criterion temporalFilterCriterion, Session session) throws OwsExceptionReport {
    if (request instanceof GetObservationRequest && ((GetObservationRequest) request).hasResultFilter()) {
        ObservationTimeExtrema ote = new ObservationTimeExtrema();
        for (SubQueryIdentifier identifier : ResultFilterRestrictions.getSubQueryIdentifier(getResultFilterClasses())) {
            Criteria c = getSeriesValueCriteriaFor(request, series, temporalFilterCriterion, null, session);
            checkAndAddResultFilterCriterion(c, (GetObservationRequest) request, identifier, session, new StringBuilder());
            addMinMaxTimeProjection(c);
            ote.expand(parseMinMaxTime((Object[]) c.uniqueResult()));
        }
        return ote;
    } else {
        Criteria c = getSeriesValueCriteriaFor(request, series, temporalFilterCriterion, null, session);
        addMinMaxTimeProjection(c);
        LOGGER.trace(LOG_QUERY_TIME_EXTREMA, HibernateHelper.getSqlString(c));
        return parseMinMaxTime((Object[]) c.uniqueResult());
    }
}
Also used : ObservationTimeExtrema(org.n52.sos.ds.hibernate.util.ObservationTimeExtrema) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) Criteria(org.hibernate.Criteria) SubQueryIdentifier(org.n52.sos.ds.hibernate.util.ResultFilterRestrictions.SubQueryIdentifier)

Example 5 with ObservationTimeExtrema

use of org.n52.sos.ds.hibernate.util.ObservationTimeExtrema in project SOS by 52North.

the class AbstractSeriesValueTimeDAO method parseMinMaxTime.

private ObservationTimeExtrema parseMinMaxTime(Object[] result) {
    ObservationTimeExtrema ote = new ObservationTimeExtrema();
    if (result != null) {
        ote.setMinPhenomenonTime(DateTimeHelper.makeDateTime(result[0]));
        ote.setMaxPhenomenonTime(DateTimeHelper.makeDateTime(result[1]));
        ote.setMaxResultTime(DateTimeHelper.makeDateTime(result[2]));
        if (result.length == 5) {
            ote.setMinValidTime(DateTimeHelper.makeDateTime(result[3]));
            ote.setMaxValidTime(DateTimeHelper.makeDateTime(result[4]));
        }
    }
    return ote;
}
Also used : ObservationTimeExtrema(org.n52.sos.ds.hibernate.util.ObservationTimeExtrema)

Aggregations

ObservationTimeExtrema (org.n52.sos.ds.hibernate.util.ObservationTimeExtrema)7 Criteria (org.hibernate.Criteria)2 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)2 SubQueryIdentifier (org.n52.sos.ds.hibernate.util.ResultFilterRestrictions.SubQueryIdentifier)2 LinkedList (java.util.LinkedList)1 Session (org.hibernate.Session)1 Criterion (org.hibernate.criterion.Criterion)1 DatasetEntity (org.n52.series.db.beans.DatasetEntity)1 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)1 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 GlobalObservationResponseValues (org.n52.shetland.ogc.sos.response.GlobalObservationResponseValues)1 HibernateChunkSeriesStreamingValue (org.n52.sos.ds.hibernate.values.series.HibernateChunkSeriesStreamingValue)1 HibernateSeriesStreamingValue (org.n52.sos.ds.hibernate.values.series.HibernateSeriesStreamingValue)1