/**
  * Create result values from observation according to ResultEncoding and ResultStructure
  *
  * @param observations Observation to create result values from
  * @param sosResultEncoding The ResultEncoding
  * @param sosResultStructure The ResultStructure
  * @return Result values String from observation according to ResultEncoding and ResultStructure
  * @throws OwsExceptionReport If creation fails
  */
 public static String createResultValuesFromObservations(
     final List<AbstractObservation> observations,
     final SosResultEncoding sosResultEncoding,
     final SosResultStructure sosResultStructure)
     throws OwsExceptionReport {
   final StringBuilder builder = new StringBuilder();
   if (CollectionHelper.isNotEmpty(observations)) {
     final String tokenSeparator = getTokenSeparator(sosResultEncoding.getEncoding());
     final String blockSeparator = getBlockSeparator(sosResultEncoding.getEncoding());
     final Map<Integer, String> valueOrder =
         getValueOrderMap(sosResultStructure.getResultStructure());
     addElementCount(builder, observations.size(), blockSeparator);
     for (final AbstractObservation observation : observations) {
       for (final Integer intger : valueOrder.keySet()) {
         final String definition = valueOrder.get(intger);
         if (definition.equals(PHENOMENON_TIME)) {
           builder.append(
               getTimeStringForPhenomenonTime(
                   observation.getPhenomenonTimeStart(), observation.getPhenomenonTimeEnd()));
         } else if (definition.equals(RESULT_TIME)) {
           builder.append(getTimeStringForResultTime(observation.getResultTime()));
         } else {
           builder.append(getValueAsStringForObservedProperty(observation, definition));
         }
         builder.append(tokenSeparator);
       }
       builder.delete(builder.lastIndexOf(tokenSeparator), builder.length());
       builder.append(blockSeparator);
     }
     if (builder.length() > 0) {
       builder.delete(builder.lastIndexOf(blockSeparator), builder.length());
     }
   }
   return builder.toString();
 }
Esempio n. 2
0
 /**
  * Set the {@link MediaType}s, clears the existing collection
  *
  * @param mediaTypes the media types to set
  * @return this
  */
 public InspireResourceLocator setMediaTypes(Collection<MediaType> mediaTypes) {
   getMediaTypes().clear();
   if (CollectionHelper.isNotEmpty(mediaTypes)) {
     getMediaTypes().addAll(mediaTypes);
   }
   return this;
 }
Esempio n. 3
0
 public static Set<String> getFeatureIdentifier(
     SpatialFilter spatialFilter, List<String> featureIdentifier, Session session)
     throws OwsExceptionReport {
   Set<String> foiIDs = null;
   // spatial filter
   if (spatialFilter != null) {
     if (spatialFilter.getValueReference().contains("om:featureOfInterest")
         && spatialFilter.getValueReference().contains("sams:shape")) {
       foiIDs =
           new HashSet<String>(
               Configurator.getInstance()
                   .getFeatureQueryHandler()
                   .getFeatureIDs(spatialFilter, session));
     } else {
       throw new NoApplicableCodeException()
           .withMessage(
               "The requested valueReference for spatial filters is not supported by this server!");
     }
   }
   // feature of interest
   if (CollectionHelper.isNotEmpty(featureIdentifier)) {
     if (foiIDs == null) {
       foiIDs = new HashSet<String>(featureIdentifier);
     } else {
       Set<String> tempFoiIDs = new HashSet<String>();
       for (String foiID : featureIdentifier) {
         if (foiIDs.contains(foiID)) {
           tempFoiIDs.add(foiID);
         }
       }
       foiIDs = tempFoiIDs;
     }
   }
   return foiIDs;
 }
Esempio n. 4
0
 @Override
 public String toString() {
   return String.format(
       "%s %n[%n url=%s,%n mediaTypes=%s%n]",
       this.getClass().getSimpleName(),
       getURL(),
       CollectionHelper.collectionToString(getMediaTypes()));
 }
