예제 #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
 private boolean checkForNamedQueries(GetDataAvailabilityRequest req, Session session) {
   final boolean features = req.isSetFeaturesOfInterest();
   final boolean observableProperties = req.isSetObservedProperties();
   final boolean procedures = req.isSetProcedures();
   // all
   if (features && observableProperties && procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES_PROCEDURES_OBSERVED_PROPERTIES, session);
   }
   // observableProperties and procedures
   else if (!features && observableProperties && procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_PROCEDURES_OBSERVED_PROPERTIES, session);
   }
   // only observableProperties
   else if (!features && observableProperties && !procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_OBSERVED_PROPERTIES, session);
   }
   // only procedures
   else if (!features && !observableProperties && procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_PROCEDURES, session);
   }
   // features and observableProperties
   else if (features && observableProperties && !procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES_OBSERVED_PROPERTIES, session);
   }
   // features and procedures
   else if (features && !observableProperties && procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES_PROCEDURES, session);
   }
   // only features
   else if (features && !observableProperties && procedures) {
     return HibernateHelper.isNamedQuerySupported(
         SQL_QUERY_GET_DATA_AVAILABILITY_FOR_FEATURES, session);
   }
   return false;
 }