Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Code Block
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.TripleMatcher;

//...

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

Date d1 = new Date();
Date d2 = new Date();
d1.set .... // set d1 to 2009-07-01 CST
d2.set ...  // set d2 to 2009-07-31 CST
//create an annotated resource for ChampaignWeather["2009-07-01-05:00".."2009-07-01-05:00"]
Resource subj1 = TimeAnnotatedResource.create(stream, TemporalAnnotation.getInterval(d1,d2));

TripleMatcher stm = new TripleMatcher();
stm.setSubject(subj1);
stm.setPredicate(pred);

context.perform(stm);

for(Triple triple : stm.getResults())
  processResult(triple.getObject()); //do something with the result

Wiki MarkupFinally, if you need to match a pattern like ?x\["2009-09-07-05:00"\] <urn:hasMaxTemperature> "77" , where was the temperature 77 on September 7th, you can use the class TimeAnnotatedVariable in aTripleMatcher:

Code Block
Date d1 = new Date();
d1.set ...// set d1 to 2009-09-07 CST
Resource pred = Resource.uriRef("urn:hasMaxTemperature");
TimeAnnotatedVariable subj = new TimeAnnotatedVariable("x",TemporalAnnotation.getInstant(d1));
Resource obj = Resource.literal("77");

TripleMatcher stm = new TripleMatcher();
stm.setPattern(new Pattern(subj,pred,obj));

context.perform(stm);

for(Triple triple : stm.getResult())
  processResult(triple.getSubject()); //do something with the results