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