forked from ontoportal/ontologies_linked_data
-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
efb330f
commit 47fedc8
Showing
1 changed file
with
52 additions
and
50 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 |
---|---|---|
|
@@ -3,28 +3,32 @@ | |
|
||
module LinkedData | ||
extend self | ||
|
||
attr_reader :settings | ||
|
||
@settings = OpenStruct.new | ||
@settings_run = false | ||
|
||
DEFAULT_PREFIX = 'http://data.bioontology.org/'.freeze | ||
|
||
def config(&block) | ||
return if @settings_run | ||
|
||
@settings_run = true | ||
|
||
overide_connect_goo = false | ||
|
||
# Set defaults | ||
@settings.goo_backend_name ||= "4store" | ||
@settings.goo_backend_name ||= '4store' | ||
@settings.goo_port ||= 9000 | ||
@settings.goo_host ||= "localhost" | ||
@settings.goo_path_query ||= "/sparql/" | ||
@settings.goo_path_data ||= "/data/" | ||
@settings.goo_path_update ||= "/update/" | ||
@settings.search_server_url ||= "http://localhost:8983/solr/term_search_core1" | ||
@settings.property_search_server_url ||= "http://localhost:8983/solr/prop_search_core1" | ||
@settings.repository_folder ||= "./test/data/ontology_files/repo" | ||
@settings.rest_url_prefix ||= "http://data.bioontology.org/" | ||
@settings.goo_host ||= 'localhost' | ||
@settings.goo_path_query ||= '/sparql/' | ||
@settings.goo_path_data ||= '/data/' | ||
@settings.goo_path_update ||= '/update/' | ||
@settings.search_server_url ||= 'http://localhost:8983/solr/term_search_core1' | ||
@settings.property_search_server_url ||= 'http://localhost:8983/solr/prop_search_core1' | ||
@settings.repository_folder ||= './test/data/ontology_files/repo' | ||
@settings.rest_url_prefix ||= DEFAULT_PREFIX | ||
@settings.enable_security ||= false | ||
@settings.enable_slices ||= false | ||
|
||
|
@@ -35,47 +39,47 @@ def config(&block) | |
# @settings.redis_port ||= 6379 | ||
# ### | ||
|
||
@settings.ui_host ||= "bioportal.bioontology.org" | ||
@settings.replace_url_prefix ||= false | ||
@settings.id_url_prefix ||= "http://data.bioontology.org/" | ||
@settings.ui_host ||= 'bioportal.bioontology.org' | ||
@settings.replace_url_prefix ||= false | ||
@settings.id_url_prefix ||= DEFAULT_PREFIX | ||
@settings.queries_debug ||= false | ||
@settings.enable_monitoring ||= false | ||
@settings.cube_host ||= "localhost" | ||
@settings.cube_host ||= 'localhost' | ||
@settings.cube_port ||= 1180 | ||
|
||
# Caching http | ||
@settings.enable_http_cache ||= false | ||
@settings.http_redis_host ||= "localhost" | ||
@settings.http_redis_host ||= 'localhost' | ||
@settings.http_redis_port ||= 6379 | ||
|
||
#Caching goo | ||
@settings.goo_redis_host ||= "localhost" | ||
@settings.goo_redis_host ||= 'localhost' | ||
@settings.goo_redis_port ||= 6379 | ||
|
||
#Ontology Analytics Redis | ||
@settings.ontology_analytics_redis_host ||= "localhost" | ||
@settings.ontology_analytics_redis_host ||= 'localhost' | ||
@settings.ontology_analytics_redis_port ||= 6379 | ||
|
||
# PURL server config parameters | ||
@settings.enable_purl ||= false | ||
@settings.purl_host ||= "purl.bioontology.org" | ||
@settings.purl_host ||= 'purl.bioontology.org' | ||
@settings.purl_port ||= 80 | ||
@settings.purl_username ||= "" | ||
@settings.purl_password ||= "" | ||
@settings.purl_maintainers ||= "" | ||
@settings.purl_target_url_prefix ||= "http://bioportal.bioontology.org" | ||
@settings.purl_username ||= '' | ||
@settings.purl_password ||= '' | ||
@settings.purl_maintainers ||= '' | ||
@settings.purl_target_url_prefix ||= 'http://bioportal.bioontology.org' | ||
|
||
# Email settings | ||
@settings.enable_notifications ||= false | ||
@settings.email_sender ||= "[email protected]" # Default sender for emails | ||
@settings.email_override ||= "[email protected]" # By default, all email gets sent here. Disable with email_override_disable. | ||
@settings.enable_notifications ||= false | ||
@settings.email_sender ||= '[email protected]' # Default sender for emails | ||
@settings.email_override ||= '[email protected]' # By default, all email gets sent here. Disable with email_override_disable. | ||
@settings.email_disable_override ||= false | ||
@settings.smtp_host ||= "localhost" | ||
@settings.smtp_host ||= 'localhost' | ||
@settings.smtp_port ||= 25 | ||
@settings.smtp_user ||= "user" | ||
@settings.smtp_password ||= "password" | ||
@settings.smtp_user ||= 'user' | ||
@settings.smtp_password ||= 'password' | ||
@settings.smtp_auth_type ||= :none # :none, :plain, :login, :cram_md5 | ||
@settings.smtp_domain ||= "localhost.localhost" | ||
@settings.smtp_domain ||= 'localhost.localhost' | ||
@settings.enable_starttls_auto ||= false # set to true for use with gmail | ||
|
||
# number of times to retry a query when empty records are returned | ||
|
@@ -89,20 +93,18 @@ def config(&block) | |
|
||
unless @settings.redis_host.nil? | ||
puts "Error: 'redis_host' is not a valid conf parameter." | ||
puts " Redis databases were split into multiple hosts (09/22/13)." | ||
raise Exception, "redis_host is not a valid conf parameter." | ||
puts ' Redis databases were split into multiple hosts (09/22/13).' | ||
raise StandardError, 'redis_host is not a valid conf parameter.' | ||
end | ||
|
||
# Check to make sure url prefix has trailing slash | ||
@settings.rest_url_prefix = @settings.rest_url_prefix + "/" unless @settings.rest_url_prefix[-1].eql?("/") | ||
@settings.rest_url_prefix = "#{@settings.rest_url_prefix}/" unless @settings.rest_url_prefix[-1].eql?('/') | ||
|
||
puts "(LD) >> Using rdf store #{@settings.goo_host}:#{@settings.goo_port}" | ||
puts "(LD) >> Using term search server at #{@settings.search_server_url}" | ||
puts "(LD) >> Using property search server at #{@settings.property_search_server_url}" | ||
puts "(LD) >> Using HTTP Redis instance at "+ | ||
"#{@settings.http_redis_host}:#{@settings.http_redis_port}" | ||
puts "(LD) >> Using Goo Redis instance at "+ | ||
"#{@settings.goo_redis_host}:#{@settings.goo_redis_port}" | ||
puts "(LD) >> Using HTTP Redis instance at #{@settings.http_redis_host}:#{@settings.http_redis_port}" | ||
puts "(LD) >> Using Goo Redis instance at #{@settings.goo_redis_host}:#{@settings.goo_redis_port}" | ||
|
||
connect_goo unless overide_connect_goo | ||
end | ||
|
@@ -132,15 +134,14 @@ def connect_goo | |
port: @settings.goo_redis_port) | ||
|
||
if @settings.enable_monitoring | ||
puts "(LD) >> Enable SPARQL monitoring with cube #{@settings.cube_host}:"+ | ||
"#{@settings.cube_port}" | ||
puts "(LD) >> Enable SPARQL monitoring with cube #{@settings.cube_host}:#{@settings.cube_port}" | ||
conf.enable_cube do |opts| | ||
opts[:host] = @settings.cube_host | ||
opts[:port] = @settings.cube_port | ||
end | ||
end | ||
end | ||
rescue Exception => e | ||
rescue StandardError => e | ||
abort("EXITING: Cannot connect to triplestore and/or search server:\n #{e}\n#{e.backtrace.join("\n")}") | ||
end | ||
end | ||
|
@@ -150,26 +151,27 @@ def connect_goo | |
# We do this at initial runtime because goo needs namespaces for its DSL | ||
def goo_namespaces | ||
Goo.configure do |conf| | ||
conf.add_namespace(:omv, RDF::Vocabulary.new("http://omv.ontoware.org/2005/05/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(:omv, RDF::Vocabulary.new('http://omv.ontoware.org/2005/05/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(:rdfs, RDF::Vocabulary.new('http://www.w3.org/2000/01/rdf-schema#')) | ||
conf.add_namespace(:metadata, | ||
RDF::Vocabulary.new("http://data.bioontology.org/metadata/"), | ||
RDF::Vocabulary.new('http://data.bioontology.org/metadata/'), | ||
default = true) | ||
conf.add_namespace(:metadata_def, | ||
RDF::Vocabulary.new("http://data.bioontology.org/metadata/def/")) | ||
conf.add_namespace(:dc, RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/")) | ||
conf.add_namespace(:xsd, RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#")) | ||
RDF::Vocabulary.new('http://data.bioontology.org/metadata/def/')) | ||
conf.add_namespace(:dc, RDF::Vocabulary.new('http://purl.org/dc/elements/1.1/')) | ||
conf.add_namespace(:xsd, RDF::Vocabulary.new('http://www.w3.org/2001/XMLSchema#')) | ||
conf.add_namespace(:oboinowl_gen, | ||
RDF::Vocabulary.new("http://www.geneontology.org/formats/oboInOwl#")) | ||
conf.add_namespace(:obo_purl, RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")) | ||
RDF::Vocabulary.new('http://www.geneontology.org/formats/oboInOwl#')) | ||
conf.add_namespace(:obo_purl, RDF::Vocabulary.new('http://purl.obolibrary.org/obo/')) | ||
conf.add_namespace(:umls, | ||
RDF::Vocabulary.new("http://bioportal.bioontology.org/ontologies/umls/")) | ||
conf.id_prefix = "http://data.bioontology.org/" | ||
RDF::Vocabulary.new('http://bioportal.bioontology.org/ontologies/umls/')) | ||
conf.id_prefix = DEFAULT_PREFIX | ||
conf.pluralize_models(true) | ||
end | ||
end | ||
self.goo_namespaces | ||
goo_namespaces | ||
|
||
end |