@Test void testTimeMapLink() { final String url = "http: final Link link = fromUri(url).rel("timemap").param("from", "Fri, 11 May 2018 15:29:25 GMT") .param("until", "Fri, 11 May 2018 20:12:47 GMT").build(); final List<Triple> triples = DefaultTimemapGenerator.buildTriplesFromLink(link).collect(toList()); assertEquals(3L, triples.size()); assertTrue(triples.stream().anyMatch(triple -> rdf.createIRI(url).equals(triple.getSubject()) && type.equals(triple.getPredicate()) && Memento.TimeMap.equals(triple.getObject()))); assertTrue(triples.stream().anyMatch(triple -> rdf.createIRI(url).equals(triple.getSubject()) && Time.hasBeginning.equals(triple.getPredicate()))); assertTrue(triples.stream().anyMatch(triple -> rdf.createIRI(url).equals(triple.getSubject()) && Time.hasEnd.equals(triple.getPredicate()))); }
static Stream<Triple> buildTriplesFromLink(final Link link) { final String linkUri = link.getUri().toString(); final IRI iri = rdf.createIRI(linkUri); final Stream.Builder<Triple> buffer = Stream.builder(); if (link.getParams().containsKey(FROM)) { buffer.add(rdf.createTriple(iri, type, Memento.TimeMap)); buffer.add(rdf.createTriple(iri, Time.hasBeginning, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(FROM), RFC_1123_DATE_TIME).toString()))); } if (link.getParams().containsKey(UNTIL)) { buffer.add(rdf.createTriple(iri, Time.hasEnd, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(UNTIL), RFC_1123_DATE_TIME).toString()))); } if (isMementoLink(link)) { final IRI original = rdf.createIRI(linkUri.split("\\?")[0]); final IRI timemapUrl = rdf.createIRI(linkUri.split("\\?")[0] + "?ext=timemap"); buffer.add(rdf.createTriple(iri, type, Memento.Memento)); buffer.add(rdf.createTriple(iri, Memento.original, original)); buffer.add(rdf.createTriple(iri, Memento.timegate, original)); buffer.add(rdf.createTriple(iri, Memento.timemap, timemapUrl)); buffer.add(rdf.createTriple(iri, Time.hasTime, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString()))); buffer.add(rdf.createTriple(iri, Memento.mementoDatetime, rdf.createLiteral(parse( link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString(), XSD.dateTime))); } return buffer.build(); }
DefaultTimemapGenerator implements TimemapGenerator { static Stream<Triple> buildTriplesFromLink(final Link link) { final String linkUri = link.getUri().toString(); final IRI iri = rdf.createIRI(linkUri); final Stream.Builder<Triple> buffer = Stream.builder(); if (link.getParams().containsKey(FROM)) { buffer.add(rdf.createTriple(iri, type, Memento.TimeMap)); buffer.add(rdf.createTriple(iri, Time.hasBeginning, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(FROM), RFC_1123_DATE_TIME).toString()))); } if (link.getParams().containsKey(UNTIL)) { buffer.add(rdf.createTriple(iri, Time.hasEnd, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(UNTIL), RFC_1123_DATE_TIME).toString()))); } if (isMementoLink(link)) { final IRI original = rdf.createIRI(linkUri.split("\\?")[0]); final IRI timemapUrl = rdf.createIRI(linkUri.split("\\?")[0] + "?ext=timemap"); buffer.add(rdf.createTriple(iri, type, Memento.Memento)); buffer.add(rdf.createTriple(iri, Memento.original, original)); buffer.add(rdf.createTriple(iri, Memento.timegate, original)); buffer.add(rdf.createTriple(iri, Memento.timemap, timemapUrl)); buffer.add(rdf.createTriple(iri, Time.hasTime, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString()))); buffer.add(rdf.createTriple(iri, Memento.mementoDatetime, rdf.createLiteral(parse( link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString(), XSD.dateTime))); } return buffer.build(); } }
DefaultTimemapGenerator implements TimemapGenerator { static Stream<Triple> buildTriplesFromLink(final Link link) { final String linkUri = link.getUri().toString(); final IRI iri = rdf.createIRI(linkUri); final Stream.Builder<Triple> buffer = Stream.builder(); if (link.getParams().containsKey(FROM)) { buffer.add(rdf.createTriple(iri, type, Memento.TimeMap)); buffer.add(rdf.createTriple(iri, Time.hasBeginning, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(FROM), RFC_1123_DATE_TIME).toString()))); } if (link.getParams().containsKey(UNTIL)) { buffer.add(rdf.createTriple(iri, Time.hasEnd, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(UNTIL), RFC_1123_DATE_TIME).toString()))); } if (isMementoLink(link)) { final IRI original = rdf.createIRI(linkUri.split("\\?")[0]); final IRI timemapUrl = rdf.createIRI(linkUri.split("\\?")[0] + "?ext=timemap"); buffer.add(rdf.createTriple(iri, type, Memento.Memento)); buffer.add(rdf.createTriple(iri, Memento.original, original)); buffer.add(rdf.createTriple(iri, Memento.timegate, original)); buffer.add(rdf.createTriple(iri, Memento.timemap, timemapUrl)); buffer.add(rdf.createTriple(iri, Time.hasTime, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString()))); buffer.add(rdf.createTriple(iri, Memento.mementoDatetime, rdf.createLiteral(parse( link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString(), XSD.dateTime))); } return buffer.build(); }  }
DefaultTimemapGenerator implements TimemapGenerator { static Stream<Triple> buildTriplesFromLink(final Link link) { final String linkUri = link.getUri().toString(); final IRI iri = rdf.createIRI(linkUri); final Stream.Builder<Triple> buffer = Stream.builder(); if (link.getParams().containsKey(FROM)) { buffer.add(rdf.createTriple(iri, type, Memento.TimeMap)); buffer.add(rdf.createTriple(iri, Time.hasBeginning, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(FROM), RFC_1123_DATE_TIME).toString()))); } if (link.getParams().containsKey(UNTIL)) { buffer.add(rdf.createTriple(iri, Time.hasEnd, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(UNTIL), RFC_1123_DATE_TIME).toString()))); } if (isMementoLink(link)) { final IRI original = rdf.createIRI(linkUri.split("\\?")[0]); final IRI timemapUrl = rdf.createIRI(linkUri.split("\\?")[0] + "?ext=timemap"); buffer.add(rdf.createTriple(iri, type, Memento.Memento)); buffer.add(rdf.createTriple(iri, Memento.original, original)); buffer.add(rdf.createTriple(iri, Memento.timegate, original)); buffer.add(rdf.createTriple(iri, Memento.timemap, timemapUrl)); buffer.add(rdf.createTriple(iri, Time.hasTime, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString()))); buffer.add(rdf.createTriple(iri, Memento.mementoDatetime, rdf.createLiteral(parse( link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString(), XSD.dateTime))); } return buffer.build(); }  @Override Stream<Triple> asRdf(final String identifier, final List<Link> mementos); }
DefaultTimemapGenerator implements TimemapGenerator { static Stream<Triple> buildTriplesFromLink(final Link link) { final String linkUri = link.getUri().toString(); final IRI iri = rdf.createIRI(linkUri); final Stream.Builder<Triple> buffer = Stream.builder(); if (link.getParams().containsKey(FROM)) { buffer.add(rdf.createTriple(iri, type, Memento.TimeMap)); buffer.add(rdf.createTriple(iri, Time.hasBeginning, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(FROM), RFC_1123_DATE_TIME).toString()))); } if (link.getParams().containsKey(UNTIL)) { buffer.add(rdf.createTriple(iri, Time.hasEnd, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(UNTIL), RFC_1123_DATE_TIME).toString()))); } if (isMementoLink(link)) { final IRI original = rdf.createIRI(linkUri.split("\\?")[0]); final IRI timemapUrl = rdf.createIRI(linkUri.split("\\?")[0] + "?ext=timemap"); buffer.add(rdf.createTriple(iri, type, Memento.Memento)); buffer.add(rdf.createTriple(iri, Memento.original, original)); buffer.add(rdf.createTriple(iri, Memento.timegate, original)); buffer.add(rdf.createTriple(iri, Memento.timemap, timemapUrl)); buffer.add(rdf.createTriple(iri, Time.hasTime, rdf.createIRI(TIME_IRI_PREFIX + parse(link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString()))); buffer.add(rdf.createTriple(iri, Memento.mementoDatetime, rdf.createLiteral(parse( link.getParams().get(DATETIME), RFC_1123_DATE_TIME).toString(), XSD.dateTime))); } return buffer.build(); }  @Override Stream<Triple> asRdf(final String identifier, final List<Link> mementos);  }