private Collection<String> getParents(FeatureEntity featureEntity) { Set<String> parentFeatures = Sets.newTreeSet(); if (featureEntity.hasParents()) { for (FeatureEntity parentEntity : featureEntity.getParents()) { parentFeatures.add(parentEntity.getIdentifier()); parentFeatures.addAll(getParents(parentEntity)); } } return parentFeatures; }
private void addObservingCapabilities(org.n52.shetland.inspire.ef.EnvironmentalMonitoringFacility emFeature, FeatureEntity feature) { emFeature.addObservingCapability(createObservingCapability(feature.getIdentifier())); if (feature.hasChildren()) { for (AbstractFeatureEntity child : feature.getChildren()) { emFeature.addObservingCapability(createObservingCapability(child.getIdentifier())); } } }
private void addObservingCapabilities(org.n52.shetland.inspire.ef.EnvironmentalMonitoringFacility emFeature, FeatureEntity feature) { emFeature.addObservingCapability(createObservingCapability(feature.getIdentifier())); if (feature.hasChildren()) { for (AbstractFeatureEntity child : feature.getChildren()) { emFeature.addObservingCapability(createObservingCapability(child.getIdentifier())); } } }
@Override public GetObservationResponse getObservation(GetObservationRequest request) throws OwsExceptionReport { if (request.getVersion().equals(Sos1Constants.SERVICEVERSION) && request.getObservedProperties().isEmpty()) { throw new MissingObservedPropertyParameterException(); } if (request.isSetResultFilter()) { throw new NotYetSupportedException("result filtering"); } Session session = sessionStore.getSession(); try { GetObservationResponse response = new GetObservationResponse(); response.setService(request.getService()); response.setVersion(request.getVersion()); response.setResponseFormat(request.getResponseFormat()); response.setResultModel(request.getResultModel()); List<FeatureEntity> features = new FeatureDao(session).getAllInstances(createDbQuery(request)); if (features == null || features.isEmpty()) { return response; } request.setFeatureIdentifiers(features.stream().map(f -> f.getIdentifier()).collect(Collectors.toList())); dao.queryObservationData(request, response); return response; } catch (DataAccessException e) { throw new NoApplicableCodeException().causedBy(e).withMessage( "Error while querying data for GetObservation!"); } finally { sessionStore.returnSession(session); } }
if (requestedLocale != null) { I18NFeatureMetadata i18n = i18nDAO.getMetadata(feature.getIdentifier(), requestedLocale); Optional<LocalizedString> name = i18n.getName().getLocalization(requestedLocale); if (name.isPresent()) { if (getContext().isShowAllLanguages()) { i18n = i18nDAO.getMetadata(feature.getIdentifier()); } else { i18n = i18nDAO.getMetadata(feature.getIdentifier(), getContext().getDefaultLanguage());
@Override public void execute() { LOGGER.debug("Executing FeatureOfInterestCacheUpdate"); startStopwatch(); try { Collection<FeatureEntity> features = new FeatureDao(getSession()).get(new DbQuery(IoParameters.createDefaults())); for (FeatureEntity featureEntity : features) { String identifier = featureEntity.getIdentifier(); getCache().addFeatureOfInterest(identifier); Collection<DatasetEntity> datasets = new DatasetDao<>(getSession()).get(createDatasetDbQuery(featureEntity)); if (datasets != null && !datasets.isEmpty()) { if (datasets.stream().anyMatch(d -> d.isPublished() || d instanceof NotInitializedDataset)) { getCache().addPublishedFeatureOfInterest(identifier); } getCache().setProceduresForFeatureOfInterest(identifier, getProcedures(datasets)); } if (featureEntity.isSetName()) { getCache().addFeatureOfInterestIdentifierHumanReadableName(identifier, featureEntity.getName()); } if (featureEntity.hasParents()) { getCache().addParentFeatures(identifier, getParents(featureEntity)); } } } catch (HibernateException he) { getErrors().add(new NoApplicableCodeException().causedBy(he).withMessage("Error while updating featureOfInterest cache!")); } LOGGER.debug("Finished executing FeatureOfInterestCacheUpdate ({})", getStopwatchResult()); }
if (requestedLocale != null) { I18NFeatureMetadata i18n = i18nDAO.getMetadata(feature.getIdentifier(), requestedLocale); Optional<LocalizedString> name = i18n.getName().getLocalization(requestedLocale); if (name.isPresent()) { if (getContext().isShowAllLanguages()) { i18n = i18nDAO.getMetadata(feature.getIdentifier()); } else { i18n = i18nDAO.getMetadata(feature.getIdentifier(), getContext().getDefaultLanguage());
if (getContext().createFeatureGeometryFromSamplingGeometries()) { int srid = getContext().getGeometryHandler().getStorageEPSG(); if (getContext().getDaoFactory().getObservationDAO().getSamplingGeometriesCount(feature.getIdentifier(), getContext().getSession()) .longValue() < 100) { List<Geometry> geometries = getContext().getDaoFactory().getObservationDAO().getSamplingGeometries(feature.getIdentifier(), getContext().getSession()); if (!CollectionHelper.nullEmptyOrContainsOnlyNulls(geometries)) { List<Coordinate> coordinates = Lists.newLinkedList();
private AbstractFeature createFeature(FeatureEntity feature) throws InvalidSridException, OwsExceptionReport { final SamplingFeature sampFeat = new SamplingFeature(new CodeWithAuthority(feature.getIdentifier())); if (feature.isSetName()) { sampFeat.addName(feature.getName()); } if (!Strings.isNullOrEmpty(feature.getDescription())) { sampFeat.setDescription(feature.getDescription()); } if (feature.isSetGeometry() && !feature.getGeometryEntity().isEmpty()) { if (getProcedureCreationContext().getGeometryHandler() != null) { sampFeat.setGeometry(getProcedureCreationContext().getGeometryHandler() .switchCoordinateAxisFromToDatasourceIfNeeded( JTSConverter.convert(feature.getGeometryEntity().getGeometry()))); } else { sampFeat.setGeometry(JTSConverter.convert(feature.getGeometryEntity().getGeometry())); } } final Set<FeatureEntity> parentFeatures = feature.getParents(); if (parentFeatures != null && !parentFeatures.isEmpty()) { final List<AbstractFeature> sampledFeatures = new ArrayList<>(parentFeatures.size()); for (final FeatureEntity parentFeature : parentFeatures) { sampledFeatures.add(createFeature(parentFeature)); } sampFeat.setSampledFeatures(sampledFeatures); } return sampFeat; }
if (getContext().createFeatureGeometryFromSamplingGeometries()) { int srid = getContext().getGeometryHandler().getStorageEPSG(); if (getContext().getDaoFactory().getObservationDAO().getSamplingGeometriesCount(feature.getIdentifier(), getContext().getSession()) .longValue() < 100) { List<Geometry> geometries = getContext().getDaoFactory().getObservationDAO().getSamplingGeometries(feature.getIdentifier(), getContext().getSession()); if (!CollectionHelper.nullEmptyOrContainsOnlyNulls(geometries)) { List<Coordinate> coordinates = Lists.newLinkedList();
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 = getFeatureType(identifier); addNameAndDescription(getContext().getRequestedLanguage(), f, absFeat); if (absFeat instanceof AbstractSamplingFeature) { AbstractSamplingFeature absSampFeat = (AbstractSamplingFeature) absFeat; absSampFeat.setGeometry(createGeometryFrom(f)); absSampFeat.setFeatureType(f.getFeatureType().getFormat()); 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; }
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 = getFeatureType(identifier); addNameAndDescription(getContext().getRequestedLanguage(), f, absFeat); if (absFeat instanceof AbstractSamplingFeature) { AbstractSamplingFeature absSampFeat = (AbstractSamplingFeature) absFeat; absSampFeat.setGeometry(createGeometryFrom(f)); absSampFeat.setFeatureType(f.getFeatureType().getFormat()); 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; }
private PlatformEntity convertToPlatform(FeatureEntity entity, DbQuery query) { PlatformEntity result = new PlatformEntity(); result.setIdentifier(entity.getIdentifier()); result.setId(entity.getId()); result.setName(entity.getName()); result.setParameters(entity.getParameters()); result.setTranslations(entity.getTranslations()); result.setDescription(entity.getDescription()); result.setGeometry(getGeometry(entity.getGeometryEntity(), query)); return result; }