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);
}
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);
}
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);
}
}
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());
}
}
}
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;
}
Aggregations