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
// Lastly, we can use the query API to run arbitrary sparql queries | |
// create a jpql-style partial SPARQL query (JPQL is currently unsupported) | |
Query aQuery = aManager.createQuery("where { ?result frbr:embodiment ?manifest." + | |
" ?foo <http://purl.org/goodrelations/v1#typeOfGood> ?manifest . " + | |
" ?foo <http://purl.org/goodrelations/v1#hasPriceSpecification> ?price. " + | |
" ?price <http://purl.org/goodrelations/v1#hasCurrencyValue> ?value. " + | |
" ?price <http://purl.org/goodrelations/v1#hasCurrency> \"USD\"@en." + | |
" filter(?value > ??min). }"); | |
// this query should return instances of type Book |
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
Graph aGraph = new GraphImpl(); | |
URI aBook = aGraph.getValueFactory().createURI("urn:x-domain:oreilly.com:product:9780596514129.IP"); | |
aGraph.add(aBook, | |
aGraph.getValueFactory().createURI("http://purl.org/dc/terms/publisher"), | |
aGraph.getValueFactory().createLiteral("O'Reilly Media / Pogue Press")); | |
aGraph.add(aBook, | |
aGraph.getValueFactory().createURI("http://purl.org/dc/terms/title"), | |
aGraph.getValueFactory().createLiteral( | |
"Switching to the Mac: The Missing Manual, Leopard Edition")); | |
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
<rdf:Description rdf:about="urn:x-domain:oreilly.com:product:9780596514129.IP"> | |
<foaf1:primarySubjectOf rdf:resource="http://oreilly.com/catalog/9780596514129"/> | |
<dc1:title xml:lang="en">Switching to the Mac: The Missing Manual, Leopard Edition</dc1:title> | |
<dc1:title>Switching to the Mac: The Missing Manual, Leopard Edition</dc1:title> | |
<dc1:creator rdf:resource="urn:x-domain:oreilly.com:agent:pdb:350"/> | |
<dc1:publisher xml:lang="en">O'Reilly Media / Pogue Press</dc1:publisher> | |
<dc1:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2008-02-26</dc1:issued> | |
<frbr1:embodiment rdf:resource="urn:x-domain:oreilly.com:product:9780596514129.BOOK"/> | |
<frbr1:embodiment rdf:resource="urn:x-domain:oreilly.com:product:9780596802899.EBOOK"/> | |
<frbr1:embodiment rdf:resource="urn:x-domain:oreilly.com:product:9780596514129.SAF"/> |
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
@RdfProperty("dc:title") | |
private String title; | |
@RdfProperty("dc:publisher") | |
private String publisher; | |
@RdfProperty("dc:issued") | |
private Date issued; | |
@RdfProperty("frbr:embodiment") |
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
// now we can delete our new book | |
aManager.remove(aNewBook); | |
// false! | |
System.err.println(aManager.contains(aNewBook)); | |
// but the new manifestation still exists, since we did not specify that deletes should cascade... | |
// true! | |
System.err.println(aManager.contains(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
@Entity | |
public class Book |
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
// ... annotations ... | |
public class Book implements SupportsRdfId |
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
private String title; | |
private String publisher; | |
private Date issued; |
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
@OneToMany(fetch = FetchType.LAZY, | |
cascade = {CascadeType.PERSIST, CascadeType.MERGE}) | |
private Collection<Manifestation> mEmbodiments = new HashSet<Manifestation>(); |
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
Empire.init(new OpenRdfEmpireModule()); |