This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EntityManager aManager = Persistence.createEntityManagerFactory("oreilly") | |
.createEntityManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Book aBook = aManager.find(Book.class, URI.create("urn:x-domain:oreilly.com:product:9780596514129.IP")); | |
// prints: Switching to the Mac: The Missing Manual, Leopard Edition | |
System.err.println(aBook.getTitle()); | |
// prints: O'Reilly Media / Pogue Press | |
System.err.println(aBook.getPublisher()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let's edit our book...maybe we changed the title and published as a PDF | |
aNewBook.setTitle("Return of the Empire"); | |
// create a new manifestation | |
Manifestation aPDFManifestation = new Manifestation(); | |
aPDFManifestation.setIssued(new Date()); | |
// set the dc:type attribute | |
aPDFManifestation.setType(URI.create("http://purl.oreilly.com/product-types/PDF")); | |
aNewBook.setEmbodiments(Arrays.asList(aPDFManifestation)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"service-discovery" : { | |
"response-mimetype" : [ "text/json", "application/rdf+xml", "application/x-turtle", "application/x-ntriples" ], | |
"endpoint" : { | |
"http-methods" : [ "GET" ], | |
"url" : "http://foo:8080/" | |
} | |
}, | |
"knowledge-bases" : [ { | |
"name" : "wine", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ps-discovery": { | |
"response-mimetype": [ | |
"text/json", | |
"application/rdf+xml", | |
"application/x-turtle", | |
"application/x-ntriples" | |
], | |
"endpoint": { | |
"http-methods": ["GET"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[$]> ; wget --header "Accept:text/turtle" http://ps.clarkparsia.com/ -O ps-desc.ttl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String sparql = "SELECT ?a ?b WHERE { ?a <urn:test:b> ?b } LIMIT 5"; | |
List<Map<String,String>> results = snarlTemplate.query(sparql, new RowMapper<Map<String,String>>() { | |
@Override | |
public Map<String,String> mapRow(BindingSet bindingSet) { | |
Map<String,String> map = new HashMap<String,String>(); | |
map.put("a", bindingSet.getValue("a").stringValue()); | |
map.put("b", bindingSet.getValue("b").stringValue()); | |
return map; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String sparql = "CONSTRUCT { ?a <urn:test:new> ?b } WHERE { ?a <urn:test:p> ?b }"; | |
List<Map<String,String>> results = snarlTemplate.construct(sparql, new GraphMapper<Map<String,String>>() { | |
@Override | |
public Map<String, String> mapRow(Statement next) { | |
Map<String,String> map = new HashMap<String,String>(); | |
map.put(next.getSubject().stringValue(), next.getObject().stringValue()); | |
return map; | |
} | |
}); |