Search in sources :

Example 1 with OfferingEntity

use of org.n52.series.db.beans.OfferingEntity in project SOS by 52North.

the class OfferingDAO method getOfferingForIdentifier.

/**
 * Get Offering object for identifier
 *
 * @param identifier
 *            Offering identifier
 * @param session
 *            Hibernate session
 * @return Offering object
 */
public OfferingEntity getOfferingForIdentifier(final String identifier, final Session session) {
    Criteria criteria = getDefaultCriteria(session).add(Restrictions.eq(OfferingEntity.IDENTIFIER, identifier));
    LOGGER.debug("QUERY getOfferingForIdentifier(identifier): {}", HibernateHelper.getSqlString(criteria));
    return (OfferingEntity) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) OfferingEntity(org.n52.series.db.beans.OfferingEntity)

Example 2 with OfferingEntity

use of org.n52.series.db.beans.OfferingEntity in project SOS by 52North.

the class OfferingDAO method getTOfferingForIdentifier.

/**
 * Get transactional offering object for identifier
 *
 * @param identifier
 *            Offering identifier
 * @param session
 *            Hibernate session
 * @return Transactional offering object
 */
public OfferingEntity getTOfferingForIdentifier(final String identifier, final Session session) {
    Criteria criteria = getDefaultTransactionalCriteria(session).add(Restrictions.eq(OfferingEntity.IDENTIFIER, identifier));
    LOGGER.debug("QUERY getTOfferingForIdentifier(): {}", HibernateHelper.getSqlString(criteria));
    return (OfferingEntity) criteria.uniqueResult();
}
Also used : Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) OfferingEntity(org.n52.series.db.beans.OfferingEntity)

Example 3 with OfferingEntity

use of org.n52.series.db.beans.OfferingEntity in project SOS by 52North.

the class OfferingDAO method updateParentOfferings.

public void updateParentOfferings(Set<String> parentOfferings, OfferingEntity hOffering, Session session) {
    for (String identifier : parentOfferings) {
        OfferingEntity offering = getOfferingForIdentifier(identifier, session);
        if (!offering.getChildren().contains(hOffering)) {
            offering.addChild(hOffering);
            session.saveOrUpdate(offering);
            session.flush();
            session.refresh(offering);
        }
    }
}
Also used : OfferingEntity(org.n52.series.db.beans.OfferingEntity)

Example 4 with OfferingEntity

use of org.n52.series.db.beans.OfferingEntity 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();
}
Also used : Criteria(org.hibernate.Criteria) AbstractSeriesDAO(org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO)

Example 5 with OfferingEntity

use of org.n52.series.db.beans.OfferingEntity 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;
}
Also used : ProcedureEntity(org.n52.series.db.beans.ProcedureEntity) DatasetEntity(org.n52.series.db.beans.DatasetEntity) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) OfferingEntity(org.n52.series.db.beans.OfferingEntity) CategoryEntity(org.n52.series.db.beans.CategoryEntity)

Aggregations

OfferingEntity (org.n52.series.db.beans.OfferingEntity)23 DatasetEntity (org.n52.series.db.beans.DatasetEntity)10 ProcedureEntity (org.n52.series.db.beans.ProcedureEntity)10 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)8 HibernateException (org.hibernate.HibernateException)7 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)7 DbQuery (org.n52.series.db.dao.DbQuery)7 HashSet (java.util.HashSet)6 Session (org.hibernate.Session)6 DataAccessException (org.n52.series.db.DataAccessException)6 SosOffering (org.n52.shetland.ogc.sos.SosOffering)6 ArrayList (java.util.ArrayList)5 Collection (java.util.Collection)5 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)5 Collectors.toCollection (java.util.stream.Collectors.toCollection)5 FormatEntity (org.n52.series.db.beans.FormatEntity)5 Locale (java.util.Locale)4 Set (java.util.Set)4 TreeSet (java.util.TreeSet)4