use of org.n52.series.db.beans.ProcedureEntity in project SOS by 52North.
the class ProcedureDescriptionGeneratorSml101 method createSmlSystem.
/**
* Create a SensorML System from Hibernate procedure entity
*
* @param procedure
* Hibernate procedure entity
*
* @return SensorML System
*
* @throws OwsExceptionReport
* If an error occurs
*/
private System createSmlSystem(ProcedureEntity procedure, Session session) throws OwsExceptionReport {
System smlSystem = new System();
setCommonValues(procedure, smlSystem, session);
smlSystem.setPosition(createPosition(procedure, session));
return smlSystem;
}
use of org.n52.series.db.beans.ProcedureEntity in project SOS by 52North.
the class ProcedureDescriptionGeneratorSml101 method createRulesDefinition.
/**
* Create the rules definition for ProcessMethod
*
* @param procedure
* Hibernate procedure entity
* @param observableProperties
* Properties observed by the procedure
*
* @return SensorML RulesDefinition
*/
private RulesDefinition createRulesDefinition(ProcedureEntity procedure, Collection<String> observableProperties) {
RulesDefinition rD = new RulesDefinition();
String template = procedureSettings().getProcessMethodRulesDefinitionDescriptionTemplate();
String description = String.format(template, procedure.getIdentifier(), COMMA_JOINER.join(observableProperties));
rD.setDescription(description);
return rD;
}
use of org.n52.series.db.beans.ProcedureEntity in project SOS by 52North.
the class ProcedureDescriptionGeneratorWml20 method generateProcedureDescription.
/**
* Generate procedure description from Hibernate procedure entity if no
* description (file, XML text) is available
*
* @param procedure
* Hibernate procedure entity
* @param session
* the session
*
* @return Generated procedure description
*
* @throws OwsExceptionReport
* If an error occurs
*/
public SosProcedureDescription<AbstractFeature> generateProcedureDescription(ProcedureEntity procedure, Locale i18n, Session session) throws OwsExceptionReport {
setLocale(i18n);
final ObservationProcess op = new ObservationProcess();
setCommonData(procedure, op, session);
addName(procedure, op);
op.setProcessType(new ReferenceType(WaterMLConstants.PROCESS_TYPE_ALGORITHM));
return new SosProcedureDescription<>(op);
}
use of org.n52.series.db.beans.ProcedureEntity in project SOS by 52North.
the class AbstractProcedureDescriptionGeneratorSml method createOutputs.
/**
* Create SensorML output list from observableProperties
*
* @param procedure
* Hibernate procedure entity
* @param observableProperties
* Properties observed by the procedure
*
* @return Output list
*
* @throws OwsExceptionReport
* If an error occurs
*/
private List<SmlIo> createOutputs(ProcedureEntity procedure, List<PhenomenonEntity> observableProperties, Session session) throws OwsExceptionReport {
try {
final List<SmlIo> outputs = Lists.newArrayListWithExpectedSize(observableProperties.size());
int i = 1;
for (PhenomenonEntity observableProperty : observableProperties) {
final SmlIo output = createOutputFromDatasets(procedure, observableProperty, session);
if (output != null) {
output.setIoName("output#" + i++);
outputs.add(output);
}
}
return outputs;
} catch (final HibernateException | DataAccessException he) {
throw new NoApplicableCodeException().causedBy(he).withMessage("Error while querying observation data!").setStatus(HTTPStatus.INTERNAL_SERVER_ERROR);
}
}
use of org.n52.series.db.beans.ProcedureEntity in project SOS by 52North.
the class AbstractProcedureDescriptionGeneratorSml method createPosition.
/**
* Create SensorML Position from Hibernate procedure entity
*
* @param procedure
* Hibernate procedure entity
*
* @return SensorML Position
* @throws CodedException If an error occurs
*/
protected SmlPosition createPosition(ProcedureEntity procedure, Session session) throws CodedException {
try {
List<FeatureEntity> features = new FeatureDao(session).getAllInstances(createDbQuery(procedure));
SmlPosition position = new SmlPosition();
position.setName(POSITION_NAME);
position.setFixed(true);
int srid = geometryHandler.getDefaultResponseEPSG();
if (features != null && features.size() == 1) {
FeatureEntity feature = features.iterator().next();
if (feature.isSetGeometry() && !feature.getGeometryEntity().isEmpty()) {
Geometry geometry = feature.getGeometryEntity().getGeometry();
// 8.2 set position from geometry
Coordinate c = geometry.getCoordinate();
position.setPosition(createCoordinatesForPosition(c.getY(), c.getX(), c.getZ()));
}
}
position.setReferenceFrame(srsNamePrefix + srid);
return position;
} catch (Exception e) {
throw new NoApplicableCodeException().causedBy(e).withMessage("Error while creating sensor position!");
}
}
Aggregations