public class EReportingObservationCreator
    implements AdditionalObservationCreator<EReportingSeries> {

  @SuppressWarnings("unchecked")
  private static final Set<AdditionalObservationCreatorKey> KEYS =
      CollectionHelper.union(
          AdditionalObservationCreatorRepository.encoderKeysForElements(
              AqdConstants.NS_AQD,
              EReportingObservation.class,
              EReportingBlobObservation.class,
              EReportingBooleanObservation.class,
              EReportingCategoryObservation.class,
              EReportingCountObservation.class,
              EReportingGeometryObservation.class,
              EReportingNumericObservation.class,
              EReportingSweDataArrayObservation.class,
              EReportingTextObservation.class,
              EReportingSeries.class),
          AdditionalObservationCreatorRepository.encoderKeysForElements(
              null,
              EReportingObservation.class,
              EReportingBlobObservation.class,
              EReportingBooleanObservation.class,
              EReportingCategoryObservation.class,
              EReportingCountObservation.class,
              EReportingGeometryObservation.class,
              EReportingNumericObservation.class,
              EReportingSweDataArrayObservation.class,
              EReportingTextObservation.class));

  private final EReportingObservationHelper helper = new EReportingObservationHelper();

  @Override
  public Set<AdditionalObservationCreatorKey> getKeys() {
    return KEYS;
  }

  @Override
  public OmObservation create(OmObservation omObservation, AbstractObservation observation) {
    if (observation instanceof EReportingObservation) {
      EReportingObservation eReportingObservation = (EReportingObservation) observation;
      create(omObservation, eReportingObservation.getEReportingSeries());
      add(omObservation, observation);
      omObservation.setValue(
          EReportingHelper.createSweDataArrayValue(omObservation, eReportingObservation));
      omObservation
          .getObservationConstellation()
          .setObservationType(OmConstants.OBS_TYPE_SWE_ARRAY_OBSERVATION);
    }
    return omObservation;
  }

  @Override
  public OmObservation create(OmObservation omObservation, EReportingSeries series) {
    for (NamedValue<?> namedValue : helper.createOmParameterForEReporting(series)) {
      omObservation.addParameter(namedValue);
    }
    return omObservation;
  }

  @Override
  public OmObservation add(OmObservation omObservation, AbstractObservation observation) {
    if (observation instanceof EReportingObservation) {
      EReportingObservation eReportingObservation = (EReportingObservation) observation;
      omObservation.setAdditionalMergeIndicator(eReportingObservation.getPrimaryObservation());
    }
    return omObservation;
  }
}
Esempio n. 6
0
 public boolean isSetVerificationFlags() {
   return CollectionHelper.isNotEmpty(getVerificationFlags());
 }
Esempio n. 7
0
 public boolean isSetValidityFlags() {
   return CollectionHelper.isNotEmpty(getValidityFlags());
 }
 /**
  * Check the queried {@link AbstractValue}s for null and set them as iterator to local variable.
  *
  * @param valuesResult Queried {@link AbstractValue}s
  */
 private void setObservationValuesResult(Collection<AbstractValue> valuesResult) {
   if (CollectionHelper.isNotEmpty(valuesResult)) {
     this.valuesResult = valuesResult.iterator();
   }
 }
Esempio n. 9
0
 public boolean isSetOfferings() {
   return CollectionHelper.isNotEmpty(getOfferings());
 }
Esempio n. 10
0
 public boolean isSetObservation() {
   return CollectionHelper.isNotEmpty(getObservations());
 }
Esempio n. 11
0
 /**
  * Check if media types are set
  *
  * @return <code>true</code>, if media types are set
  */
 public boolean isSetMediaTypes() {
   return CollectionHelper.isNotEmpty(getMediaTypes());
 }
Esempio n. 12
0
 public List<Spelling> getSpelling() {
   if (CollectionHelper.isEmpty(spelling)) {
     addSpelling(new Spelling());
   }
   return Collections.unmodifiableList(spelling);
 }