Search in sources :

Example 1 with HibernateChunkSeriesStreamingValue

use of org.n52.sos.ds.hibernate.values.series.HibernateChunkSeriesStreamingValue in project SOS by 52North.

the class GetObservationByIdDaoImpl method querySeriesObservation.

/**
 * Query the series observations for streaming datasource
 *
 * @param request
 *            The GetObservation request
 * @param session
 *            Hibernate Session
 * @return List of internal observations
 * @throws OwsExceptionReport
 *             If an error occurs.
 * @throws ConverterException
 *             If an error occurs during sensor description creation.
 */
private List<OmObservation> querySeriesObservation(GetObservationByIdRequest request, final Session session) throws OwsExceptionReport, ConverterException {
    final long start = System.currentTimeMillis();
    final List<OmObservation> result = new LinkedList<OmObservation>();
    // get valid featureOfInterest identifier
    List<DatasetEntity> serieses = daoFactory.getSeriesDAO().getSeries(request, session);
    checkMaxNumberOfReturnedSeriesSize(serieses.size());
    for (DatasetEntity series : serieses) {
        ObservationStream createSosObservationFromSeries = HibernateObservationUtilities.createSosObservationFromSeries(series, request, getProcedureDescriptionFormat(request.getResponseFormat()), observationCreatorContext, session);
        OmObservation observationTemplate = createSosObservationFromSeries.next();
        HibernateSeriesStreamingValue streamingValue = new HibernateChunkSeriesStreamingValue(sessionHolder.getConnectionProvider(), daoFactory, request, series.getId(), observationCreatorContext.getBindingRepository(), getChunkSize());
        streamingValue.setResponseFormat(request.getResponseFormat());
        streamingValue.setObservationTemplate(observationTemplate);
        observationTemplate.setValue(streamingValue);
        result.add(observationTemplate);
    }
    LOGGER.debug("Time to query observations needs {} ms!", System.currentTimeMillis() - start);
    return result;
}
Also used : HibernateChunkSeriesStreamingValue(org.n52.sos.ds.hibernate.values.series.HibernateChunkSeriesStreamingValue) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) DatasetEntity(org.n52.series.db.beans.DatasetEntity) OmObservation(org.n52.shetland.ogc.om.OmObservation) HibernateSeriesStreamingValue(org.n52.sos.ds.hibernate.values.series.HibernateSeriesStreamingValue) LinkedList(java.util.LinkedList)

Example 2 with HibernateChunkSeriesStreamingValue

use of org.n52.sos.ds.hibernate.values.series.HibernateChunkSeriesStreamingValue in project SOS by 52North.

the class GetObservationDaoImpl method querySeriesObservationForStreaming.

/**
 * Query the series observations for streaming datasource
 *
 * @param request
 *            The GetObservation request
 * @param session
 *            Hibernate Session
 * @return List of internal observations
 * @throws OwsExceptionReport
 *             If an error occurs.
 * @throws ConverterException
 *             If an error occurs during sensor description creation.
 */
private List<OmObservation> querySeriesObservationForStreaming(GetObservationRequest request, GetObservationResponse response, Session session) throws OwsExceptionReport, ConverterException {
    final long start = System.currentTimeMillis();
    final List<OmObservation> result = new LinkedList<OmObservation>();
    List<String> features = request.getFeatureIdentifiers();
    Criterion temporalFilterCriterion = getTemporalFilterCriterion(request);
    List<DatasetEntity> serieses = daoFactory.getSeriesDAO().getSeries(request, features, session);
    checkMaxNumberOfReturnedSeriesSize(serieses.size());
    int maxNumberOfValuesPerSeries = getMaxNumberOfValuesPerSeries(serieses.size());
    for (DatasetEntity series : serieses) {
        ObservationStream createSosObservationFromSeries = HibernateObservationUtilities.createSosObservationFromSeries(series, request, getRequestedLocale(request), getProcedureDescriptionFormat(request.getResponseFormat()), observationCreatorContext, session);
        OmObservation observationTemplate = createSosObservationFromSeries.next();
        HibernateSeriesStreamingValue streamingValue = new HibernateChunkSeriesStreamingValue(sessionHolder.getConnectionProvider(), daoFactory, request, series.getId(), observationCreatorContext.getBindingRepository(), getChunkSize());
        streamingValue.setResponseFormat(request.getResponseFormat());
        streamingValue.setTemporalFilterCriterion(temporalFilterCriterion);
        streamingValue.setObservationTemplate(observationTemplate);
        streamingValue.setMaxNumberOfValues(maxNumberOfValuesPerSeries);
        observationTemplate.setValue(streamingValue);
        result.add(observationTemplate);
    }
    ObservationTimeExtrema timeExtrema = daoFactory.getValueTimeDAO().getTimeExtremaForSeries(serieses, temporalFilterCriterion, session);
    if (timeExtrema.isSetPhenomenonTimes()) {
        response.setGlobalObservationValues(new GlobalObservationResponseValues().setPhenomenonTime(timeExtrema.getPhenomenonTime()));
    }
    LOGGER.debug(LOG_TIME_TO_QUERY, System.currentTimeMillis() - start);
    return result;
}
Also used : DatasetEntity(org.n52.series.db.beans.DatasetEntity) OmObservation(org.n52.shetland.ogc.om.OmObservation) LinkedList(java.util.LinkedList) HibernateChunkSeriesStreamingValue(org.n52.sos.ds.hibernate.values.series.HibernateChunkSeriesStreamingValue) ObservationTimeExtrema(org.n52.sos.ds.hibernate.util.ObservationTimeExtrema) Criterion(org.hibernate.criterion.Criterion) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) HibernateSeriesStreamingValue(org.n52.sos.ds.hibernate.values.series.HibernateSeriesStreamingValue) GlobalObservationResponseValues(org.n52.shetland.ogc.sos.response.GlobalObservationResponseValues)

Aggregations

LinkedList (java.util.LinkedList)2 DatasetEntity (org.n52.series.db.beans.DatasetEntity)2 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)2 OmObservation (org.n52.shetland.ogc.om.OmObservation)2 HibernateChunkSeriesStreamingValue (org.n52.sos.ds.hibernate.values.series.HibernateChunkSeriesStreamingValue)2 HibernateSeriesStreamingValue (org.n52.sos.ds.hibernate.values.series.HibernateSeriesStreamingValue)2 Criterion (org.hibernate.criterion.Criterion)1 GlobalObservationResponseValues (org.n52.shetland.ogc.sos.response.GlobalObservationResponseValues)1 ObservationTimeExtrema (org.n52.sos.ds.hibernate.util.ObservationTimeExtrema)1