Class: RDF::AllegroGraph::Session

Inherits:
AbstractRepository show all
Defined in:
lib/rdf/allegro_graph/session.rb

Overview

A persistent AllegroGraph session. This takes up more server resources than a normal stateless repository connection, but it allows access to advanced AllegroGraph features.

Note that this class does not interoperate well with the Unix fork command if you're using blank nodes. See README.md for details.

See Also:

Instance Method Summary collapse

Methods inherited from AbstractRepository

#build_query, #clear, #each, #has_statement?, #prolog_query, #serialize, #serialize_prolog, #sparql_query, #supports?

Instance Method Details

#close

This method returns an undefined value.

Explicitly close the current session and release all server resources. This function does not commit any outstanding transactions.

See Also:



28
29
30
31
# File 'lib/rdf/allegro_graph/session.rb', line 28

def close
  @repo.request_http(:post, path('session/close'),
                     :expected_status_code => 204)
end

#commit

This method returns an undefined value.

Commit the current changes to the main repository.

See Also:



37
38
39
# File 'lib/rdf/allegro_graph/session.rb', line 37

def commit
  @repo.commit
end

#generator(options) ⇒ Query::PrologLiteral

Define an SNA generator.

Options Hash (options):

  • :object_of (RDF::Resource, Array<RDF::Resource>)

    Follow links defined by specified predicates.

  • :subject_of (RDF::Resource, Array<RDF::Resource>)

    Follow links defined by specified predicates, but from the object to the subject.

  • :undirected (RDF::Resource, Array<RDF::Resource>)

    Follow links defined by specified predicates in both directions.

See Also:



63
64
65
66
67
68
69
70
# File 'lib/rdf/allegro_graph/session.rb', line 63

def generator(options)
  id = unique_id
  generator = SnaGenerator.new(self, options)
  @repo.request_json(:put, path("snaGenerators/#{id}"),
                     :parameters => generator.to_params,
                     :expected_status_code => 204)
  Query::PrologLiteral.new(id.to_sym)
end

#rollback

This method returns an undefined value.

Roll back the changes made since the last commit.

See Also:



45
46
47
# File 'lib/rdf/allegro_graph/session.rb', line 45

def rollback
  @repo.rollback
end