Class RDFManager

java.lang.Object
net.bioclipse.managers.RDFManager

public class RDFManager extends Object
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
    Modifier and Type
    Field
    Description
    static final Integer
     
    static final Integer
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RDFManager(String workspaceRoot)
    Creates a new RDFManager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDataProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String value)
    Creates a new RDF data triple in the given triple store.
    void
    addObjectProperty(net.bioclipse.rdf.business.IRDFStore store, String subject, String property, String object)
    Creates a new RDF object triple in the given triple store.
    void
    addPrefix(net.bioclipse.rdf.business.IRDFStore store, String prefix, String namespace)
    Adds a prefix definition to the given triple store.
    void
    addPropertyInLanguage(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.
    void
    addTypedDataProperty(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 a ShexReport into a String.
    asTurtle(net.bioclipse.rdf.business.IRDFStore store)
    Serializes the triples in the triple store as Turtle.
    net.bioclipse.rdf.business.IRDFStore
    Creates a triple store that is fully stored in memory.
    net.bioclipse.rdf.business.IRDFStore
    createInMemoryStore(boolean ontologyModel)
    Creates an ontology triple store that is fully stored in memory.
    net.bioclipse.rdf.business.IRDFStore
    createStore(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.IRDFStore
    importFile(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.IRDFStore
    importFromStream(net.bioclipse.rdf.business.IRDFStore store, InputStream stream, String format)
    Reads RDF triples from an InputStream in the given format and stores the triples in the given triple store.
    net.bioclipse.rdf.business.IRDFStore
    importFromString(net.bioclipse.rdf.business.IRDFStore store, String rdfContent, String format)
    Reads RDF triples from an String in the given format and stores the triples in the given triple store.
    net.bioclipse.rdf.business.IRDFStore
    importURL(net.bioclipse.rdf.business.IRDFStore store, String url)
    Reads RDF triples from a URL and stores the triples in the given triple store.
    net.bioclipse.rdf.business.IRDFStore
    importURL(net.bioclipse.rdf.business.IRDFStore store, String url, Map<String,String> extraHeaders)
    Reads RDF triples from a URL and stores the triples in the given triple store, with additional HTTP headers.
    net.bioclipse.core.domain.IStringMatrix
    processSPARQLXML(byte[] queryResults, String originalQuery)
    Processes XML returned by a remote SPARQL end point.
    long
    size(net.bioclipse.rdf.business.IRDFStore store)
    Returns the number of RDF triples in the triple store.
    net.bioclipse.core.domain.StringMatrix
    sparql(net.bioclipse.rdf.business.IRDFStore store, String queryString)
    Queries a local RDF triple store.
    net.bioclipse.core.domain.StringMatrix
    sparqlRemote(String serviceURL, String sparqlQueryString)
    Queries a remote SPARQL end point.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CONNECT_TIME_OUT

      public static final Integer CONNECT_TIME_OUT
    • READ_TIME_OUT

      public static final Integer READ_TIME_OUT
  • Constructor Details

    • RDFManager

      public RDFManager(String workspaceRoot)
      Creates a new RDFManager.
      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 IRDFStore object
    • createStore

      public net.bioclipse.rdf.business.IRDFStore createStore(String tripleStoreDirectoryPath)
      Creates a triple store that is fully stored on disk.
      Returns:
      a triple store as IRDFStore object
    • 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 IRDFStore object
    • 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 - an IRDFStore object
      prefix - the prefix
      namespace - 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 - an IRDFStore object
      resourceURI - subject of the triples
      predicate - 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 - the IRDFStore store where the identical classes are looked up
      resourceURI - the resource to find the links for
      Returns:
      All matching resources.
      Throws:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 - the IRDFStore store where the equivalent classes are looked up
      resourceURI - the resource to find the links for
      Returns:
      All matching resources.
      Throws:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 - the IRDFStore store where the triple is added
      subject - the RDF Subject of the triple
      property - the RDF Predicate of the triple
      object - 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 - the IRDFStore store where the triple is added
      subject - the RDF Subject of the triple
      property - the RDF Predicate of the triple
      value - 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 - the IRDFStore store where the triple is added
      subject - the RDF Subject of the triple
      property - the RDF Predicate of the triple
      value - the RDF Literal string
      dataType - 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 - the IRDFStore store where the triple is added
      subject - the RDF Subject of the triple
      property - the RDF Predicate of the triple
      value - the RDF Literal string
      language - 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 point
      sparqlQueryString - the SPARQL query
      Returns:
      an StringMatrix object 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 XML
      originalQuery - 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 query
      queryString - the SPARQL query
      Returns:
      an StringMatrix object with results
      Throws:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 - an IRDFStore object
      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 - IRDFStore to put the triples in
      rdfFile - location of the RDF file
      format - 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:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 an InputStream in the given format and stores the triples in the given triple store.
      Parameters:
      store - IRDFStore to put the triples in
      stream - the InputStream from which the triples are read
      format - 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:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 an String in the given format and stores the triples in the given triple store.
      Parameters:
      store - IRDFStore to put the triples in
      rdfContent - the String from which the triples are read
      format - 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:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 - IRDFStore to put the triples in
      url - the URL from which the triples are read
      Returns:
      an RDF store with the content of the loaded RDF file
      Throws:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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.CoreException
      Reads RDF triples from a URL and stores the triples in the given triple store, with additional HTTP headers.
      Parameters:
      store - IRDFStore to put the triples in
      url - the URL from which the triples are read
      extraHeaders - the extra HTTP headers
      Returns:
      an RDF store with the content of the loaded RDF file
      Throws:
      IOException
      net.bioclipse.core.business.BioclipseException
      org.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 - the IRDFStore
      Returns:
      a String with 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 - the IRDFStore
      Returns:
      a String with 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 - the IRDFStore
      shexFile - the file with shape expressions
      shapeURI - URI of the shape to test against
      type - URI of the rdf:type of the resources to test
      Returns:
      the ShEx validation report as ShexReport
    • asString

      public String asString(org.apache.jena.shex.ShexReport report)
      Converts a ShexReport into a String.
      Parameters:
      report - the ShexReport
      Returns:
      String serialization of the report