Class Index | File Index

Classes


Class Store.Store


Defined in: store.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Store.Store(callback, params)
Creates a new store.
Field Summary
Field Attributes Field Name and Description
 
rdf
An instance of RDF JS Interface RDFEnvironment associated to this graph instance.
Method Summary
Method Attributes Method Name and Description
 
clear(graph, callback)
Removes all the triples stored in a graph.
 
delete(triples, graphURI, callback)
Removes the triples in a RDF JS Interface API Graph object from the store.
 
execute(query, defaultURIs, namespacesURIs, callback)
Executes a query in the store.
 
executeWithEnvironment(query, URIs, URIs, callback)
A variation of the execute function that expects arguments containing values for the default and named graphs that will be used in the query.
 
Returns the current network transport being used by the the store.
 
graph(graphURI, callback)
Retrieves all the quads belonging to a certain graph in the store as a RDF JS Interface Graph object.
 
insert(triples, graphURI, callback)
Inserts a RDF JS Interface API Graph object into the store.
 
load(mediaType, data, graph, callback)
Load triples into a graph in the store.
 
node(nodeURI, graphURI, callback)
Retrieves all the quads belonging to a certain node in the store as a RDF JS Interface Graph object containing the collection of triples whose subject is the provided node URI.
 
Registers a namespace prefix that will be automatically declared in all the queries.
 
Registers the default namespaces declared in the RDF JS Interfaces specification in the default Profile.
 
registeredGraphs(callback)
Returns the URI of all the graphs currently contained in the store
 
registerParser(mediaType, parser)
Registers a new parser associated to the provided media type.
 
setBatchLoadEvents(mustFireEvents)
Boolean value determining if loading RDF must produce triple add events and fire callbacks.
 
setDefaultPrefix(URIFragment)
Defines the URI that will be used by default by the RDF JS Interface API RDFEnvironment object associated to the store and available through the storeInstance.rdf property.
 
setNetworkTransport(networkTransportImpl)
Sets the network transport used by the store.
 
setPrefix(prefix, URIFragment)
Register a combination of prefix and URI fragment in the default instance of the RDF JS Interface API RDFEnvironment object associated to the store and available through the storeInstance.rdf property.
 
startObservingNode(nodeURI, eventListener, callback)
Associates an event listener function to a node URI.
 
startObservingQuery(query, eventListener, callback)
Associates an event listener function to a SPARQL SELECT or CONSTRUCT query.
 
stopObservingNode(eventListener)
Removes a callback function associated to a node.
 
stopObservingQuery(eventListener)
Removes a callback function associated to a SPARQL query.
 
subscribe(s, p, o, g, event)
Associates an event listener to a pattern expressed as the subject, predicate, object and graph string parameters passed to the function.
 
unsubscribe(callback)
Removes an event listener associated to a certain pattern.
Class Detail
Store.Store(callback, params)
Creates a new store.

It accepts two optional arguments, a map of configuration options for the store and a callback function.
Parameters:
{Function} callback Optional
Callback that will be invoked when the store has been created
{Object} params Optional
  • persistent: should the store use persistence?
  • treeOrder: in versions of the store backed by the native indexing system, the order of the BTree indices
  • name: when using persistence, the name for this store. In the MongoDB backed version, name of the DB used by the store. By default 'rdfstore_js' is used
  • overwrite: clears the persistent storage
  • maxCacheSize: if using persistence, maximum size of the index cache
  • engine: the persistent storage to use, a value mongodb selects the MongoDB engine
  • mongoDomain: when engine=mongodb, server domain name or IP address where the MongoDB server backing the store is running. By default '127.0.0.1' is used
  • mongoPort: when engine=mongodb, port where the MongoDB server is running. By default 27017 is used
  • mongoOptions: when engine=mongodb, additional options for the MongoDB driver. By default {} is used
Field Detail
rdf
An instance of RDF JS Interface RDFEnvironment associated to this graph instance.
Method Detail
clear(graph, callback)
Removes all the triples stored in a graph. The URI of the graph and a callback function can be optinally passed as parameters.

If no graph URI is specified, all triples in the default graph will be removed.
Parameters:
{String} graph Optional
the URI of the graph the triples must be removed from
{Function} callback Optional
a function that will be invoked with a success notification

delete(triples, graphURI, callback)
Removes the triples in a RDF JS Interface API Graph object from the store. The function receives a mandatory Graph object whose triples will be removed. Optionally, a URI string for a graph and a callback function can be passed as arguments.

If no graph URI is specified, triples will be removed from the default graph.

