use of org.n52.series.db.beans.ProfileDataEntity in project SOS by 52North.
the class ProfileGeneratorSplitter method create.
public ProfileValue create(ProfileDataEntity entity) throws OwsExceptionReport {
ProfileValue profileValue = new ProfileValue("");
profileValue.setGmlId("pv" + entity.getId());
UoM uom = null;
if (entity.getDataset().hasVerticalMetadata() && entity.getDataset().getVerticalMetadata().hasVerticalUnit()) {
UnitEntity levelunit = entity.getDataset().getVerticalMetadata().getVerticalUnit();
uom = new UoM(levelunit.getUnit());
if (levelunit.isSetName()) {
uom.setName(levelunit.getName());
}
if (levelunit.isSetLink()) {
uom.setLink(levelunit.getLink());
}
}
if (entity.hasVerticalFrom()) {
profileValue.setFromLevel(new QuantityValue(entity.getVerticalFrom().doubleValue(), uom));
}
if (entity.hasVerticalTo()) {
profileValue.setToLevel(new QuantityValue(entity.getVerticalTo().doubleValue(), uom));
}
profileValue.setValue(createProfileLevel(entity));
return profileValue;
}
use of org.n52.series.db.beans.ProfileDataEntity in project SOS by 52North.
the class ProfileGeneratorSplitter method createProfileLevel.
private List<ProfileLevel> createProfileLevel(ProfileDataEntity entity) throws OwsExceptionReport {
Map<BigDecimal, ProfileLevel> map = Maps.newTreeMap();
if (entity.hasValue()) {
for (DataEntity<?> observation : entity.getValue()) {
VerticalMetadataEntity verticalMetadata = entity.getDataset().getVerticalMetadata();
QuantityValue levelStart = observation.hasVerticalFrom() && observation.hasVerticalInterval() ? getLevelStart(observation.getVerticalFrom(), verticalMetadata.getVerticalFromName(), verticalMetadata.getVerticalUnit()) : null;
QuantityValue levelEnd = observation.hasVerticalTo() ? getLevelEnd(observation.getVerticalTo(), verticalMetadata.getVerticalToName(), verticalMetadata.getVerticalUnit()) : null;
if (levelStart == null && levelEnd == null && observation.hasParameters()) {
levelStart = getLevelStart(observation.getParameters());
levelEnd = getLevelEnd(observation.getParameters());
}
if (levelStart != null || levelEnd != null) {
BigDecimal key = getKey(levelStart, levelEnd);
Value<?> value = creator.visit(observation);
if (map.containsKey(key)) {
map.get(key).addValue(value);
} else {
ProfileLevel profileLevel = new ProfileLevel();
profileLevel.setLevelStart(levelStart);
profileLevel.setLevelEnd(levelEnd);
if (observation.isSetGeometryEntity()) {
profileLevel.setLocation(observation.getGeometryEntity().getGeometry());
}
profileLevel.addValue(value);
map.put(key, profileLevel);
}
}
}
}
return (List<ProfileLevel>) Lists.newArrayList(map.values());
}
use of org.n52.series.db.beans.ProfileDataEntity in project SOS by 52North.
the class ObservationPersister method checkForParameter.
private <T extends DataEntity<?>> T checkForParameter(T observation, ParameterHolder parameterHolder, ObservationContext ctx, Session session) throws OwsExceptionReport {
if (parameterHolder.isSetParameter()) {
if (parameterHolder.isSetFromToParameter()) {
NamedValue<BigDecimal> fromParameter = parameterHolder.getFromParameter();
NamedValue<BigDecimal> toParameter = parameterHolder.getToParameter();
if (!(observation instanceof ProfileDataEntity)) {
observation.setVerticalFrom(fromParameter.getValue().getValue());
observation.setVerticalTo(toParameter.getValue().getValue());
}
// set vertical metadata
VerticalMetadataEntity verticalMetadata = new VerticalMetadataEntity();
verticalMetadata.setVerticalFromName(fromParameter.getName().getHref());
verticalMetadata.setVerticalToName(toParameter.getName().getHref());
if (fromParameter.getValue().isSetUnit()) {
verticalMetadata.setVerticalUnit(getUnit(fromParameter.getValue().getUnitObject(), caches.units, session));
}
if (parameterHolder.isSetHeightDepthParameter()) {
if (parameterHolder.isSetDepthParameter() && parameterHolder.isSetHeightParameter()) {
verticalMetadata.setOrientation(Integer.valueOf(0).shortValue());
} else if (parameterHolder.isSetDepthParameter()) {
verticalMetadata.setOrientation(Integer.valueOf(-1).shortValue());
} else {
verticalMetadata.setOrientation(Integer.valueOf(1).shortValue());
}
}
ctx.setVertical(verticalMetadata);
parameterHolder.removeParameter(fromParameter);
parameterHolder.removeParameter(toParameter);
} else if (parameterHolder.isSetHeightDepthParameter()) {
NamedValue<BigDecimal> parameter = parameterHolder.getHeightDepthParameter();
VerticalMetadataEntity verticalMetadata = new VerticalMetadataEntity();
if (parameterHolder.isSetDepthParameter()) {
if (!(observation instanceof ProfileDataEntity)) {
observation.setVerticalFrom(parameter.getValue().getValue());
observation.setVerticalTo(parameter.getValue().getValue());
}
verticalMetadata.setOrientation(Integer.valueOf(-1).shortValue());
} else {
if (!(observation instanceof ProfileDataEntity)) {
observation.setVerticalFrom(parameter.getValue().getValue());
observation.setVerticalTo(parameter.getValue().getValue());
}
verticalMetadata.setOrientation(Integer.valueOf(1).shortValue());
}
// set vertical metadata
verticalMetadata.setVerticalFromName(parameter.getName().getHref());
verticalMetadata.setVerticalToName(parameter.getName().getHref());
if (parameter.getValue().isSetUnit()) {
verticalMetadata.setVerticalUnit(getUnit(parameter.getValue().getUnitObject(), caches.units, session));
}
ctx.setVertical(verticalMetadata);
parameterHolder.removeParameter(parameter);
}
if (parameterHolder.isSetParameter()) {
Set<ParameterEntity<?>> insertParameter = daos.parameter().insertParameter(parameterHolder.getParameter(), caches.units, session);
observation.setParameters(insertParameter);
}
}
return observation;
}
use of org.n52.series.db.beans.ProfileDataEntity in project SOS by 52North.
the class ObservationPersister method visit.
@Override
public DataEntity<?> visit(ProfileValue value) throws OwsExceptionReport {
ProfileDataEntity profile = observationFactory.profile();
if (value.isSetFromLevel() || value.isSetToLevel()) {
if (value.isSetFromLevel()) {
profile.setVerticalFrom(value.getFromLevel().getValue());
omObservation.addParameter(createParameter((QuantityValue) value.getFromLevel()));
}
if (value.isSetToLevel()) {
profile.setVerticalTo(value.getToLevel().getValue());
omObservation.addParameter(createParameter((QuantityValue) value.getToLevel()));
}
}
if (value.isSetPhenomenonTime()) {
omObservation.getValue().setPhenomenonTime(value.getPhenomenonTime());
}
dataset.setValueType(getProfileValueType(value));
DataEntity profileDataEntity = persist((DataEntity) profile, new HashSet<DataEntity<?>>());
persistChildren(value.getValue(), profileDataEntity.getId());
return profileDataEntity;
}
Aggregations