Class: StatementsService

StatementsService(httpRequestExecutor, parserRegistry, parseExecutor)

Service for reading, inserting or deleting repository statements.

Constructor

new StatementsService(httpRequestExecutor, parserRegistry, parseExecutor)

Instantiates the service with the supplied executor and parser utils.

Parameters:
Name Type Description
httpRequestExecutor function

executor for HTTP requests

parserRegistry ParserRegistry

registry of available parsers

parseExecutor function

function that will parse provided data

Author:
  • Mihail Radkov
  • Svilen Velikov
Source:

Methods

add(payload) → {ServiceRequest}

Saves the provided statement payload in the repository.

The payload will be converted to a quad or a collection of quads in case there are multiple contexts.

After the conversion, the produced quad(s) will be serialized to Turtle or Trig format and send to the repository as payload.

See #addQuads().

Parameters:
Name Type Description
payload AddStatementPayload

holding request parameters

Source:
Throws:

if the payload is not provided or the payload has null subject, predicate and/or object

Type
Error
Returns:

service request that will resolve if the addition is successful or reject in case of failure

Type
ServiceRequest

addQuads(quads, contextopt, baseURIopt) → {ServiceRequest}

Serializes the provided quads to Turtle format and sends them to the repository as payload.

If any of the quads have a graph, then the text will be serialized to the Trig format which is an extended version of Turtle supporting contexts.

Parameters:
Name Type Attributes Description
quads Array.<Quad>

collection of quads to be sent as Turtle/Trig text

context string | Array.<string> <optional>

restricts the insertion to the given context. Will be encoded as N-Triple if it is not already one

baseURI string <optional>

used to resolve relative URIs in the data

Source:
Throws:

if no quads are provided or if they cannot be converted

Type
Error
Returns:

service request that will be resolved if the addition is successful or rejected in case of failure

Type
ServiceRequest

deleteAllStatements() → {ServiceRequest}

Deletes all statements in the repository.

Source:
Returns:

service request that will be resolved if the deletion is successful or rejected in case of failure

Type
ServiceRequest

deleteStatements(subjectopt, predicateopt, objectopt, contextsopt) → {ServiceRequest}

Deletes statements in the repository based on the provided subject, predicate, object and or contexts. Each of them is optional and acts as statements filter which effectively narrows the scope of the deletion.

Providing context or contexts will restricts the operation to one or more specific contexts in the repository.

Provided values will be automatically converted to N-Triples if they are not already encoded as such.

Parameters:
Name Type Attributes Description
subject String <optional>

resource subject

predicate String <optional>

resource predicate

object String <optional>

resource object

contexts Array.<String> | String <optional>

resource or resources context

Source:
Returns:

service request that will be resolved if the deletion is successful or rejected in case of failure

Type
ServiceRequest

get(payload) → {ServiceRequest}

Fetch rdf data from statements endpoint using provided parameters.

Provided values will be automatically converted to N-Triples if they are not already encoded as such.

Parameters:
Name Type Description
payload GetStatementsPayload

is an object holding the request parameters.

Source:
Returns:

service request that resolves to plain string or Quad according to provided response type.

Type
ServiceRequest

getServiceName()

Source:

putQuads(quads, contextopt, baseURIopt) → {ServiceRequest}

Overwrites the repository's data by serializing the provided quads to Turtle format and sending them to the repository as payload.

If any of the quads have a graph, then the text will be serialized to the Trig format which is an extended version of Turtle supporting contexts.

The overwrite will be restricted if the context parameter is specified.

Parameters:
Name Type Attributes Description
quads Array.<Quad>

collection of quads to be sent as Turtle/Trig text

context string | Array.<string> <optional>

restricts the insertion to the given context. Will be encoded as N-Triple if it is not already one

baseURI string <optional>

used to resolve relative URIs in the data

Source:
Throws:

if no quads are provided or if they cannot be converted

Type
Error
Returns:

service request that will be resolved if the overwrite is successful or rejected in case of failure

Type
ServiceRequest