Search in sources :

Example 1 with InMemoryCacheImpl

use of org.n52.sos.cache.InMemoryCacheImpl in project SOS by 52North.

the class InMemoryCacheImplTest method initInstance.

@Before
public void initInstance() {
    // overwrite these methods as these are doing getInstance()-calls
    instance = new InMemoryCacheImpl() {

        private static final long serialVersionUID = -2571450058666530166L;

        @Override
        public Set<String> getFeatureOfInterestTypes() {
            return Collections.emptySet();
        }

        @Override
        public Set<String> getObservationTypes() {
            return Collections.emptySet();
        }
    };
    SupportedTypeRepository supportedTypeRepository = new SupportedTypeRepository();
    supportedTypeRepository.init(new DecoderRepository(), new EncoderRepository());
    instance.setSupportedTypeRepository(supportedTypeRepository);
}
Also used : Set(java.util.Set) EncoderRepository(org.n52.svalbard.encode.EncoderRepository) DecoderRepository(org.n52.svalbard.decode.DecoderRepository) SupportedTypeRepository(org.n52.iceland.coding.SupportedTypeRepository) Before(org.junit.Before)

Example 2 with InMemoryCacheImpl

use of org.n52.sos.cache.InMemoryCacheImpl in project SOS by 52North.

the class SosCacheFeederDAOTest method updateCacheFillsCapabilitiesCache.

@Test
public void updateCacheFillsCapabilitiesCache() throws OwsExceptionReport {
    SosWritableContentCache cache = (InMemoryCacheImpl) new InMemoryCacheImpl().setSupportedTypeRepository(new SupportedTypeRepository());
    instance.updateCache(cache);
    testCacheResult(cache);
}
Also used : InMemoryCacheImpl(org.n52.sos.cache.InMemoryCacheImpl) SosWritableContentCache(org.n52.sos.cache.SosWritableContentCache) SupportedTypeRepository(org.n52.iceland.coding.SupportedTypeRepository) Test(org.junit.Test)

Example 3 with InMemoryCacheImpl

use of org.n52.sos.cache.InMemoryCacheImpl in project SOS by 52North.

the class ObservationInsertionUpdate method execute.