If the callback function is specified, it will be invoked when all the triples had been removed from the store.
Parameters:
{RDFJSInterface.Graph} triples
a RDF JS Interface Graph object
{String} graphURI Optional
URI of the graph where the triples will be removed from. If it is missing, triples will be removed from the default graph
{String} callback Optional
A callback function that will be invoked with a success notification

execute(query, defaultURIs, namespacesURIs, callback)
Executes a query in the store.

There are two possible ways of invoking this function, providing a pair of arrays of namespaces that will be used to compute the union of the default and named dataset, or without them.

Both invocations receive as an optional last parameter a callback function that will receive the return status of the query and the results.

Results can have different formats:
Parameters:
{String} query
{String} defaultURIs Optional
default namespaces
{String} namespacesURIs Optional
named namespaces
{Function} callback Optional

executeWithEnvironment(query, URIs, URIs, callback)
A variation of the execute function that expects arguments containing values for the default and named graphs that will be used in the query.
Parameters:
{String} query
{String} URIs
default namespaces
{String} URIs
named namespaces
{Function} callback Optional

getNetworkTransport()
Returns the current network transport being used by the the store. The default transport uses TCP sockets in the Node.js version and relies on jQuery in the browser version. This can be overriden using the setNetworkTransport function.

graph(graphURI, callback)
Retrieves all the quads belonging to a certain graph in the store as a RDF JS Interface Graph object.

The function accepts as mandatory parameter a callback function that will receive the a success notification and the returned graph.

Optionally, the URI of the graph can also be passed as the first argument. If no graph is specified, the default graph will be returned.
Parameters:
{String} graphURI Optional
If this parameter is missing, the default graph will be returned
{Functon} callback

insert(triples, graphURI, callback)
Inserts a RDF JS Interface API Graph object into the store. The function receives a mandatory Graph object whose triples will be inserted. Optionally, a URI string for a graph and a callback function can be passed as arguments.

If no graph URI is specified, triples will be inserted into the default graph.

If the callback function is specified, it will be invoked when all the triples had been inserted into the store.
Parameters:
{RDFJSInterface.Graph} triples
a RDF JS Interface Graph object
{String} graphURI Optional
URI of the graph where the triples will be inserted. If it is missing, triples will be inserted in the default graph
{String} callback Optional
A callback function that will be invoked with a success notification and the number of triples inserted

load(mediaType, data, graph, callback)
Load triples into a graph in the store. Data can be passed directly to the method or a remote URI speifying where the data is located can be used.

If the data is passed directly to the load function, the media type stating the format of the data must also be passed to the function.

If an URI is passed as a parameter, the store will attempt to perform content negotiation with the remote server and get a representation for the RDF data matching one of the the RDF parsers registered in the store. In this case, the media type parameter must be set to the 'remote' value.

An additional URI for the graph where the parsed data will be loaded and a callback function can be also passed as parameters. If no graph is specified, triples will be loaded in the default graph.

By default loading data will not trigger notification through the events API. If events needs to be trigger, the functio setBatchLoadEvents must be invoked with a true parameter.
Parameters:
{String} mediaType
Media type (application/json, text/n3...) of the data to be parsed or the value 'remote' if a URI for the data is passed instead
{String} data
RDF data to be parsed and loaded or an URI where the data will be retrieved after performing content negotiation
{String} graph Optional
Graph where the parsed triples will be inserted. If it is not specified, triples will be loaded in the default graph
{Function} callback
that will be invoked with a success notification and the number of triples loaded.

node(nodeURI, graphURI, callback)
Retrieves all the quads belonging to a certain node in the store as a RDF JS Interface Graph object containing the collection of triples whose subject is the provided node URI.

The function accepts as mandatory parameters the node URI and a callback unction that will receive a success notification and the returned node.

Optionally, the URI of the graph where the node is contained can also be passed as the first argument.

If no graph is specified, the node will be looked into the default graph.
Parameters:
{String} nodeURI
URI of the node to look for
{String} graphURI Optional
If this parameter is missing, the node will be looked into the default graph
{Functon} callback

registerDefaultNamespace(ns, prefix)
Registers a namespace prefix that will be automatically declared in all the queries.

The prefix will also be inserte in the default RDFEnvironment object associated to the rdf property of the store instance.
Parameters:
{String} ns
the name space to be regsitered
{String} prefix
the URI fragment associated to the name space

registerDefaultProfileNamespaces()
Registers the default namespaces declared in the RDF JS Interfaces specification in the default Profile.

registeredGraphs(callback)
Returns the URI of all the graphs currently contained in the store
Parameters:
{Function} callback
function that will receive a success notification and the array of graph URIs

registerParser(mediaType, parser)
Registers a new parser associated to the provided media type. If there is a parser already registered for that media type, the new parser will replace the old one.

