Skip to content

Instantly share code, notes, and snippets.

@jnorthrup
Created December 20, 2010 23:57
Show Gist options
  • Save jnorthrup/749252 to your computer and use it in GitHub Desktop.
Save jnorthrup/749252 to your computer and use it in GitHub Desktop.
jena query on appengine
private Model createCacheGzipModel(String url, MemcacheService memcacheService, final String hash) {
final Model model = ModelFactory.createDefaultModel(ReificationStyle.Minimal);
final InputStream inputStream;
try {
inputStream = new java.net.URL(url).openStream();
model.read(inputStream, null);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
cacheModel(url, memcacheService, model);
Model index = model.query(new SimpleSelector() {
@Override
public boolean test(Statement s) {
if (s.getPredicate().getURI().equals(TalkwheelClient.RSS_DESCRIPTION)) {
// model.remove(s);
final RDFNode object1 = s.getObject();
final RdfDescription rdfDescription = new RdfDescription();
//shorthand for "make a Memento with this key and create an entity for it"
final Entity rd = new Entity(MementoFactory.$$(rdfDescription.$$(new MD5(s.getSubject().getURI()).asHex())));
rd.setProperty("description", new Text(s.getObject().asLiteral().getString()));
DS.put(rd);
return false;
}
return true;
}
});
cacheModel(url, memcacheService, index, "$");
return index;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment