Пример #1
0
 private List<?> executeNamedQuery(GetDataAvailabilityRequest req, Session session) {
   final boolean features = req.isSetFeaturesOfInterest();
   final boolean observableProperties = req.isSetObservedProperties();
   final boolean procedures = req.isSetProcedures();
   String namedQueryName = null;
   Map<String, Collection<String>> parameter = Maps.newHashMap();
   // all
   if (features && observableProperties && procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES_PROCEDURES_OBSERVED_PROPERTIES;
     parameter.put(FEATURES, req.getFeaturesOfInterest());
     parameter.put(OBSERVABLE_PROPERTIES, req.getObservedProperties());
     parameter.put(PROCEDURES, req.getProcedures());
   }
   // observableProperties and procedures
   else if (!features && observableProperties && procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_PROCEDURES_OBSERVED_PROPERTIES;
     parameter.put(OBSERVABLE_PROPERTIES, req.getObservedProperties());
     parameter.put(PROCEDURES, req.getProcedures());
   }
   // only observableProperties
   else if (!features && observableProperties && !procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_OBSERVED_PROPERTIES;
     parameter.put(OBSERVABLE_PROPERTIES, req.getObservedProperties());
   }
   // only procedures
   else if (!features && !observableProperties && procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_PROCEDURES;
     parameter.put(PROCEDURES, req.getProcedures());
   }
   // features and observableProperties
   else if (features && observableProperties && !procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES_OBSERVED_PROPERTIES;
     parameter.put(FEATURES, req.getFeaturesOfInterest());
     parameter.put(OBSERVABLE_PROPERTIES, req.getObservedProperties());
   }
   // features and procedures
   else if (features && !observableProperties && procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES_PROCEDURES;
     parameter.put(FEATURES, req.getFeaturesOfInterest());
     parameter.put(PROCEDURES, req.getProcedures());
   }
   // only features
   else if (features && !observableProperties && procedures) {
     namedQueryName = SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES;
     parameter.put(FEATURES, req.getFeaturesOfInterest());
   }
   if (StringHelper.isNotEmpty(namedQueryName)) {
     Query namedQuery = session.getNamedQuery(namedQueryName);
     for (String key : parameter.keySet()) {
       namedQuery.setParameterList(key, parameter.get(key));
     }
     LOGGER.debug(
         "QUERY getProceduresForFeatureOfInterest(feature) with NamedQuery: {}", namedQuery);
     namedQuery.setResultTransformer(new DataAvailabilityTransformer(session));
     return namedQuery.list();
   }
   return Lists.newLinkedList();
 }
Пример #2
0
 /**
  * GetDataAvailability processing is series mapping is supported.
  *
  * @param request GetDataAvailability request
  * @param session Hibernate session
  * @return List of valid data availability information
  * @throws OwsExceptionReport If an error occurs
  */
 private List<?> querySeriesDataAvailabilities(GetDataAvailabilityRequest request, Session session)
     throws OwsExceptionReport {
   List<DataAvailability> dataAvailabilityValues = Lists.newLinkedList();
   Map<String, ReferenceType> procedures = new HashMap<String, ReferenceType>();
   Map<String, ReferenceType> observableProperties = new HashMap<String, ReferenceType>();
   Map<String, ReferenceType> featuresOfInterest = new HashMap<String, ReferenceType>();
   AbstractSeriesObservationDAO seriesObservationDAO = getSeriesObservationDAO();
   SeriesMinMaxTransformer seriesMinMaxTransformer = new SeriesMinMaxTransformer();
   boolean supportsNamedQuery =
       HibernateHelper.isNamedQuerySupported(SQL_QUERY_GET_DATA_AVAILABILITY_FOR_SERIES, session);
   for (final Series series :
       DaoFactory.getInstance()
           .getSeriesDAO()
           .getSeries(
               request.getProcedures(),
               request.getObservedProperties(),
               request.getFeaturesOfInterest(),
               session)) {
     TimePeriod timePeriod = null;
     if (!request.isSetOfferings()) {
       // get time information from series object
       if (series.isSetFirstLastTime()) {
         timePeriod = new TimePeriod(series.getFirstTimeStamp(), series.getLastTimeStamp());
       }
       // get time information from a named query
       else if (timePeriod == null && supportsNamedQuery) {
         timePeriod =
             getTimePeriodFromNamedQuery(series.getSeriesId(), seriesMinMaxTransformer, session);
       }
     }
     // get time information from SeriesGetDataAvailability mapping if
     // supported
     if (timePeriod == null) {
       SeriesObservationTimeDAO seriesObservationTimeDAO =
           (SeriesObservationTimeDAO) DaoFactory.getInstance().getObservationTimeDAO();
       timePeriod =
           getTimePeriodFromSeriesGetDataAvailability(
               seriesObservationTimeDAO, series, request, seriesMinMaxTransformer, session);
     }
     // create DataAvailabilities
     if (timePeriod != null && !timePeriod.isEmpty()) {
       DataAvailability dataAvailability =
           new DataAvailability(
               getProcedureReference(series, procedures),
               getObservedPropertyReference(series, observableProperties),
               getFeatureOfInterestReference(series, featuresOfInterest, session),
               timePeriod);
       if (isShowCount(request)) {
         dataAvailability.setCount(getCountFor(series, request, session));
       }
       if (isIncludeResultTime(request)) {
         dataAvailability.setResultTimes(
             getResultTimesFromSeriesObservation(seriesObservationDAO, series, request, session));
       }
       dataAvailabilityValues.add(dataAvailability);
     }
   }
   return dataAvailabilityValues;
 }