Class: OpenBEL::Routes::Expressions

Inherits:
Base
  • Object
show all
Includes:
BELParser::Parsers
Defined in:
app/openbel/api/routes/expressions.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_CONTENT_TYPE, Base::DEFAULT_CONTENT_TYPE_ID, Base::RESOURCE_SERIALIZERS, Base::SCHEMA_BASE_URL, Base::SPOKEN_CONTENT_TYPES

Constants included from Schemas

Schemas::COMPILED_SCHEMAS, Schemas::SCHEMA_DIR, Schemas::SUFFIX

Constants included from OpenBEL::Resource::Namespaces

OpenBEL::Resource::Namespaces::VOCABULARY_RDF

Constants included from OpenBEL::Resource::Annotations

OpenBEL::Resource::Annotations::VOCABULARY_RDF

Instance Method Summary collapse

Methods included from Schemas

#validate

Constructor Details

#initialize(app) ⇒ Expressions

Returns a new instance of Expressions.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/openbel/api/routes/expressions.rb', line 22

def initialize(app)
  super

  # Obtain configured BEL version.
  bel_version   = OpenBEL::Settings[:bel][:version]
  @spec         = BELParser::Language.specification(bel_version)

  # RdfRepository using Jena.
  tdb = OpenBEL::Settings[:resource_rdf][:jena][:tdb_directory]
  @rr = BEL::RdfRepository.plugins[:jena].create_repository(:tdb_directory => tdb)

  # Annotations using RdfRepository
  @annotations = BEL::Resource::Annotations.new(@rr)
  # Namespaces using RdfRepository
  @namespaces  = BEL::Resource::Namespaces.new(@rr)

  @supported_namespaces = Hash[
    @namespaces.each.map { |ns|
      prefix = ns.prefix.first.upcase

      [
        prefix,
        BELParser::Expression::Model::Namespace.new(
          prefix,
          ns.uri
        )
      ]
    }
  ]

  # Resource Search using SQLite.
  @search = BEL::Resource::Search.plugins[:sqlite].create_search(
    :database_file => OpenBEL::Settings[:resource_search][:sqlite][:database_file]
  )

  @expression_validator = BELParser::Expression::Validator.new(
    @spec,
    @supported_namespaces,
    BELParser::Resource::JenaTDBReader.new(tdb),
    BELParser::Resource.default_url_reader)
end