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());
}
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;
}
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;
}
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();
}
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);
}
}
Aggregations