@Override
public void execute() {
    final InMemoryCacheImpl cache = (InMemoryCacheImpl) getCache();
    // Always update the javadoc when changing this method!
    for (OmObservation observation : request.getObservations()) {
        AbstractPhenomenon observableProperty = observation.getObservationConstellation().getObservableProperty();
        final String observationType = observation.getObservationConstellation().getObservationType();
        final String procedure = observation.getObservationConstellation().getProcedure().getIdentifier();
        final Time phenomenonTime = observation.getPhenomenonTime();
        final Time resultTime = observation.getResultTime();
        cache.updatePhenomenonTime(phenomenonTime);
        cache.updateResultTime(resultTime);
        cache.updatePhenomenonTimeForProcedure(procedure, phenomenonTime);
        // update features
        List<AbstractSamplingFeature> observedFeatures = sosFeaturesToList(observation.getObservationConstellation().getFeatureOfInterest());
        final Envelope envelope = createEnvelopeFrom(observedFeatures);
        for (AbstractSamplingFeature sosSamplingFeature : observedFeatures) {
            String featureOfInterest = sosSamplingFeature.getIdentifierCodeWithAuthority().getValue();
            cache.addFeatureOfInterest(featureOfInterest);
            cache.addPublishedFeatureOfInterest(featureOfInterest);
            cache.addPublishedFeatureOfInterest(featureOfInterest);
            if (sosSamplingFeature.isSetName()) {
                cache.addFeatureOfInterestIdentifierHumanReadableName(featureOfInterest, sosSamplingFeature.getFirstName().getValue());
            }
            cache.addProcedureForFeatureOfInterest(featureOfInterest, procedure);
            if (sosSamplingFeature.isSetSampledFeatures()) {
                for (AbstractFeature parentFeature : sosSamplingFeature.getSampledFeatures()) {
                    cache.addParentFeature(sosSamplingFeature.getIdentifierCodeWithAuthority().getValue(), parentFeature.getIdentifierCodeWithAuthority().getValue());
                    cache.addPublishedFeatureOfInterest(parentFeature.getIdentifierCodeWithAuthority().getValue());
                }
            }
            for (String offering : request.getOfferings()) {
                cache.addRelatedFeatureForOffering(offering, featureOfInterest);
                cache.addFeatureOfInterestForOffering(offering, featureOfInterest);
                if (!OGCConstants.UNKNOWN.equals(sosSamplingFeature.getFeatureType())) {
                    cache.addFeatureOfInterestTypesForOffering(offering, sosSamplingFeature.getFeatureType());
                }
            }
        }
        // update Spatial Filtering Profile envelope
        Envelope spatialFitleringProfileEnvelope = new Envelope();
        if (observation.isSetParameter()) {
            for (NamedValue<?> namedValue : observation.getParameter()) {
                if (Sos2Constants.HREF_PARAMETER_SPATIAL_FILTERING_PROFILE.equals(namedValue.getName().getHref())) {
                    if (namedValue.getValue().isSetValue()) {
                        spatialFitleringProfileEnvelope.expandToInclude(((Geometry) namedValue.getValue().getValue()).getEnvelopeInternal());
                        spatialFitleringProfileEnvelope.expandToInclude(((Geometry) namedValue.getValue().getValue()).getEnvelopeInternal());
                    }
                }
            }
        }
        // update offerings
        for (String offering : request.getOfferings()) {
            // procedure
            cache.addOffering(offering);
            if (!cache.getHiddenChildProceduresForOffering(offering).contains(procedure)) {
                cache.addProcedureForOffering(offering, procedure);
            }
            cache.addOfferingForProcedure(procedure, offering);
            // observation type
            cache.addObservationTypesForOffering(offering, observationType);
            // envelopes/bounding boxes (spatial and temporal)
            cache.updatePhenomenonTimeForOffering(offering, phenomenonTime);
            cache.updateResultTimeForOffering(offering, resultTime);
            cache.updateEnvelopeForOffering(offering, envelope);
            cache.updateGlobalEnvelope(envelope);
            if (!envelope.isNull()) {
                cache.updateSpatialFilteringProfileEnvelopeForOffering(offering, spatialFitleringProfileEnvelope);
            }
        }
        updateObservableProperties(cache, observableProperty, procedure);
    }
}
Also used : AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) InMemoryCacheImpl(org.n52.sos.cache.InMemoryCacheImpl) AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Time(org.n52.shetland.ogc.gml.time.Time) Envelope(org.locationtech.jts.geom.Envelope)

Example 4 with InMemoryCacheImpl

use of org.n52.sos.cache.InMemoryCacheImpl in project SOS by 52North.

the class ObservationInsertionUpdate method updateObservableProperties.

private void updateObservableProperties(InMemoryCacheImpl cache, AbstractPhenomenon observableProperty, String procedure) {
    // procedure <-> observable property
    cache.addProcedureForObservableProperty(observableProperty.getIdentifier(), procedure);
    cache.addObservablePropertyForProcedure(procedure, observableProperty.getIdentifier());
    // offering <-> observable property
    for (String offering : request.getOfferings()) {
        cache.addOfferingForObservableProperty(observableProperty.getIdentifier(), offering);
        cache.addObservablePropertyForOffering(offering, observableProperty.getIdentifier());
    }
    if (observableProperty instanceof OmCompositePhenomenon) {
        OmCompositePhenomenon parent = (OmCompositePhenomenon) observableProperty;
        cache.addCompositePhenomenon(parent.getIdentifier());
        cache.addCompositePhenomenonForProcedure(procedure, parent.getIdentifier());
        for (String offering : request.getOfferings()) {
            cache.addCompositePhenomenonForOffering(offering, parent.getIdentifier());
        }
        for (OmObservableProperty child : parent) {
            cache.addObservablePropertyForCompositePhenomenon(parent.getIdentifier(), child.getIdentifier());
            cache.addCompositePhenomenonForObservableProperty(child.getIdentifier(), parent.getIdentifier());
        }
    }
}
Also used : OmCompositePhenomenon(org.n52.shetland.ogc.om.OmCompositePhenomenon) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 5 with InMemoryCacheImpl

