use of org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO in project SOS by 52North.
the class ProcedureDAO method getProcedureTimeExtrema.
@SuppressWarnings("unchecked")
public Map<String, TimeExtrema> getProcedureTimeExtrema(Session session) throws OwsExceptionReport {
List<ProcedureTimeExtrema> results = null;
if (isAllProcedureTimeExtremaNamedQuerySupported(session)) {
Query namedQuery = session.getNamedQuery(SQL_QUERY_GET_ALL_PROCEDURE_TIME_EXTREMA);
LOGGER.trace("QUERY getProcedureTimeExtrema() with NamedQuery '{}': {}", SQL_QUERY_GET_ALL_PROCEDURE_TIME_EXTREMA, namedQuery.getQueryString());
namedQuery.setResultTransformer(transformer);
results = namedQuery.list();
} else {
AbstractSeriesDAO seriesDAO = getDaoFactory().getSeriesDAO();
if (seriesDAO != null) {
Criteria c = seriesDAO.getDefaultSeriesCriteria(session);
c.createAlias(DatasetEntity.PROPERTY_PROCEDURE, "p");
c.setProjection(Projections.projectionList().add(Projections.groupProperty(P_PREFIX + ProcedureEntity.IDENTIFIER)).add(Projections.min(DatasetEntity.PROPERTY_FIRST_VALUE_AT)).add(Projections.max(DatasetEntity.PROPERTY_LAST_VALUE_AT)));
LOGGER.trace(QUERY_TIME_EXTREMA_LOG_TEMPLATE, HibernateHelper.getSqlString(c));
c.setResultTransformer(transformer);
results = c.list();
}
if (checkHasNoProcedureTimeResult(results)) {
AbstractObservationDAO observationDAO = getDaoFactory().getObservationDAO();
Criteria criteria = observationDAO.getDefaultObservationTimeCriteria(session);
String alias = observationDAO.addProcedureAlias(criteria);
criteria.setProjection(Projections.projectionList().add(Projections.groupProperty(alias + ProcedureEntity.IDENTIFIER)).add(Projections.min(DataEntity.PROPERTY_SAMPLING_TIME_START)).add(Projections.max(DataEntity.PROPERTY_SAMPLING_TIME_START)).add(Projections.max(DataEntity.PROPERTY_SAMPLING_TIME_START)));
LOGGER.trace(QUERY_TIME_EXTREMA_LOG_TEMPLATE, HibernateHelper.getSqlString(criteria));
criteria.setResultTransformer(transformer);
results = criteria.list();
}
}
Map<String, TimeExtrema> procedureTimeExtrema = Maps.newHashMap();
if (results != null && !results.isEmpty()) {
for (ProcedureTimeExtrema pte : results) {
if (pte != null && pte.isSetProcedure()) {
procedureTimeExtrema.put(pte.getProcedure(), pte);
}
}
}
return procedureTimeExtrema;
}
use of org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO in project SOS by 52North.
the class DeleteDataHelper method getDatasetForOffering.
default List<DatasetEntity> getDatasetForOffering(OfferingEntity offering, Session session) {
AbstractSeriesDAO seriesDAO = getDaoFactory().getSeriesDAO();
Criteria c = seriesDAO.getDefaultAllSeriesCriteria(session);
seriesDAO.addOfferingToCriteria(c, offering);
return c.list();
}
use of org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO in project SOS by 52North.
the class InsertResultHandler method insertObservationConstellationForProfiles.
private DatasetEntity insertObservationConstellationForProfiles(AbstractSeriesDAO obsConstDao, FormatDAO obsTypeDao, OmObservation o, Session session) throws OwsExceptionReport {
ProcedureEntity procedure = getDaoFactory().getProcedureDAO().getProcedureForIdentifier(o.getObservationConstellation().getProcedureIdentifier(), session);
PhenomenonEntity observableProperty = getDaoFactory().getObservablePropertyDAO().getOrInsertObservableProperty(o.getObservationConstellation().getObservableProperty(), session);
OfferingEntity offering = getDaoFactory().getOfferingDAO().getOfferingForIdentifier(o.getObservationConstellation().getOfferings().iterator().next(), session);
CategoryEntity category = getDaoFactory().getCategoryDAO().getOrInsertCategory(observableProperty, session);
DatasetEntity oc = obsConstDao.checkOrInsertSeries(procedure, observableProperty, offering, category, false, session);
if (o.getObservationConstellation().isSetObservationType()) {
oc.setOmObservationType(obsTypeDao.getFormatEntityObject(o.getObservationConstellation().getObservationType(), session));
}
return oc;
}
use of org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO in project SOS by 52North.
the class DeleteDataHelper method getDatasetForProcedure.
default List<DatasetEntity> getDatasetForProcedure(ProcedureEntity procedure, Session session) {
AbstractSeriesDAO seriesDAO = getDaoFactory().getSeriesDAO();
Criteria c = seriesDAO.getDefaultAllSeriesCriteria(session);
seriesDAO.addProcedureToCriteria(c, procedure);
return c.list();
}
use of org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO in project SOS by 52North.
the class FeatureOfInterestDAO method getIdentifiersForOffering.
/**
* Get featureOfInterest identifiers for an offering identifier
*
* @param offering
* Offering identifier
* @param session
* Hibernate session Hibernate session
* @return FeatureOfInterest identifiers for offering
* @throws CodedException If an error occurs
*/
@SuppressWarnings({ "unchecked" })
public List<String> getIdentifiersForOffering(String offering, Session session) throws OwsExceptionReport {
if (HibernateHelper.isNamedQuerySupported(SQL_QUERY_GET_FEATURE_OF_INTEREST_IDENTIFIER_FOR_OFFERING, session)) {
Query namedQuery = session.getNamedQuery(SQL_QUERY_GET_FEATURE_OF_INTEREST_IDENTIFIER_FOR_OFFERING);
namedQuery.setParameter(OFFERING, offering);
LOGGER.trace("QUERY getFeatureOfInterestIdentifiersForOffering(offeringIdentifiers) with NamedQuery: {}", SQL_QUERY_GET_FEATURE_OF_INTEREST_IDENTIFIER_FOR_OFFERING);
return namedQuery.list();
} else {
AbstractSeriesDAO datasetDAO = getDaoFactory().getSeriesDAO();
Criteria c = datasetDAO.getDefaultSeriesCriteria(session).createCriteria(DatasetEntity.PROPERTY_FEATURE).setProjection(Projections.distinct(Projections.property(AbstractFeatureEntity.IDENTIFIER)));
getDaoFactory().getOfferingDAO().addOfferingRestricionForObservation(c, offering);
LOGGER.trace("QUERY getFeatureOfInterestIdentifiersForOffering(offeringIdentifiers): {}", HibernateHelper.getSqlString(c));
return c.list();
}
}
Aggregations