Parsers must implement a function *parse* accepting the data to be parsed as the first parameter and the destination graph URI as the second one. They must return an array of objects with properties: 'subject', 'predicate', 'object' and 'graph' containing lexical representations for these values:

The provided media type will be used to perform content negotiation when dealing with remote resources, or to select the parser in the load function.
Parameters:
{String} mediaType
the media type for this parser
{String} parser
an object containing the *parse* function with the parser logic

setBatchLoadEvents(mustFireEvents)
Boolean value determining if loading RDF must produce triple add events and fire callbacks.
Default value is false.
Parameters:
{boolean} mustFireEvents
true/false value.

setDefaultPrefix(URIFragment)
Defines the URI that will be used by default by the RDF JS Interface API RDFEnvironment object associated to the store and available through the storeInstance.rdf property.
Parameters:
{String} URIFragment
The URI fragment will be used by default

setNetworkTransport(networkTransportImpl)
Sets the network transport used by the store.

Network transport consist of an object implementing the load function, receiving the URI to load, a string with the value of the HTTP 'Accept' header for the store registered parsers, a callback function where the retrieved data and the success notification must be returned.

Different examples with implementations of different transports can be found in the source code of the store:
Parameters:
networkTransportImpl
object implementing the transport *load* function.

setPrefix(prefix, URIFragment)
Register a combination of prefix and URI fragment in the default instance of the RDF JS Interface API RDFEnvironment object associated to the store and available through the storeInstance.rdf property.
Parameters:
{String} prefix
The prefix to be associated
{String} URIFragment
URI fragment the provided prefix will be resolved

startObservingNode(nodeURI, eventListener, callback)
Associates an event listener function to a node URI. Every time the collection of triples whose subject is the specified node URI changes, because an insertion or deletion, the provided callback function will be invoked receiving as a parameter a RDF JS Interface Graph object with the new collection of triples.

The function accepts two mandatory arguments, the URI of the node to observe and the function that will receive the event notifications. An optional third parameter, consisting of a callback function, can be passed and will be invoked once the store had correctly configured the event listener.

LOAD queries, batch loading data into the store, do not trigger events by default. If you wish to be notified by changes triggered by this kind of queries, invoke the *setBatchLoadEvents* function with a true argument.

The event listener function can be removed using the stopObservingNode function.
Parameters:
{String} nodeURI
URI of the node to observe
{Function} eventListener
Function that will be notified with the events
{Function} callback Optional
Function that will be invoked, once the event listener had been correctly set up.

startObservingQuery(query, eventListener, callback)
Associates an event listener function to a SPARQL SELECT or CONSTRUCT query.
Every time an update (insert, delete...) query modified the triples in the store in a way that modifies the output of the query, the event listener will be invoked with an updated result.

LOAD queries, batch loading data into the store, do not trigger events by default. If you wish to be notified by changes triggered by this kind of queries, invoke the setBatchLoadEvents function with a true argument.

The event listener function can be removed invoking the stopObservingQuery function.
Parameters:
{String} query
SELECT or CONSTRUCT SPARQL query
{Function} eventListener
the function that will receive the notifications
{Function} callback Optional
optional function that will be invoked when the stored had set up the event listener function.

stopObservingNode(eventListener)
Removes a callback function associated to a node.
The event listener function object must be passed as an argument.
Parameters:
{Function} eventListener
The event listener function to remove, the same passed as an argument to startObservingNode

stopObservingQuery(eventListener)
Removes a callback function associated to a SPARQL query.
The event listener function object must be passed as an argument.
Parameters:
{Function} eventListener
The event listener function to remove, the same passed as an argument to startObservingQuery

subscribe(s, p, o, g, event)
Associates an event listener to a pattern expressed as the subject, predicate, object and graph string parameters passed to the function. To match any value in that position, a null value can be passed as an argument. e.g. subscribe(null, null, null, g, cb), will be notified with any change in the g graph.
The graph component of the pattern does not support a null value.

Results will be notified as an Array of RDF JS Interface Triple objects.

LOAD queries, batch loading data into the store, do not trigger events by default. If you wish to be notified by changes triggered by this kind of queries, invoke the setBatchLoadEvents function with a true argument.
Parameters:
{String} s
subject or null for any subject
{String} p
predicate or null for any predicate
{String} o
object or null for any object
{String} g
graph or null for any graph
{Function} event
listener function that will be notified when a change occurs

unsubscribe(callback)
Removes an event listener associated to a certain pattern. The function passed as an argument to subscribe must be passed as an argument.
Parameters:
{Function} callback
The event listener to be removed

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Jan 12 2012 19:28:46 GMT-0000 (GMT)