Triples are written to a context by using the Tupelo operator TripleWriter. Simply create a time-annotated resource by wrapping a regular resource with an annotation and then compose a triple using such resource. Any of the subject, predicate or object of the triple can be time-annotated resorces, but only URI references can be annotated. The following code show one way of inserting triples.

The triples to insert are

<urn:ChampaignWeather>["2009-09-07-06:00"] <urn:hasMaxTemperature> "77" .
<urn:ChampaignWeather>["2009-09-08-06:00"] <urn:hasMaxTemperature> "78" .
import edu.uiuc.ncsa.datastream.rdf.TimeAnnotatedResource;
import edu.uiuc.ncsa.datastream.time.TemporalAnnotation;

import org.tupeloproject.rdf.Resource;
import org.tupeloprohect.rdf.Triple;
import org.tupeloproject.kernel.TripleWriter;

import java.util.Date;

//...

Resource stream = Resource.uriRef("urn:ChampaignWeather");
Resource pred = Resource.uriRef("urn:hasMaxTemperature");

//create the triple
// ["2009-09-07-06:00"]  "77"

Date d1 = new Date();
d1.set .... // set d1 to 2009-09-07 CST
//create an annotated resource for ChampaignWeather["2009-09-07-06:00"]
Resource subj1 = TimeAnnotatedResource.create(stream, TemporalAnnotation.getInstant(d1));
Triple t1 = new Triple(subj1,pred,Resource.literal(77));

//create the triple
// ["2009-09-08-06:00]  "78"

Date d2 = new Date();
d2.set .... // set d2 to 2009-09-08 CST
//create an annotated resource for ChampaignWeather["2009-09-08-06:00"]
Resource subj2 = TimeAnnotatedResource.create(stream, TemporalAnnotation.getInstant(d2));
Triple t2 = new Triple(subj2,pred,Resource.literal(78));

//write the triples to the context using a TripleWriter operator

TripleWriter tw = new TripleWriter();
tw.add(t1);
tw.add(t2);
context.perform(tw);
  • No labels