Package net.bioclipse.managers
Class RDFManager
java.lang.Object
net.bioclipse.managers.RDFManager
Bioclipse manager that provides functionality around the Resource
Description Framework standard. It allows creating in memory and
on disk triple stores, creating on content, and IO functionality.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value) Creates a new RDF data triple in the given triple store.voidaddObjectProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String object) Creates a new RDF object triple in the given triple store.voidAdds a prefix definition to the given triple store.voidaddPropertyInLanguage(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value, String language) Creates a new RDF data triple in the given triple store.voidaddTypedDataProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value, String dataType) Creates a new RDF data triple in the given triple store.allOwlEquivalentClass(net.bioclipse.rdf.business.IRDFStore store, String resourceURI) Lists all resources that are owl:equivalentClass as the given resource.allOwlSameAs(net.bioclipse.rdf.business.IRDFStore store, String resourceURI) Lists all resources that are owl:sameAs as the given resource.asRDFN3(net.bioclipse.rdf.business.IRDFStore store) Serializes the triples in the triple store as Notation3.asString(org.apache.jena.shex.ShexReport report) Converts aShexReportinto a String.asTurtle(net.bioclipse.rdf.business.IRDFStore store) Serializes the triples in the triple store as Turtle.net.bioclipse.rdf.business.IRDFStoreCreates a triple store that is fully stored in memory.net.bioclipse.rdf.business.IRDFStorecreateInMemoryStore(boolean ontologyModel) Creates an ontology triple store that is fully stored in memory.net.bioclipse.rdf.business.IRDFStorecreateStore(String tripleStoreDirectoryPath) Creates a triple store that is fully stored on disk.getForPredicate(net.bioclipse.rdf.business.IRDFStore store, String resourceURI, String predicate) Lists all resources or literals for the resource and predicate.net.bioclipse.rdf.business.IRDFStoreimportFile(net.bioclipse.rdf.business.IRDFStore store, String rdfFile, String format) Reads a RDF file in the given format from the workspace and stores the triples in the given triple store.net.bioclipse.rdf.business.IRDFStoreimportFromStream(net.bioclipse.rdf.business.IRDFStore store, InputStream stream, String format) Reads RDF triples from anInputStreamin the given format and stores the triples in the given triple store.net.bioclipse.rdf.business.IRDFStoreimportFromString(net.bioclipse.rdf.business.IRDFStore store, String rdfContent, String format) Reads RDF triples from anStringin the given format and stores the triples in the given triple store.net.bioclipse.rdf.business.IRDFStoreReads RDF triples from a URL and stores the triples in the given triple store.net.bioclipse.rdf.business.IRDFStoreReads RDF triples from a URL and stores the triples in the given triple store, with additional HTTP headers.net.bioclipse.core.domain.IStringMatrixprocessSPARQLXML(byte[] queryResults, String originalQuery) Processes XML returned by a remote SPARQL end point.longsize(net.bioclipse.rdf.business.IRDFStore store) Returns the number of RDF triples in the triple store.net.bioclipse.core.domain.StringMatrixQueries a local RDF triple store.net.bioclipse.core.domain.StringMatrixsparqlRemote(String serviceURL, String sparqlQueryString) Queries a remote SPARQL end point.org.apache.jena.shex.ShexReportvalidateAllOfType(net.bioclipse.rdf.business.IRDFStore store, String shexFile, String shapeURI, String type) Validates triples according to some shape expression in ShEx format.
-
Field Details
-
CONNECT_TIME_OUT
-
READ_TIME_OUT
-
-
Constructor Details
-
RDFManager
Creates a newRDFManager.- Parameters:
workspaceRoot- location of the workspace, e.g. "."
-
-
Method Details
-
createInMemoryStore
public net.bioclipse.rdf.business.IRDFStore createInMemoryStore()Creates a triple store that is fully stored in memory.- Returns:
- a triple store as
IRDFStoreobject
-
createStore
Creates a triple store that is fully stored on disk.- Returns:
- a triple store as
IRDFStoreobject
-
createInMemoryStore
public net.bioclipse.rdf.business.IRDFStore createInMemoryStore(boolean ontologyModel) Creates an ontology triple store that is fully stored in memory.- Returns:
- a triple store as
IRDFStoreobject
-
addPrefix
public void addPrefix(net.bioclipse.rdf.business.IRDFStore store, String prefix, String namespace) throws net.bioclipse.core.business.BioclipseException Adds a prefix definition to the given triple store.- Parameters:
store- anIRDFStoreobjectprefix- the prefixnamespace- the RDF namespace- Throws:
net.bioclipse.core.business.BioclipseException
-
getForPredicate
public List<String> getForPredicate(net.bioclipse.rdf.business.IRDFStore store, String resourceURI, String predicate) throws net.bioclipse.core.business.BioclipseException Lists all resources or literals for the resource and predicate.- Parameters:
store- anIRDFStoreobjectresourceURI- subject of the triplespredicate- predicate of the triples- Returns:
- List of objects (resources and literals).
- Throws:
net.bioclipse.core.business.BioclipseException
-
allOwlSameAs
public List<String> allOwlSameAs(net.bioclipse.rdf.business.IRDFStore store, String resourceURI) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Lists all resources that are owl:sameAs as the given resource.- Parameters:
store- theIRDFStorestore where the identical classes are looked upresourceURI- the resource to find the links for- Returns:
- All matching resources.
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
allOwlEquivalentClass
public List<String> allOwlEquivalentClass(net.bioclipse.rdf.business.IRDFStore store, String resourceURI) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Lists all resources that are owl:equivalentClass as the given resource.- Parameters:
store- theIRDFStorestore where the equivalent classes are looked upresourceURI- the resource to find the links for- Returns:
- All matching resources.
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
addObjectProperty
public void addObjectProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String object) throws net.bioclipse.core.business.BioclipseException Creates a new RDF object triple in the given triple store.- Parameters:
store- theIRDFStorestore where the triple is addedsubject- the RDF Subject of the tripleproperty- the RDF Predicate of the tripleobject- the RDF Object of the triple- Throws:
net.bioclipse.core.business.BioclipseException
-
addDataProperty
public void addDataProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value) throws net.bioclipse.core.business.BioclipseException Creates a new RDF data triple in the given triple store.- Parameters:
store- theIRDFStorestore where the triple is addedsubject- the RDF Subject of the tripleproperty- the RDF Predicate of the triplevalue- the RDF Literal string- Throws:
net.bioclipse.core.business.BioclipseException
-
addTypedDataProperty
public void addTypedDataProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value, String dataType) throws net.bioclipse.core.business.BioclipseException Creates a new RDF data triple in the given triple store.- Parameters:
store- theIRDFStorestore where the triple is addedsubject- the RDF Subject of the tripleproperty- the RDF Predicate of the triplevalue- the RDF Literal stringdataType- the data type of the RDF Literal- Throws:
net.bioclipse.core.business.BioclipseException
-
addPropertyInLanguage
public void addPropertyInLanguage(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value, String language) throws net.bioclipse.core.business.BioclipseException Creates a new RDF data triple in the given triple store.- Parameters:
store- theIRDFStorestore where the triple is addedsubject- the RDF Subject of the tripleproperty- the RDF Predicate of the triplevalue- the RDF Literal stringlanguage- the language of the RDF Literal- Throws:
net.bioclipse.core.business.BioclipseException
-
sparqlRemote
public net.bioclipse.core.domain.StringMatrix sparqlRemote(String serviceURL, String sparqlQueryString) Queries a remote SPARQL end point.- Parameters:
serviceURL- the URL of the SPARQL end pointsparqlQueryString- the SPARQL query- Returns:
- an
StringMatrixobject with results
-
processSPARQLXML
public net.bioclipse.core.domain.IStringMatrix processSPARQLXML(byte[] queryResults, String originalQuery) throws net.bioclipse.core.business.BioclipseException Processes XML returned by a remote SPARQL end point.- Parameters:
queryResults- the search results as a byte array of the returned XMLoriginalQuery- the original SPARQL query that gave the results- Returns:
- a matrix with SPARQL results
- Throws:
net.bioclipse.core.business.BioclipseException
-
sparql
public net.bioclipse.core.domain.StringMatrix sparql(net.bioclipse.rdf.business.IRDFStore store, String queryString) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Queries a local RDF triple store.- Parameters:
store- the RDF triples store to queryqueryString- the SPARQL query- Returns:
- an
StringMatrixobject with results - Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
size
public long size(net.bioclipse.rdf.business.IRDFStore store) throws net.bioclipse.core.business.BioclipseException Returns the number of RDF triples in the triple store.- Parameters:
store- anIRDFStoreobject- Returns:
- the number of triples
- Throws:
net.bioclipse.core.business.BioclipseException
-
importFile
public net.bioclipse.rdf.business.IRDFStore importFile(net.bioclipse.rdf.business.IRDFStore store, String rdfFile, String format) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Reads a RDF file in the given format from the workspace and stores the triples in the given triple store.- Parameters:
store-IRDFStoreto put the triples inrdfFile- location of the RDF fileformat- format of the RDF file (e.g. "RDF/XML", "TURTLE", or "N3")- Returns:
- an RDF store with the content of the loaded RDF file
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
importFromStream
public net.bioclipse.rdf.business.IRDFStore importFromStream(net.bioclipse.rdf.business.IRDFStore store, InputStream stream, String format) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Reads RDF triples from anInputStreamin the given format and stores the triples in the given triple store.- Parameters:
store-IRDFStoreto put the triples instream- theInputStreamfrom which the triples are readformat- format of the RDF file (e.g. "RDF/XML", "TURTLE", or "N3")- Returns:
- an RDF store with the content of the loaded RDF content
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
importFromString
public net.bioclipse.rdf.business.IRDFStore importFromString(net.bioclipse.rdf.business.IRDFStore store, String rdfContent, String format) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Reads RDF triples from anStringin the given format and stores the triples in the given triple store.- Parameters:
store-IRDFStoreto put the triples inrdfContent- theStringfrom which the triples are readformat- format of the RDF file (e.g. "RDF/XML", "TURTLE", or "N3")- Returns:
- an RDF store with the content of the loaded RDF content
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
importURL
public net.bioclipse.rdf.business.IRDFStore importURL(net.bioclipse.rdf.business.IRDFStore store, String url) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreException Reads RDF triples from a URL and stores the triples in the given triple store.- Parameters:
store-IRDFStoreto put the triples inurl- the URL from which the triples are read- Returns:
- an RDF store with the content of the loaded RDF file
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
importURL
public net.bioclipse.rdf.business.IRDFStore importURL(net.bioclipse.rdf.business.IRDFStore store, String url, Map<String, String> extraHeaders) throws IOException, net.bioclipse.core.business.BioclipseException, org.eclipse.core.runtime.CoreExceptionReads RDF triples from a URL and stores the triples in the given triple store, with additional HTTP headers.- Parameters:
store-IRDFStoreto put the triples inurl- the URL from which the triples are readextraHeaders- the extra HTTP headers- Returns:
- an RDF store with the content of the loaded RDF file
- Throws:
IOExceptionnet.bioclipse.core.business.BioclipseExceptionorg.eclipse.core.runtime.CoreException
-
asRDFN3
public String asRDFN3(net.bioclipse.rdf.business.IRDFStore store) throws net.bioclipse.core.business.BioclipseException Serializes the triples in the triple store as Notation3.- Parameters:
store- theIRDFStore- Returns:
- a
Stringwith Notation3-formatted triples - Throws:
net.bioclipse.core.business.BioclipseException
-
asTurtle
public String asTurtle(net.bioclipse.rdf.business.IRDFStore store) throws net.bioclipse.core.business.BioclipseException Serializes the triples in the triple store as Turtle.- Parameters:
store- theIRDFStore- Returns:
- a
Stringwith Turtle-formatted triples - Throws:
net.bioclipse.core.business.BioclipseException
-
validateAllOfType
public org.apache.jena.shex.ShexReport validateAllOfType(net.bioclipse.rdf.business.IRDFStore store, String shexFile, String shapeURI, String type) Validates triples according to some shape expression in ShEx format.- Parameters:
store- theIRDFStoreshexFile- the file with shape expressionsshapeURI- URI of the shape to test againsttype- URI of the rdf:type of the resources to test- Returns:
- the ShEx validation report as
ShexReport
-
asString
Converts aShexReportinto a String.- Parameters:
report- theShexReport- Returns:
- String serialization of the report
-