root/Explorator/trunk/lib/dataload.rb @ 487

Revision 487, 6.5 KB (checked in by mauriciobomfim, 7 years ago)

Added jruby support

Line 
1require "date"
2require "logger"
3#This module loads the adapters.
4#Each adapter has a connection with a repository.
5#See the ActiveRDF documentation for further references.
6#Author: Samur Araujo
7#Date: 25 jun 2008.
8require 'active_rdf' 
9def createdir(dir)
10  Dir.mkdir("db/" + dir) unless File.directory?("db/" + dir)
11end
12#$activerdflog.level = Logger::DEBUG
13#Keep track of all repositories registered in the pool
14
15#dir = File.dirname(File.expand_path(__FILE__))
16dbdir = Dir.pwd +  File::SEPARATOR + 'db'
17
18#ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8087/openrdf-sesame/repositories/TESTE", :results => :sparql_xml
19#ConnectionPool.add_data_source :type => :sesame, :name=>:teste
20#
21
22#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8181/org.semanticdesktop.services.rdfrepository/repositories/main", :results => :sparql_xml, :caching =>true
23#adapter.title='NEPOMUK_SPARQL'
24
25$sesamedir = Dir.new(dbdir + File::SEPARATOR + 'Sesame' + File::SEPARATOR + "repositories")
26$sesamedir.each  do |x| 
27  begin 
28    if x.rindex('.') == nil && x!= ('SYSTEM') && x!= ('INTERNAL')     
29      adapter = ConnectionPool.add_data_source :type => :sparql_sesame_api, :title => x + '(Local)'  ,  :caching =>true, :repository => x, :dir => $sesamedir.path   
30     
31    end
32  rescue => ex
33        begin #try add datasource once again if it fail at the first time.
34          adapter = ConnectionPool.add_data_source :type => :sparql_sesame_api, :title => x + '(Local)'  ,  :caching =>true, :repository => x, :dir => $sesamedir.path
35        rescue
36        end
37  end
38end
39
40#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/PRESIDENT", :results => :sparql_xml, :caching =>true
41#adapter.title='PRESIDENT_PARALLAX_DEFAULT'
42#
43#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/NOKIA", :results => :sparql_xml, :caching =>true
44#adapter.title='NOKIA_DEFAULT'
45#
46#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/MONDIAL", :results => :sparql_xml, :caching =>true
47#adapter.title='MONDIAL_DEFAULT'
48#
49#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/CIA", :results => :sparql_xml, :caching =>true
50#adapter.title='CIA_DEFAULT'
51#
52#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/METAMODEL", :results => :sparql_xml, :caching =>true
53#adapter.title='METAMODEL_SPARQL'
54#
55#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/FACETO", :results => :sparql_xml, :caching =>true
56#adapter.title='FACETO_DEFAULT'
57#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://data.linkedmdb.org/sparql", :results => :sparql_xml, :caching =>true
58#adapter.title='IMDB_SPARQL'
59#
60#begin
61#  adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :virtuoso,:title=>'DBPEDIA(Local)', :url => "http://tecweb08.tecweb.inf.puc-rio.br:8890/sparql", :results => :sparql_xml, :caching =>true
62#rescue Exception => e
63#  puts 'Removing datasource: '
64#  #puts e.backtrace
65#  ConnectionPool.remove_last_data_source_added()
66#  puts 'Datasource removed'
67#end
68#
69#begin
70#  adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :virtuoso,:title=>'MEDICAL(Local)', :url => "http://tecweb08.tecweb.inf.puc-rio.br:8890/sparql?default-graph-uri=http://medical.org", :results => :sparql_xml, :caching =>true
71#rescue Exception => e
72#  puts 'Removing datasource: '
73# # puts e.backtrace 
74#  ConnectionPool.remove_last_data_source_added()
75#  puts 'Datasource removed'
76#end
77
78
79
80#begin
81#  adapter =ConnectionPool.add_data_source :type => :sparql,:title=>'DRUGBANK(Local)', :url => "http://www4.wiwiss.fu-berlin.de/drugbank/sparql", :results => :sparql_xml, :caching =>true 
82#   rescue Exception => e
83# puts e.backtrace
84#end
85
86#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://dbtune.org:2105/sparql/", :results => :sparql_xml
87#adapter.title='BDTune'
88#
89#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://spade.lbl.gov:2020/sparql", :results => :sparql_xml
90#adapter.title='Spade'
91
92
93#You should insert here a line for each namespace that you want to use in your application.
94#The namespace must be unique. If you have doubt please see the ActiveRDF documentation.
95Namespace.register(:dp1, 'http://sw.nokia.com/DP-1/')
96Namespace.register(:fn1, 'http://sw.nokia.com/FN-1/')
97Namespace.register(:mars, 'http://sw.nokia.com/MARS-3/')
98Namespace.register(:voc1, 'http://sw.nokia.com/VOC-1/')
99Namespace.register(:fntype, 'http://sw.nokia.com/FN-1/Type/')
100Namespace.register(:sesame, 'http://www.openrdf.org/schema/sesame#')
101Namespace.register(:dc, 'http://purl.org/dc/elements/1.1/')
102Namespace.register(:dcterms, 'http://purl.org/dc/terms/')
103Namespace.register(:editor, 'http://sw.nokia.com/Editor-1/')
104Namespace.register(:webarch, 'http://sw.nokia.com/WebArch-1/')
105Namespace.register(:faceto, 'http://www.tecweb.inf.puc-rio.br/2008/faceto#')
106Namespace.register(:explorator, 'http://www.explorator.org/2008/explorator#')
107Namespace.register(:foaf, 'http://xmlns.com/foaf/0.1/')
108Namespace.register(:dbpedia, 'http://dbpedia.org/resource/')
109Namespace.register(:imdb, 'http://www.imdb.org/')
110Namespace.register(:wn, 'http://www.w3.org/2006/03/wn/wn20/schema/')
111
112Namespace.register(:explorator, 'http://www.tecweb.inf.puc-rio.br/ontologies/2008/explorator/01/core#')
113
114Namespace.register(:imdb2, 'http://wwwis.win.tue.nl/~ppartout/Blu-IS/Ontologies/IMDB/')
115
116Namespace.register(:oddlinker, "http://data.linkedmdb.org/resource/oddlinker/")
117Namespace.register(:map, "file:/C:/d2r-server-0.4/mapping.n3#")
118Namespace.register(:db, "http://data.linkedmdb.org/resource/")
119Namespace.register(:skos,"http://www.w3.org/2004/02/skos/core#")
120Namespace.register(:moviedmdb,"http://data.linkedmdb.org/resource/movie/")
121Namespace.register(:omdb,"http://triplify.org/vocabulary/omdb#")
122Namespace.register(:movie,"http://triplify.org/vocabulary/movie#")
123Namespace.register(:mondial,"http://www.semwebtech.org/mondial/10/meta#")
124
125
126# construct the necessary Ruby Modules and Classes to use the Namespace
127begin
128  ObjectManager.construct_classes
129rescue Exception => e
130  puts e.backtrace
131end
Note: See TracBrowser for help on using the browser.