Search in sources :

Example 16 with DataEntity

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

the class ObservationPersister method visit.

@Override
public DataEntity<?> visit(ReferenceValue value) throws OwsExceptionReport {
    ReferencedDataEntity reference = observationFactory.reference();
    reference.setName(value.getValue().getTitle());
    return persist(reference, value.getValue().getHref());
}
Also used : ReferencedDataEntity(org.n52.series.db.beans.ReferencedDataEntity)

Example 17 with DataEntity

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

the class ObservationPersister method visit.

@Override
public DataEntity<?> visit(ComplexValue value) throws OwsExceptionReport {
    ComplexDataEntity complex = observationFactory.complex();
    DataEntity complexyDataEntity = persist((DataEntity) complex, new HashSet<DataEntity<?>>());
    persistChildren(value.getValue(), complexyDataEntity);
    return complexyDataEntity;
}
Also used : DataEntity(org.n52.series.db.beans.DataEntity) DataArrayDataEntity(org.n52.series.db.beans.DataArrayDataEntity) GeometryDataEntity(org.n52.series.db.beans.GeometryDataEntity) ProfileDataEntity(org.n52.series.db.beans.ProfileDataEntity) ComplexDataEntity(org.n52.series.db.beans.ComplexDataEntity) ReferencedDataEntity(org.n52.series.db.beans.ReferencedDataEntity) ComplexDataEntity(org.n52.series.db.beans.ComplexDataEntity)

Example 18 with DataEntity

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

the class ObservationOmObservationCreator method createNewObservation.

@SuppressWarnings({ "unchecked", "rawtypes" })
private OmObservation createNewObservation(OmObservationConstellation oc, DataEntity<?> ho, Value<?> value) throws OwsExceptionReport {
    final OmObservation o = new OmObservation();
    o.setObservationID(Long.toString(ho.getId()));
    if (ho.isSetIdentifier() && !ho.getIdentifier().startsWith(SosConstants.GENERATED_IDENTIFIER_PREFIX)) {
        final CodeWithAuthority identifier = new CodeWithAuthority(ho.getIdentifier());
        if (ho.isSetIdentifierCodespace()) {
            identifier.setCodeSpace(ho.getIdentifierCodespace().getName());
        }
        o.setIdentifier(identifier);
    }
    addNameAndDescription(ho, o, getRequestedLanguage(), getI18N(), false);
    o.setObservationConstellation(oc);
    addDefaultValuesToObservation(o);
    o.setResultTime(new TimeInstant(new DateTime(ho.getResultTime(), DateTimeZone.UTC)));
    if (ho.getValidTimeStart() != null || ho.getValidTimeEnd() != null) {
        o.setValidTime(new TimePeriod(new DateTime(ho.getValidTimeStart(), DateTimeZone.UTC), new DateTime(ho.getValidTimeEnd(), DateTimeZone.UTC)));
    }
    o.setValue(new SingleObservationValue(getPhenomenonTime(ho), value));
    return o;
}
Also used : SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) DateTime(org.joda.time.DateTime)

Example 19 with DataEntity

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

the class AbstractSeriesObservationDAO method getSamplingGeometries.

@SuppressWarnings("unchecked")
@Override
public List<org.locationtech.jts.geom.Geometry> getSamplingGeometries(String feature, Session session) throws OwsExceptionReport {
    Criteria criteria = getDefaultObservationTimeCriteria(session).createAlias(DataEntity.PROPERTY_DATASET, "s");
    criteria.createCriteria(S_PREFIX + DatasetEntity.PROPERTY_FEATURE).add(Restrictions.eq(AbstractFeatureEntity.IDENTIFIER, feature));
    criteria.addOrder(Order.asc(DataEntity.PROPERTY_SAMPLING_TIME_START));
    if (HibernateHelper.isColumnSupported(getObservationFactory().contextualReferencedClass(), GeometryEntity.PROPERTY_GEOMETRY)) {
        criteria.add(Restrictions.isNotNull(DataEntity.PROPERTY_GEOMETRY_ENTITY));
        criteria.setProjection(Projections.property(DataEntity.PROPERTY_GEOMETRY_ENTITY));
        LOGGER.trace(LOG_QUERY_SAMPLING_GEOMETRIES, HibernateHelper.getSqlString(criteria));
        return criteria.list();
    } else if (HibernateHelper.isColumnSupported(getObservationFactory().contextualReferencedClass(), GeometryEntity.PROPERTY_LON) && HibernateHelper.isColumnSupported(getObservationFactory().contextualReferencedClass(), GeometryEntity.PROPERTY_LAT)) {
        criteria.add(Restrictions.and(Restrictions.isNotNull(GeometryEntity.PROPERTY_LAT), Restrictions.isNotNull(GeometryEntity.PROPERTY_LON)));
        List<org.locationtech.jts.geom.Geometry> samplingGeometries = new LinkedList<>();
        LOGGER.trace(LOG_QUERY_SAMPLING_GEOMETRIES, HibernateHelper.getSqlString(criteria));
        for (DataEntity element : (List<DataEntity>) criteria.list()) {
            samplingGeometries.add(element.getGeometryEntity().getGeometry());
        }
        return samplingGeometries;
    }
    return Collections.emptyList();
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) DataEntity(org.n52.series.db.beans.DataEntity) Criteria(org.hibernate.Criteria)

Example 20 with DataEntity

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

the class AbstractSeriesObservationDAO method updateObservationSetAsDeletedForSeries.

/**
 * Update series observation by setting deleted flag
 *
 * @param series
 *            Series for which the observations should be updated
 * @param deleteFlag
 *            New deleted flag value
 * @param session
 *            Hibernate Session
 */
public void updateObservationSetAsDeletedForSeries(List<DatasetEntity> series, boolean deleteFlag, Session session) {
    if (CollectionHelper.isNotEmpty(series)) {
        Criteria criteria = getDefaultObservationCriteria(session);
        criteria.add(Restrictions.in(DataEntity.PROPERTY_DATASET_ID, series.stream().map(DatasetEntity::getId).collect(Collectors.toSet())));
        ScrollableIterable<DataEntity<?>> scroll = ScrollableIterable.fromCriteria(criteria);
        updateObservation(scroll, deleteFlag, session);
    }
}
Also used : DataEntity(org.n52.series.db.beans.DataEntity) Criteria(org.hibernate.Criteria)

Aggregations

DataEntity (org.n52.series.db.beans.DataEntity)31 Criteria (org.hibernate.Criteria)20 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)18 DatasetEntity (org.n52.series.db.beans.DatasetEntity)14 QuantityDataEntity (org.n52.series.db.beans.QuantityDataEntity)14 Test (org.junit.Test)13 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)11 LinkedList (java.util.LinkedList)10 HibernateException (org.hibernate.HibernateException)9 Session (org.hibernate.Session)9 List (java.util.List)8 SubQueryIdentifier (org.n52.sos.ds.hibernate.util.ResultFilterRestrictions.SubQueryIdentifier)8 DateTime (org.joda.time.DateTime)7 OmObservation (org.n52.shetland.ogc.om.OmObservation)7 DataArrayDataEntity (org.n52.series.db.beans.DataArrayDataEntity)6 ReferencedDataEntity (org.n52.series.db.beans.ReferencedDataEntity)6 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)6 ComplexDataEntity (org.n52.series.db.beans.ComplexDataEntity)5 GeometryDataEntity (org.n52.series.db.beans.GeometryDataEntity)5 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)5