/******************************************************************************************************************* * * ******************************************************************************************************************/ public StatementUnmarshallerFactoryImpl() { // FIXME: discover with Lookup unmarshallerMapByType.put(ObservationVocabulary.OBS_OBSERVATION_SET, new SimpleObservationSetUnmarshaller()); unmarshallerMapByType.put(ObservationVocabulary.OBS_OBSERVATION, new SimpleObservationUnmarshaller()); unmarshallerMapByType.put(ObservationVocabulary.OBS_OBSERVATION_ITEM, new SimpleObservationItemUnmarshaller()); unmarshallerMapByType.put(ObservationVocabulary.OBS_OBSERVABLE, new SimpleObservableUnmarshaller()); unmarshallerMapByType.put(ObservationVocabulary.OBS_OBSERVER, new SimpleObserverUnmarshaller()); unmarshallerMapByType.put(ObservationVocabulary.DC_PUBLISHER, new SimpleSourceUnmarshaller()); unmarshallerMapByType.put(ObservationVocabulary.OBS_LOCATION, new SimpleLocationUnmarshaller()); // factoryMapByType.put(Media.FOAF_DOCUMENT, new MediaTripleUnmarshaller()); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ public StatementMarshallerFactoryImpl() { // IXME: discover with Lookup // tripleMarshallerMapByClass.put(FactSheet.class, new FactSheetTripleMarshaller()); marshallerMapByClass.put(Media.class, new MediaMarshaller()); marshallerMapByClass.put(ObservationSet.class, new SimpleObservationSetMarshaller()); marshallerMapByClass.put(Observation.class, new SimpleObservationMarshaller()); marshallerMapByClass.put(ObservationItem.class, new SimpleObservationItemMarshaller()); marshallerMapByClass.put(Observable.class, new SimpleObservableMarshaller()); marshallerMapByClass.put(Observer.class, new SimpleObserverMarshaller()); marshallerMapByClass.put(Source.class, new SimpleSourceMarshaller()); marshallerMapByClass.put(Location.class, new SimpleLocationMarshaller()); }
@Override @Nonnull public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context) { try { final SimpleObservation observation = (SimpleObservation)context.peek(); final Observable observable = (Observable)context.find(findStatementWithPredicate(statements, ObservationVocabulary.FOAF_TOPIC).getObject()); Cardinality cardinality = Cardinality.UNDEFINED; // FIXME return new SimpleObservationItem(observation, observable, cardinality); } catch (NotFoundException e) { throw new RuntimeException(e); // FIXME: throw a checked exception } } }
final Date date = (Date)getLiteral(statements, ObservationVocabulary.DC_DATE); final Location location = (Location)findEntity(context, statements, ObservationVocabulary.OBS_MADE_AT); final Source source = (Source)findEntity(context, statements, ObservationVocabulary.DC_PUBLISHER); final Set<Observer> observers = new HashSet<Observer>(); final Set<ObservationItem> observationItems = new HashSet<ObservationItem>(); extras.add(new DefaultIdentifiable(Converter.valueToId(statements.get(0).getSubject()))); final String displayName = (String)getLiteral(statements, ObservationVocabulary.RDFS_LABEL); context.push(observation); for (final Statement statement : findStatementsWithPredicate(statements, ObservationVocabulary.SKOS_NARROWER)) for (final Statement statement : findStatementsWithPredicate(statements, ObservationVocabulary.DC_CREATOR))
@Override @Nonnull public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context) { // TODO: what about retrieving the observationSet and calling findOrCreate(?) final List<Object> capabilities = new ArrayList<Object>(); capabilities.add(new DefaultIdentifiable(Converter.valueToId(statements.get(0).getSubject()))); try { final String displayName = findStatementWithPredicate(statements, ObservationVocabulary.RDFS_LABEL).getObject().stringValue(); capabilities.add(new DefaultDisplayable(displayName, "SimpleSource")); } catch (NotFoundException e) { // ok. no Displayable } addCapabilities(capabilities, statements, ObservationVocabulary.FOAF_HOME_PAGE); return new SimpleSource(capabilities.toArray()); } }
@Override @Nonnull public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context) { final SimpleObservationSet observationSet = new SimpleObservationSet(); context.push(observationSet); for (final Statement statement : findStatementsWithPredicate(statements, ObservationVocabulary.SKOS_NARROWER)) { observationSet.addObservation((SimpleObservation)context.find(statement.getObject())); } context.pop(); return observationSet; } }
@Override @Nonnull public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context) { // TODO: what about retrieving the observationSet and calling findOrCreate(?) final List<Object> capabilities = new ArrayList<Object>(); try { final String displayName = findStatementWithPredicate(statements, ObservationVocabulary.RDFS_LABEL).getObject().stringValue(); capabilities.add(new DefaultDisplayable(displayName, "SimpleObserver")); } catch (NotFoundException e) { // ok. no Displayable } return new SimpleObserver(capabilities.toArray()); } }
@Override @Nonnull public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context) { // TODO: what about retrieving the observationSet and calling findOrCreate(?) // final List<Object> capabilities = new ArrayList<Object>(); // capabilities.add(new DefaultIdentifiable(statements.get(0).getSubject())); try { final String displayName = findStatementWithPredicate(statements, ObservationVocabulary.RDFS_LABEL).getObject().stringValue(); return new SimpleLocation(new DefaultDisplayable(displayName, "SimpleLocation")); } catch (NotFoundException e) { throw new RuntimeException(e); // ok. no Displayable } // return new SimpleLocation(capabilities.toArray()); } }
@Override @Nonnull public As unmarshal (final @Nonnull List<Statement> statements, final @Nonnull Context context) { // TODO: what about retrieving the observationSet and calling findOrCreate(?) final List<Object> capabilities = new ArrayList<Object>(); capabilities.add(new DefaultIdentifiable(Converter.valueToId(statements.get(0).getSubject()))); try { final String displayName = findStatementWithPredicate(statements, ObservationVocabulary.RDFS_LABEL).getObject().stringValue(); capabilities.add(new DefaultDisplayable(displayName, "SimpleObservable")); } catch (NotFoundException e) { // ok. no Displayable } return new SimpleObservable(capabilities.toArray()); } }