Search in sources :

Example 1 with PhenomenonEntity

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

the class ObservablePropertyDAO method getObservableProperty.

private PhenomenonEntity getObservableProperty(String identifier, Map<String, PhenomenonEntity> observableProperties, Session session) {
    // TODO check if this is still required
    if (identifier == null) {
        return null;
    }
    PhenomenonEntity observableProperty = observableProperties.get(identifier);
    if (observableProperty != null) {
        return observableProperty;
    }
    observableProperty = getObservablePropertyForIdentifier(identifier, session);
    observableProperties.put(identifier, observableProperty);
    return observableProperty;
}
Also used : I18nPhenomenonEntity(org.n52.series.db.beans.i18n.I18nPhenomenonEntity) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity)

Example 2 with PhenomenonEntity

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

the class ObservablePropertyDAO method getObservableProperties.

/**
 * Get observable property objects for observable property identifiers
 *
 * @param identifiers
 *            Observable property identifiers
 * @param session
 *            Hibernate session
 * @return Observable property objects
 */
@SuppressWarnings("unchecked")
public List<PhenomenonEntity> getObservableProperties(final List<String> identifiers, final Session session) {
    Criteria criteria = session.createCriteria(PhenomenonEntity.class).add(Restrictions.in(PhenomenonEntity.IDENTIFIER, identifiers));
    LOGGER.trace("QUERY getObservableProperties(identifiers): {}", HibernateHelper.getSqlString(criteria));
    return criteria.list();
}
Also used : I18nPhenomenonEntity(org.n52.series.db.beans.i18n.I18nPhenomenonEntity) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 3 with PhenomenonEntity

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

the class ObservablePropertyDAO method insertNonExisting.

protected void insertNonExisting(AbstractPhenomenon sosObsProp, Map<String, PhenomenonEntity> existing, Session session) throws HibernateException {
    if (!existing.containsKey(sosObsProp.getIdentifier())) {
        PhenomenonEntity obsProp = new PhenomenonEntity();
        addIdentifierNameDescription(sosObsProp, obsProp, session);
        session.save(obsProp);
        session.flush();
        session.refresh(obsProp);
        existing.put(obsProp.getIdentifier(), obsProp);
    }
    if (sosObsProp instanceof OmCompositePhenomenon) {
        insertNonExisting(((OmCompositePhenomenon) sosObsProp).getPhenomenonComponents(), existing, session);
    }
}
Also used : OmCompositePhenomenon(org.n52.shetland.ogc.om.OmCompositePhenomenon) I18nPhenomenonEntity(org.n52.series.db.beans.i18n.I18nPhenomenonEntity) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity)

Example 4 with PhenomenonEntity

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

the class ObservablePropertyDAO method getObservablePropertiesForIdentifiers.

/**
 * Get observable properties by identifiers
 *
 * @param identifiers
 *            The observable property identifiers
 * @param session
 *            Hibernate session
 * @return Observable property objects
 */
@SuppressWarnings("unchecked")
public List<PhenomenonEntity> getObservablePropertiesForIdentifiers(final Collection<String> identifiers, final Session session) {
    Criteria criteria = session.createCriteria(PhenomenonEntity.class).add(Restrictions.in(PhenomenonEntity.IDENTIFIER, identifiers));
    LOGGER.trace("QUERY getObservablePropertiesForIdentifiers(identifiers): {}", HibernateHelper.getSqlString(criteria));
    return (List<PhenomenonEntity>) criteria.list();
}
Also used : I18nPhenomenonEntity(org.n52.series.db.beans.i18n.I18nPhenomenonEntity) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) ArrayList(java.util.ArrayList) List(java.util.List) Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 5 with PhenomenonEntity

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

the class ObservablePropertyDAO method insertHierachy.

protected void insertHierachy(OmCompositePhenomenon parent, Map<String, PhenomenonEntity> existing, Session session) throws HibernateException {
    PhenomenonEntity parentObsProp = getObservableProperty(parent.getIdentifier(), existing, session);
    for (OmObservableProperty child : parent) {
        PhenomenonEntity childObsProp = getObservableProperty(child.getIdentifier(), existing, session);
        childObsProp.addParent(parentObsProp);
        session.update(childObsProp);
    }
    // do not save the parent, as it would result in a duplicate key
    // error...
    session.flush();
    session.refresh(parentObsProp);
}
Also used : I18nPhenomenonEntity(org.n52.series.db.beans.i18n.I18nPhenomenonEntity) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Aggregations

PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)28 I18nPhenomenonEntity (org.n52.series.db.beans.i18n.I18nPhenomenonEntity)11 DatasetEntity (org.n52.series.db.beans.DatasetEntity)7 ProcedureEntity (org.n52.series.db.beans.ProcedureEntity)7 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)6 HibernateException (org.hibernate.HibernateException)5 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)5 HashMap (java.util.HashMap)4 Criteria (org.hibernate.Criteria)4 Session (org.hibernate.Session)4 Transaction (org.hibernate.Transaction)4 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)4 CategoryEntity (org.n52.series.db.beans.CategoryEntity)4 FormatEntity (org.n52.series.db.beans.FormatEntity)4 OfferingEntity (org.n52.series.db.beans.OfferingEntity)4 PlatformEntity (org.n52.series.db.beans.PlatformEntity)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 LinkedList (java.util.LinkedList)3 DatastreamEntity (org.n52.series.db.beans.sta.DatastreamEntity)3