use of org.n52.series.db.beans.FeatureEntity in project SOS by 52North.
the class FeatureOfInterestDAO method getOrInsert.
/**
* Insert and/or get featureOfInterest object for identifier
*
* @param identifier
* FeatureOfInterest identifier
* @param url
* FeatureOfInterest URL, if defined as link
* @param session
* Hibernate session
* @return FeatureOfInterest object
*/
public AbstractFeatureEntity getOrInsert(String identifier, String url, Session session) {
AbstractFeatureEntity feature = get(identifier, session);
if (feature == null) {
feature = new FeatureEntity();
feature.setIdentifier(identifier, getDaoFactory().isStaSupportsUrls());
if (url != null && !url.isEmpty()) {
feature.setUrl(url);
}
FormatEntity type = new FormatDAO().getOrInsertFormatEntity(OGCConstants.UNKNOWN, session);
feature.setFeatureType(type);
session.save(feature);
} else if (feature.getUrl() != null && !feature.getUrl().isEmpty() && url != null && !url.isEmpty()) {
feature.setUrl(url);
session.saveOrUpdate(feature);
}
// don't flush here because we may be batching
return feature;
}
use of org.n52.series.db.beans.FeatureEntity in project SOS by 52North.
the class FeatureOfInterestDAO method getFeatureOfInterestObject.
/**
* Get featureOfInterest objects for featureOfInterest identifiers
*
* @param identifiers
* FeatureOfInterest identifiers
* @param session
* Hibernate session
* @return FeatureOfInterest objects
*/
@SuppressWarnings("unchecked")
public List<FeatureEntity> getFeatureOfInterestObject(Collection<String> identifiers, Session session) {
if (identifiers == null || identifiers.isEmpty()) {
return Collections.emptyList();
}
Criteria criteria = session.createCriteria(FeatureEntity.class).add(QueryHelper.getCriterionForObjects(AbstractFeatureEntity.IDENTIFIER, identifiers));
LOGGER.trace("QUERY getFeatureOfInterestObject(identifiers): {}", HibernateHelper.getSqlString(criteria));
return criteria.list();
}
use of org.n52.series.db.beans.FeatureEntity 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!");
}
}
use of org.n52.series.db.beans.FeatureEntity in project SOS by 52North.
the class FeatureOfInterestEnrichment method createFeatures.
private Map<String, AbstractFeature> createFeatures(Set<FeatureEntity> featureEntities) throws InvalidSridException, OwsExceptionReport {
final Map<String, AbstractFeature> map = new HashMap<>(featureEntities.size());
for (final FeatureEntity feature : featureEntities) {
final AbstractFeature abstractFeature = createFeature(feature);
map.put(abstractFeature.getIdentifier(), abstractFeature);
}
return map;
}
use of org.n52.series.db.beans.FeatureEntity in project SOS by 52North.
the class AbstractFeatureOfInerestCreator method createFeature.
public AbstractFeature createFeature(FeatureEntity f) throws OwsExceptionReport {
final CodeWithAuthority identifier = getIdentifier(f);
if (!SosHelper.checkFeatureOfInterestIdentifierForSosV2(f.getIdentifier(), getContext().getVersion())) {
identifier.setValue(null);
}
final AbstractFeature absFeat = createFeature(identifier);
addNameAndDescription(f, absFeat, getContext().getRequestedLanguage(), getContext().getDefaultLanguage(), getContext().isShowAllLanguages());
if (absFeat instanceof AbstractSamplingFeature) {
AbstractSamplingFeature absSampFeat = (AbstractSamplingFeature) absFeat;
absSampFeat.setGeometry(createGeometryFrom(f));
absSampFeat.setFeatureType(getFeatureTypes(f));
absSampFeat.setUrl(f.getUrl());
if (f.isSetXml()) {
absSampFeat.setXml(f.getXml());
}
addParameter(absSampFeat, f);
final Set<FeatureEntity> parentFeatures = f.getParents();
if (parentFeatures != null && !parentFeatures.isEmpty()) {
final List<AbstractFeature> sampledFeatures = new ArrayList<AbstractFeature>(parentFeatures.size());
for (final AbstractFeatureEntity parentFeature : parentFeatures) {
sampledFeatures.add(new HibernateFeatureVisitor(getContext()).visit(parentFeature));
}
absSampFeat.setSampledFeatures(sampledFeatures);
}
}
return absFeat;
}
Aggregations