Search in sources :

Example 1 with HasUnit

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

the class ParameterVisitor method addUnit.

protected void addUnit(ParameterEntity<?> vp, Value<?> v) {
    if (!v.isSetUnit() && vp instanceof HasUnit && ((HasUnit) vp).isSetUnit()) {
        UnitEntity unit = ((HasUnit) vp).getUnit();
        UoM uom = new UoM(unit.getUnit());
        if (unit.isSetName()) {
            uom.setName(unit.getName());
        }
        if (unit.isSetLink()) {
            uom.setLink(unit.getLink());
        }
        v.setUnit(uom);
    }
}
Also used : UoM(org.n52.shetland.ogc.UoM) UnitEntity(org.n52.series.db.beans.UnitEntity) HasUnit(org.n52.series.db.beans.HibernateRelations.HasUnit)

Example 2 with HasUnit

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

the class SweAbstractDataComponentCreator method setCommonValues.

protected <T extends SweAbstractDataComponent> T setCommonValues(T component, DataEntity<?> valuedObservation) throws CodedException {
    if (valuedObservation != null) {
        PhenomenonEntity op = valuedObservation.getDataset().getPhenomenon();
        component.setIdentifier(op.getIdentifier());
        component.setDefinition(op.getIdentifier());
        component.setDescription(op.getDescription());
        if (op.isSetNameCodespace()) {
            String codespace = op.getNameCodespace().getName();
            try {
                component.setName(new CodeType(op.getName(), new URI(codespace)));
            } catch (URISyntaxException e) {
                throw new NoApplicableCodeException().causedBy(e).withMessage("Error while creating URI from '{}'", codespace);
            }
        } else {
            component.setName(op.getName());
        }
        if (valuedObservation.getDataset().hasUnit() && component instanceof SweAbstractUomType) {
            SweAbstractUomType<?> uomType = (SweAbstractUomType<?>) component;
            uomType.setUom(valuedObservation.getDataset().getUnit().getUnit());
        }
    }
    return component;
}
Also used : NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) CodeType(org.n52.shetland.ogc.gml.CodeType) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) SweAbstractUomType(org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType)

Aggregations

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HasUnit (org.n52.series.db.beans.HibernateRelations.HasUnit)1 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)1 UnitEntity (org.n52.series.db.beans.UnitEntity)1 UoM (org.n52.shetland.ogc.UoM)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 SweAbstractUomType (org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType)1