forked from ontoportal/goo
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
170 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,5 @@ doc/ | |
|
||
.idea/* | ||
projectFilesBackup/* | ||
|
||
config/config.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Goo.config do |config| | ||
# 4store | ||
config.goo_backend_name = '4store' | ||
config.goo_port = 8080 | ||
config.goo_host = 'localhost' | ||
config.goo_path_query = '/sparql/' | ||
config.goo_path_data = '/data/' | ||
config.goo_path_update = '/update/' | ||
|
||
# AllegroGraph | ||
# config.goo_backend_name = 'AG' | ||
# config.goo_port = 10035 | ||
# config.goo_host = 'localhost' | ||
# config.goo_path_query = "/repositories/ontoportal" | ||
# config.goo_path_data = "/repositories/ontoportal/statements/" | ||
# config.goo_path_update = "/repositories/ontoportal/statements/" | ||
|
||
config.search_server_url = 'http://localhost:8983/solr/term_search_core1' | ||
config.redis_host = 'localhost' | ||
config.redis_port = 6379 | ||
config.bioportal_namespace = 'http://data.bioontology.org/' | ||
config.queries_debug = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
require 'ostruct' | ||
|
||
module Goo | ||
extend self | ||
attr_reader :settings | ||
|
||
@settings = OpenStruct.new | ||
@settings_run = false | ||
|
||
def config(&block) | ||
return if @settings_run | ||
@settings_run = true | ||
|
||
yield @settings if block_given? | ||
|
||
# Set defaults | ||
@settings.goo_backend_name ||= ENV['GOO_BACKEND_NAME'] || '4store' | ||
@settings.goo_port ||= ENV['GOO_PORT'] || 9000 | ||
@settings.goo_host ||= ENV['GOO_HOST'] || 'localhost"' | ||
@settings.goo_path_query ||= ENV['GOO_PATH_QUERY'] || '/sparql/' | ||
@settings.goo_path_data ||= ENV['GOO_PATH_DATA'] || '/data/' | ||
@settings.goo_path_update ||= ENV['GOO_PATH_UPDATE'] || '/update/' | ||
@settings.search_server_url ||= ENV['SEARCH_SERVER_URL'] || 'http://localhost:8983/solr/term_search_core1' | ||
@settings.redis_host ||= ENV['REDIS_HOST'] || 'localhost' | ||
@settings.redis_port ||= ENV['REDIS_PORT'] || 6379 | ||
@settings.bioportal_namespace ||= ENV['BIOPORTAL_NAMESPACE'] || 'http://data.bioontology.org/' | ||
@settings.queries_debug ||= ENV['QUERIES_DEBUG'] || false | ||
|
||
puts "(GOO) >> Using RDF store #{@settings.goo_host}:#{@settings.goo_port}#{@settings.goo_path_query}" | ||
puts "(GOO) >> Using term search server at #{@settings.search_server_url}" | ||
puts "(GOO) >> Using Redis instance at #{@settings.redis_host}:#{@settings.redis_port}" | ||
|
||
connect_goo | ||
end | ||
|
||
def connect_goo | ||
begin | ||
Goo.configure do |conf| | ||
conf.queries_debug(@settings.queries_debug) | ||
conf.add_sparql_backend(:main, | ||
backend_name: @settings.goo_backend_name, | ||
query: "http://#{@settings.goo_host}:#{@settings.goo_port}#{@settings.goo_path_query}", | ||
data: "http://#{@settings.goo_host}:#{@settings.goo_port}#{@settings.goo_path_data}", | ||
update: "http://#{@settings.goo_host}:#{@settings.goo_port}#{@settings.goo_path_update}", | ||
options: { rules: :NONE }) | ||
conf.add_search_backend(:main, service: @settings.search_server_url) | ||
conf.add_redis_backend(host: @settings.goo_redis_host, port: @settings.goo_redis_port) | ||
|
||
conf.add_namespace(:omv, RDF::Vocabulary.new("http://omv.org/ontology/")) | ||
conf.add_namespace(:skos, RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#")) | ||
conf.add_namespace(:owl, RDF::Vocabulary.new("http://www.w3.org/2002/07/owl#")) | ||
conf.add_namespace(:rdfs, RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#")) | ||
conf.add_namespace(:goo, RDF::Vocabulary.new("http://goo.org/default/"), default = true) | ||
conf.add_namespace(:metadata, RDF::Vocabulary.new("http://goo.org/metadata/")) | ||
conf.add_namespace(:foaf, RDF::Vocabulary.new("http://xmlns.com/foaf/0.1/")) | ||
conf.add_namespace(:rdf, RDF::Vocabulary.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) | ||
conf.add_namespace(:tiger, RDF::Vocabulary.new("http://www.census.gov/tiger/2002/vocab#")) | ||
conf.add_namespace(:nemo, RDF::Vocabulary.new("http://purl.bioontology.org/NEMO/ontology/NEMO_annotation_properties.owl#")) | ||
conf.add_namespace(:bioportal, RDF::Vocabulary.new(@settings.bioportal_namespace)) | ||
conf.use_cache = false | ||
end | ||
rescue Exception => e | ||
abort("EXITING: Goo cannot connect to triplestore and/or search server:\n #{e}\n#{e.backtrace.join("\n")}") | ||
end | ||
end | ||
|
||
def self.test_reset | ||
if @@sparql_backends[:main][:query].url.to_s["localhost"].nil? | ||
raise Exception, "only for testing" | ||
end | ||
@@sparql_backends[:main][:query] = Goo::SPARQL::Client.new("http://#{@settings.goo_host}:#{@settings.goo_port}#{@settings.goo_path_query}", | ||
{protocol: "1.1", "Content-Type" => "application/x-www-form-urlencoded", | ||
read_timeout: 300, | ||
redis_cache: @@redis_client }) | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
require_relative '../test_case' | ||
|
||
GooTest.configure_goo | ||
|
||
module Test | ||
module Models | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
require_relative '../test_case' | ||
require_relative 'bioportal' | ||
|
||
GooTest.configure_goo | ||
|
||
binding.pry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require_relative "../lib/goo.rb" | ||
require_relative "./test_case.rb" | ||
|
||
GooTest.configure_goo | ||
binding.pry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.