Search in sources :

Example 1 with ProfileDataEntity

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;
}
Also used : UoM(org.n52.shetland.ogc.UoM) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) UnitEntity(org.n52.series.db.beans.UnitEntity) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue)

Example 2 with ProfileDataEntity

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());
}
Also used : VerticalMetadataEntity(org.n52.series.db.beans.VerticalMetadataEntity) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel) List(java.util.List) BigDecimal(java.math.BigDecimal)

Example 3 with ProfileDataEntity

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;
}
Also used : VerticalMetadataEntity(org.n52.series.db.beans.VerticalMetadataEntity) ParameterEntity(org.n52.series.db.beans.parameter.ParameterEntity) NamedValue(org.n52.shetland.ogc.om.NamedValue) ProfileDataEntity(org.n52.series.db.beans.ProfileDataEntity) BigDecimal(java.math.BigDecimal)

Example 4 with ProfileDataEntity

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;
}
Also used : QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) 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) ProfileDataEntity(org.n52.series.db.beans.ProfileDataEntity)

Aggregations

QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)3 BigDecimal (java.math.BigDecimal)2 ProfileDataEntity (org.n52.series.db.beans.ProfileDataEntity)2 VerticalMetadataEntity (org.n52.series.db.beans.VerticalMetadataEntity)2 List (java.util.List)1 ComplexDataEntity (org.n52.series.db.beans.ComplexDataEntity)1 DataArrayDataEntity (org.n52.series.db.beans.DataArrayDataEntity)1 DataEntity (org.n52.series.db.beans.DataEntity)1 GeometryDataEntity (org.n52.series.db.beans.GeometryDataEntity)1 ReferencedDataEntity (org.n52.series.db.beans.ReferencedDataEntity)1 UnitEntity (org.n52.series.db.beans.UnitEntity)1 ParameterEntity (org.n52.series.db.beans.parameter.ParameterEntity)1 UoM (org.n52.shetland.ogc.UoM)1 NamedValue (org.n52.shetland.ogc.om.NamedValue)1 ProfileLevel (org.n52.shetland.ogc.om.values.ProfileLevel)1 ProfileValue (org.n52.shetland.ogc.om.values.ProfileValue)1