Search in sources :

Example 11 with ProcedureEntity

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;
}
Also used : System(org.n52.shetland.ogc.sensorML.System)

Example 12 with ProcedureEntity

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;
}
Also used : RulesDefinition(org.n52.shetland.ogc.sensorML.RulesDefinition)

Example 13 with ProcedureEntity

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);
}
Also used : SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) ObservationProcess(org.n52.shetland.ogc.om.series.wml.ObservationProcess) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType)

Example 14 with ProcedureEntity

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);
    }
}
Also used : HibernateException(org.hibernate.HibernateException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) DataAccessException(org.n52.series.db.DataAccessException)

Example 15 with ProcedureEntity

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!");
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) FeatureEntity(org.n52.series.db.beans.FeatureEntity) Coordinate(org.locationtech.jts.geom.Coordinate) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) FeatureDao(org.n52.series.db.dao.FeatureDao) SmlPosition(org.n52.shetland.ogc.sensorML.elements.SmlPosition) CodedException(org.n52.shetland.ogc.ows.exception.CodedException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) HibernateException(org.hibernate.HibernateException) DataAccessException(org.n52.series.db.DataAccessException)

Aggregations

ProcedureEntity (org.n52.series.db.beans.ProcedureEntity)32 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)14 HibernateException (org.hibernate.HibernateException)11 DatasetEntity (org.n52.series.db.beans.DatasetEntity)10 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)10 Criteria (org.hibernate.Criteria)9 Session (org.hibernate.Session)9 OfferingEntity (org.n52.series.db.beans.OfferingEntity)9 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)9 HashSet (java.util.HashSet)8 FormatEntity (org.n52.series.db.beans.FormatEntity)7 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)6 DateTime (org.joda.time.DateTime)6 ArrayList (java.util.ArrayList)5 Collection (java.util.Collection)5 HashMap (java.util.HashMap)5 Transaction (org.hibernate.Transaction)5 ProcedureHistoryEntity (org.n52.series.db.beans.ProcedureHistoryEntity)5 Set (java.util.Set)4 Collectors.toCollection (java.util.stream.Collectors.toCollection)4