use of org.n52.sos.cache.InMemoryCacheImpl in project SOS by 52North.

the class ContentCacheControllerImplTest method createController.

private ContentCacheControllerImpl createController() throws ConfigurationError {
    ImmediatePersistenceStrategy persistenceStrategy = new ImmediatePersistenceStrategy();
    persistenceStrategy.setConfigLocationProvider(tempFolder.getRoot()::getAbsolutePath);
    persistenceStrategy.init();
    CompleteCacheUpdateFactoryImpl cacheUpdateFactory = new CompleteCacheUpdateFactoryImpl();
    CacheFeederHandler cacheFeederHandler = new NoOpCacheFeederHandler();
    cacheUpdateFactory.setCacheFeederHandler(cacheFeederHandler);
    ContentCacheFactory cacheFactory = InMemoryCacheImpl::new;
    ContentCacheControllerImpl ccc = new ContentCacheControllerImpl();
    ccc.setCacheFactory(cacheFactory);
    ccc.setPersistenceStrategy(persistenceStrategy);
    ccc.setCompleteCacheUpdateFactory(cacheUpdateFactory);
    ccc.setUpdateInterval(0);
    ccc.init();
    return ccc;
}
Also used : ImmediatePersistenceStrategy(org.n52.iceland.cache.ctrl.persistence.ImmediatePersistenceStrategy) CompleteCacheUpdateFactoryImpl(org.n52.sos.cache.ctrl.CompleteCacheUpdateFactoryImpl) ContentCacheControllerImpl(org.n52.iceland.cache.ctrl.ContentCacheControllerImpl) CacheFeederHandler(org.n52.sos.ds.CacheFeederHandler) ContentCacheFactory(org.n52.iceland.cache.ctrl.ContentCacheFactory)

Aggregations

InMemoryCacheImpl (org.n52.sos.cache.InMemoryCacheImpl)4 Envelope (org.locationtech.jts.geom.Envelope)2 ContentCacheControllerImpl (org.n52.iceland.cache.ctrl.ContentCacheControllerImpl)2 ContentCacheFactory (org.n52.iceland.cache.ctrl.ContentCacheFactory)2 SupportedTypeRepository (org.n52.iceland.coding.SupportedTypeRepository)2 Time (org.n52.shetland.ogc.gml.time.Time)2 OmObservation (org.n52.shetland.ogc.om.OmObservation)2 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)2 SosWritableContentCache (org.n52.sos.cache.SosWritableContentCache)2 CompleteCacheUpdateFactoryImpl (org.n52.sos.cache.ctrl.CompleteCacheUpdateFactoryImpl)2 CacheFeederHandler (org.n52.sos.ds.CacheFeederHandler)2 Set (java.util.Set)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ContentCachePersistenceStrategy (org.n52.iceland.cache.ContentCachePersistenceStrategy)1 ImmediatePersistenceStrategy (org.n52.iceland.cache.ctrl.persistence.ImmediatePersistenceStrategy)1 NoOpCachePersistenceStrategy (org.n52.iceland.cache.ctrl.persistence.NoOpCachePersistenceStrategy)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 AbstractPhenomenon (org.n52.shetland.ogc.om.AbstractPhenomenon)1 OmCompositePhenomenon (org.n52.shetland.ogc.om.OmCompositePhenomenon)1