@Nonnull public Finder<Location> create (final @Nonnull SimpleObservationSet observationSet) { final Set<Location> locations = new HashSet<Location>(); for (final Observation observation : observationSet.observations) { locations.add(observation.getLocation()); } return new SimpleFinderSupport<Location>(locations); } };
/******************************************************************************************************************* * * ******************************************************************************************************************/ protected SimpleObservationChangeBuilder (final @Nonnull SimpleObservationSet observationSet, final @Nonnull Observation originalObservation) { super(observationSet); this.originalObservation = originalObservation; at(originalObservation.getDate()); at(originalObservation.getLocation()); for (final Observer observer : originalObservation.findObservers().results()) { by(observer); } for (final ObservationItem observationItem : originalObservation.findObservationItems().results()) { of(observationItem.getObservable(), observationItem.getCardinality()); } }
@Override @Nonnull public void marshal (final @Nonnull As entity, final @Nonnull Context context) { super.marshal(entity, context); final Observation observation = (Observation)entity; context.addStatement(observation, Vocabulary.RDF_TYPE, Vocabulary.OBSERVATION); context.addStatement(observation, Vocabulary.DC_DATE, observation.getDate()); context.addStatement(observation, Vocabulary.MADE_AT, observation.getLocation()); context.addStatement(observation, Vocabulary.DC_PUBLISHER, observation.getSource()); for (final Observer observer : observation.findObservers().results()) { context.addStatement(observation, Vocabulary.DC_CREATOR, observer); } for (final ObservationItem observationItem : observation.findObservationItems().results()) { context.addStatement(observation, Vocabulary.SKOS_NARROWER, observationItem); } try { context.addStatement(observation.as(Media.class), Vocabulary.FOAF_TOPIC, observation); } catch (AsException e) { // ok, no attachment } } }