use of org.n52.series.db.beans.DataEntity in project SOS by 52North.
the class AbstractSeriesObservationDAO method getFirstObservationFor.
/**
* Get the first not deleted observation for the {@link DatasetEntity}
*
* @param series
* Series to get observation for
* @param session
* Hibernate session
* @return First not deleted observation
*/
public DataEntity<?> getFirstObservationFor(DatasetEntity series, Session session) {
Criteria c = getDefaultObservationCriteria(session);
c.add(Restrictions.eq(DataEntity.PROPERTY_DATASET_ID, series.getId()));
c.addOrder(Order.asc(DataEntity.PROPERTY_SAMPLING_TIME_START));
c.setMaxResults(1);
LOGGER.trace("QUERY getFirstObservationFor(series): {}", HibernateHelper.getSqlString(c));
return (DataEntity) c.uniqueResult();
}
use of org.n52.series.db.beans.DataEntity in project SOS by 52North.
the class AbstractSeriesValueDAO method getStreamingSeriesValuesFor.
/**
* Query streaming value for parameter as chunk {@link List}
*
* @param request
* {@link AbstractObservationRequest}
* @param series
* Datasource series id
* @param chunkSize
* Chunk size
* @param currentRow
* Start row
* @param session
* Hibernate Session
* @return Resulting chunk {@link List}
* @throws OwsExceptionReport
* If an error occurs when querying
*/
@SuppressWarnings("unchecked")
public List<DataEntity<?>> getStreamingSeriesValuesFor(AbstractObservationRequest request, long series, int chunkSize, int currentRow, Session session) throws OwsExceptionReport {
if (request instanceof GetObservationRequest && ((GetObservationRequest) request).hasResultFilter()) {
StringBuilder logArgs = new StringBuilder();
List<DataEntity<?>> list = new LinkedList<>();
for (SubQueryIdentifier identifier : ResultFilterRestrictions.getSubQueryIdentifier(getResultFilterClasses())) {
Criteria c = getSeriesValueCriteriaFor(request, series, null, session, logArgs);
addChunkValuesToCriteria(c, chunkSize, currentRow, request, logArgs);
checkAndAddResultFilterCriterion(c, (GetObservationRequest) request, identifier, session, logArgs);
LOGGER.trace(QUERY_STREAMING_SERIES_VALUE, logArgs.toString(), HibernateHelper.getSqlString(c));
list.addAll(c.list());
}
return list;
} else {
StringBuilder logArgs = new StringBuilder();
Criteria c = getSeriesValueCriteriaFor(request, series, null, session, logArgs);
addChunkValuesToCriteria(c, chunkSize, currentRow, request, logArgs);
LOGGER.trace(QUERY_STREAMING_SERIES_VALUE, logArgs.toString(), HibernateHelper.getSqlString(c));
return (List<DataEntity<?>>) c.list();
}
}
use of org.n52.series.db.beans.DataEntity in project SOS by 52North.
the class AbstractSeriesValueDAO method getStreamingSeriesValuesFor.
/**
* Query streaming value for parameter as chunk {@link List}
*
* @param request
* {@link AbstractObservationRequest}
* @param series
* Datasource series ids
* @param chunkSize
* Chunk size
* @param currentRow
* Start row
* @param session
* Hibernate Session
* @return Resulting chunk {@link List}
* @throws OwsExceptionReport
* If an error occurs when querying
*/
@SuppressWarnings("unchecked")
public List<DataEntity<?>> getStreamingSeriesValuesFor(AbstractObservationRequest request, Set<Long> series, int chunkSize, int currentRow, Session session) throws OwsExceptionReport {
if (request instanceof GetObservationRequest && ((GetObservationRequest) request).hasResultFilter()) {
List<DataEntity<?>> list = new LinkedList<>();
for (SubQueryIdentifier identifier : ResultFilterRestrictions.getSubQueryIdentifier(getResultFilterClasses())) {
StringBuilder logArgs = new StringBuilder();
Criteria c = getSeriesValueCriteriaFor(request, series, null, session, logArgs);
addChunkValuesToCriteria(c, chunkSize, currentRow, request, logArgs);
checkAndAddResultFilterCriterion(c, (GetObservationRequest) request, identifier, session, logArgs);
LOGGER.trace(QUERY_STREAMING_SERIES_VALUE, logArgs.toString(), HibernateHelper.getSqlString(c));
list.addAll(c.list());
}
return list;
} else {
StringBuilder logArgs = new StringBuilder();
Criteria c = getSeriesValueCriteriaFor(request, series, null, session, logArgs);
addChunkValuesToCriteria(c, chunkSize, currentRow, request, logArgs);
LOGGER.trace(QUERY_STREAMING_SERIES_VALUE, logArgs.toString(), HibernateHelper.getSqlString(c));
return (List<DataEntity<?>>) c.list();
}
}
use of org.n52.series.db.beans.DataEntity in project SOS by 52North.
the class EReportingHelper method createSweDataArrayValue.
/**
* Creates an {@link ObservationValue} from the {@link DataEntity}
*
* @param omObservation
* Corresponding {@link OmObservation}
* @param observation
* {@link DataEntity} to create {@link ObservationValue} from
* @return Created {@link ObservationValue}.
* @throws CodedException
* If an error occurs
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public SingleObservationValue<?> createSweDataArrayValue(OmObservation omObservation, DataEntity observation) throws CodedException {
SweDataArrayValue sweDataArrayValue = new SweDataArrayValue();
sweDataArrayValue.setValue(createSweDataArray(omObservation, observation));
SingleObservationValue observationValue = new SingleObservationValue(sweDataArrayValue);
observationValue.setPhenomenonTime(getPhenomenonTime(omObservation, DataTimeCreator.createPhenomenonTime(observation)));
addQuality(observation.getEreportingProfile(), observationValue);
return observationValue;
}
use of org.n52.series.db.beans.DataEntity in project SOS by 52North.
the class ObservationOmObservationCreator method createObservationConstellation.
private OmObservationConstellation createObservationConstellation(DataEntity<?> hObservation, String procedureId, String phenomenonId, String featureId, Set<String> offerings) throws OwsExceptionReport {
long start = System.currentTimeMillis();
LOGGER.trace("Creating ObservationConstellation...");
OmObservationConstellation obsConst = new OmObservationConstellation(getProcedure(procedureId), getObservedProperty(phenomenonId), getFeature(featureId), offerings);
if (observationConstellations.containsKey(obsConst.hashCode())) {
obsConst = observationConstellations.get(obsConst.hashCode());
}
int hashCode = obsConst.hashCode();
if (!Strings.isNullOrEmpty(getResultModel())) {
obsConst.setObservationType(getResultModel());
}
if (hObservation.getDataset().isSetOmObservationType()) {
obsConst.setObservationType(hObservation.getDataset().getOmObservationType().getFormat());
}
observationConstellations.put(hashCode, obsConst);
DatasetEntity series = hObservation.getDataset();
if (series.isSetIdentifier()) {
addIdentifier(obsConst, series);
}
obsConst.setObservationType(getResultModel());
if (request.isSetRequestedLanguage()) {
addNameAndDescription(series, obsConst, getRequestedLanguage(), getI18N(), false);
if (obsConst.isSetName()) {
obsConst.setHumanReadableIdentifier(obsConst.getFirstName().getValue());
}
} else {
if (series.isSetName()) {
addName(obsConst, series);
}
if (series.isSetDescription()) {
obsConst.setDescription(series.getDescription());
}
}
LOGGER.trace("Creating ObservationConstellation done in {} ms.", System.currentTimeMillis() - start);
return obsConst;
}
Aggregations