public static Map<String, String> getCacheValues() { SosContentCache cache = Configurator.getInstance().getCache(); Map<String, String> values = new TreeMap<>(); values.put(LAST_UPDATE_TIME, nullSafeToString(cache.getLastUpdateTime())); values.put(MIN_PHENOMENON_TIME, nullSafeToString(cache.getMinPhenomenonTime())); values.put(MAX_PHENOMENON_TIME, nullSafeToString(cache.getMaxPhenomenonTime())); values.put(MIN_RESULT_TIME, nullSafeToString(cache.getMinResultTime())); values.put(MAX_RESULT_TIME, nullSafeToString(cache.getMaxResultTime())); values.put(GLOBAL_ENVELOPE, nullSafeToString(cache.getGlobalEnvelope())); values.put(NUM_OFFERINGS, nullSafeToString(cache.getOfferings())); values.put(NUM_PROCEDURES, nullSafeToString(cache.getProcedures())); values.put(NUM_OBSERVABLE_PROPERTIES, nullSafeToString(cache.getObservableProperties())); values.put(NUM_FEATURES_OF_INTEREST, nullSafeToString(cache.getFeaturesOfInterest())); values.put(NUM_FEATURE_OF_INTEREST_TYPES, nullSafeToString(cache.getFeatureOfInterestTypes())); values.put(NUM_OBSERVATION_TYPES, nullSafeToString(cache.getObservationTypes())); values.put(NUM_RELATED_FEATURES, nullSafeToString(cache.getRelatedFeatures())); values.put(NUM_RESULT_TEMPLATES, nullSafeToString(cache.getResultTemplates())); values.put(DEFAULT_EPSG, Integer.toString(cache.getDefaultEPSGCode())); values.put(NUM_EPSGS, nullSafeToString(cache.getEpsgCodes())); return values; }
protected Collection<String> getProceduresForOffering(String offering, String version) throws OwsExceptionReport { Collection<String> procedures =new HashSet<>(getCache().getProceduresForOffering(offering)); if (version.equals(Sos1Constants.SERVICEVERSION)) { procedures.addAll(getCache().getHiddenChildProceduresForOffering(offering)); } return procedures.stream() .filter(getCache().getPublishedProcedures()::contains) .collect(toSet()); }
private boolean checkComponentsIfInserted(List<OmObservableProperty> phenomenonComponents) { for (OmObservableProperty omObservableProperty : phenomenonComponents) { if (getCache().hasObservableProperty(omObservableProperty.getIdentifier()) && !getCache() .getProceduresForObservableProperty(omObservableProperty.getIdentifier()).isEmpty()) { return true; } } return false; }
@RequestMapping(method = RequestMethod.GET) public ModelAndView view() { Map<String, String> model = new HashMap<>(4); SosContentCache cache = getCache(); model.put(OFFERINGS, asJSONArray(cache.getOfferings())); model.put(PROCEDURES, asJSONArray(cache.getProcedures())); model.put(FEATURES, asJSONArray(cache.getFeaturesOfInterest())); model.put(OBSERVABLE_PROPERTIES, asJSONArray(cache .getObservableProperties())); return new ModelAndView(ControllerConstants.Views.ADMIN_I18N, model); }
protected Collection<String> getObservationTypes(String offering) { Set<String> observationTypes = getCache().getObservationTypesForOffering(offering).stream() .filter(Predicate.isEqual(SosConstants.NOT_DEFINED).negate()) .collect(Collectors.toSet()); if (observationTypes.isEmpty()) { getCache().getAllowedObservationTypesForOffering(offering).stream() .filter(Predicate.isEqual(SosConstants.NOT_DEFINED).negate()) .forEach(observationTypes::add); } return observationTypes; }
@Override public boolean hasExtendedOfferingFor(String identifier) { return this.enabled && getCache().getOfferings().contains(identifier); }
/** * checks if the passed offeringId is supported * * @param offeringIds * the offeringId to be checked * * * @throws OwsExceptionReport * if the passed offeringId is not supported */ private void checkOfferingId(final List<String> offeringIds) throws OwsExceptionReport { if (offeringIds != null) { Set<String> offerings = getCache().getOfferings(); CompositeOwsException exceptions = new CompositeOwsException(); offeringIds.forEach((offeringId) -> { if (offeringId == null || offeringId.isEmpty()) { exceptions.add(new MissingOfferingParameterException()); } else if (offeringId.contains(SosConstants.SEPARATOR_4_OFFERINGS)) { final String[] offArray = offeringId.split(SosConstants.SEPARATOR_4_OFFERINGS); if (!offerings.contains(offArray[0]) || !getCache().getProceduresForOffering(offArray[0]).contains(offArray[1])) { exceptions.add(new InvalidOfferingParameterException(offeringId)); } } else if (!offerings.contains(offeringId)) { exceptions.add(new InvalidOfferingParameterException(offeringId)); } }); exceptions.throwIfNotEmpty(); } }
@Override public OwsCapabilitiesExtension getExtension() { SosContentCache cache = getCache(); SosInsertionCapabilities insertionCapabilities = new SosInsertionCapabilities(); insertionCapabilities.addFeatureOfInterestTypes(cache.getFeatureOfInterestTypes()); insertionCapabilities.addObservationTypes(cache.getObservationTypes()); insertionCapabilities.addProcedureDescriptionFormats(this.procedureDescriptionFormatRepository .getSupportedProcedureDescriptionFormats(SosConstants.SOS, Sos2Constants.SERVICEVERSION)); return insertionCapabilities; }
String version = sectionSpecificContentObject.getGetCapabilitiesResponse().getVersion(); SosContentCache cache = getCache(); Collection<String> offerings = cache.getOfferings(); List<SosObservationOffering> sosOfferings = new ArrayList<>(offerings.size()); for (String offering : offerings) { Collection<String> procedures = getProceduresForOffering(offering, version); ReferencedEnvelope envelopeForOffering = cache.getEnvelopeForOffering(offering); Set<String> featuresForoffering = getFOI4offering(offering); Collection<String> responseFormats = getResponseFormatRepository() sosObservationOffering.setObservedArea(cache.getEnvelopeForOffering(offering)); sosObservationOffering.setObservableProperties(cache.getObservablePropertiesForOffering(offering)); sosObservationOffering.setCompositePhenomena(cache.getCompositePhenomenonsForOffering(offering)); Map<String, Set<String>> phens4CompPhens = cache.getCompositePhenomenonsForOffering(offering).stream() .collect(toMap(Function.identity(), cache::getObservablePropertiesForCompositePhenomenon)); sosObservationOffering.setPhens4CompPhens(phens4CompPhens); cache.getObservationTypesForOffering(offering)); sosObservationOffering.setResultModels(resultModels);
protected void checkOffering(String offering, String parameterName, boolean all) throws OwsExceptionReport { if (offering == null || offering.isEmpty()) { throw new MissingParameterValueException(parameterName); } if (all) { if (!getCache().getOfferings().contains(offering)) { throw new InvalidParameterValueException(parameterName, offering); } } else { if (!getCache().getPublishedOfferings().contains(offering)) { throw new InvalidParameterValueException(parameterName, offering); } } }
/** * Checks whether the specified ObservableProperty is known. * * @param observableProperty the observable property * * @return {@code true} if it is contained */ default boolean hasObservableProperty(String observableProperty) { return getObservableProperties().contains(observableProperty); }
protected OwsDomain getOfferingParameter(String service, String version) { if (checkListOnlyParentOfferings()) { return getOfferingParameter(service, version, getCache().getParentOfferings(getCache().getOfferings(), false, false)); } else { return getOfferingParameter(service, version, getCache().getOfferings()); } }
protected void checkObservedProperty(String observedProperty, String parameterName, boolean insertion) throws OwsExceptionReport { if (observedProperty == null || observedProperty.isEmpty()) { throw new MissingParameterValueException(parameterName); } if (insertion) { if (!getCache().hasObservableProperty(observedProperty)) { throw new InvalidParameterValueException(parameterName, observedProperty); } } else if (isIncludeChildObservableProperties()) { if (getCache().isCompositePhenomenon(observedProperty) || !(getCache().isCompositePhenomenonComponent(observedProperty) || getCache().hasObservableProperty(observedProperty))) { throw new InvalidParameterValueException(parameterName, observedProperty); } } else if (!getCache().getPublishedObservableProperties().contains(observedProperty)) { throw new InvalidParameterValueException(parameterName, observedProperty); } }
private void checkObservedPropertyOfferingPairs(DeleteResultTemplateRequest request, CompositeOwsException exceptions) { if (request.isSetObservedPropertyOfferingPairs()) { for (Map.Entry<String, String> propertyOfferingPair : request.getObservedPropertyOfferingPairs()) { if (!getCache().hasOffering(propertyOfferingPair.getValue())) { exceptions.add(new InvalidParameterValueException( DeleteResultTemplateConstants.PARAMETERS.offering, propertyOfferingPair.getValue())); } if (!getCache().hasObservableProperty(propertyOfferingPair.getKey())) { exceptions.add(new InvalidParameterValueException( DeleteResultTemplateConstants.PARAMETERS.observableProperty, propertyOfferingPair.getKey())); } } } }
@Override protected boolean isValid(SosContentCache cache, String id) { return cache.hasOffering(id); }
@Override protected boolean isValid(SosContentCache cache, String id) { return cache.hasObservableProperty(id); }
protected Collection<String> getObservableProperties() { Set<String> observableProperties = getCache().getObservableProperties(); if (isIncludeChildObservableProperties()) { Set<String> compositePhenomenons = getCache().getCompositePhenomenons(); observableProperties.removeAll(compositePhenomenons); compositePhenomenons.stream().map(getCache()::getObservablePropertiesForCompositePhenomenon) .flatMap(Set::stream).forEach(observableProperties::add); } return observableProperties; }
private void checkObservations(final InsertObservationRequest request) throws OwsExceptionReport { if (CollectionHelper.isEmpty(request.getObservations())) { throw new MissingObservationParameterException(); } else { final SosContentCache cache = getCache(); final CompositeOwsException exceptions = new CompositeOwsException(); for (final OmObservation observation : request.getObservations()) { final OmObservationConstellation obsConstallation = observation.getObservationConstellation(); checkObservationConstellationParameter(obsConstallation); // Requirement 67 checkOrSetObservationType(observation, isSplitObservations(request)); if (!cache.getObservationTypes().contains(obsConstallation.getObservationType())) { exceptions.add(new InvalidObservationTypeException(obsConstallation.getObservationType())); } else if (obsConstallation.isSetOfferings()) { for (final String offeringID : obsConstallation.getOfferings()) { final Collection<String> allowedObservationTypes = cache .getAllowedObservationTypesForOffering(offeringID); if ((allowedObservationTypes == null || !allowedObservationTypes.contains(obsConstallation.getObservationType())) && !request.isSetExtensionSplitDataArrayIntoObservations()) { exceptions.add(new InvalidObservationTypeForOfferingException( obsConstallation.getObservationType(), offeringID)); } } } } exceptions.throwIfNotEmpty(); } }
/** * Checks whether the specified featureOfInterest type exists. * * @param featureOfInterestType the observation type * * @return {@code true} if it exists */ default boolean hasFeatureOfInterestType(String featureOfInterestType) { return getFeatureOfInterestTypes().contains(featureOfInterestType); }
/** * Checks whether the specified observation type exists. * * @param observationType the observation type * * @return {@code true} if it exists */ default boolean hasObservationType(String observationType) { return getObservationTypes().contains(observationType); }