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; }
private void checkObservationType(InsertResultTemplateRequest request) throws OwsExceptionReport { OmObservationConstellation observationConstellation = request.getObservationTemplate(); if (observationConstellation.isSetObservationType()) { // TODO check why setting SweArray_Observation as type //observationConstellation.setObservationType(OmConstants.OBS_TYPE_SWE_ARRAY_OBSERVATION); // check if observation type is supported checkObservationType(observationConstellation.getObservationType(), Sos2Constants.InsertResultTemplateParams.observationType.name()); } Set<String> validObservationTypesForOffering = new HashSet<>(0); for (String offering : observationConstellation.getOfferings()) { validObservationTypesForOffering.addAll(getCache() .getAllowedObservationTypesForOffering(offering)); } // check if observation type is valid for offering if (!validObservationTypesForOffering.contains(observationConstellation.getObservationType())) { throw new InvalidParameterValueException().at(Sos2Constants.InsertResultTemplateParams.observationType) .withMessage("The requested observation type is not valid for the offering!"); } }
private void checkObservationType(InsertResultTemplateRequest request) throws OwsExceptionReport { OmObservationConstellation observationConstellation = request.getObservationTemplate(); if (observationConstellation.isSetObservationType()) { // TODO check why setting SweArray_Observation as type //observationConstellation.setObservationType(OmConstants.OBS_TYPE_SWE_ARRAY_OBSERVATION); // check if observation type is supported checkObservationType(observationConstellation.getObservationType(), Sos2Constants.InsertResultTemplateParams.observationType.name()); } Set<String> validObservationTypesForOffering = new HashSet<>(0); for (String offering : observationConstellation.getOfferings()) { validObservationTypesForOffering.addAll(getCache() .getAllowedObservationTypesForOffering(offering)); } // check if observation type is valid for offering if (!validObservationTypesForOffering.contains(observationConstellation.getObservationType())) { throw new InvalidParameterValueException().at(Sos2Constants.InsertResultTemplateParams.observationType) .withMessage("The requested observation type is not valid for the offering!"); } }
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(); } }