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

Revision 469, 6.3 KB (checked in by samuraraujo, 9 years ago)
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
33  end
34end
35
36#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/PRESIDENT", :results => :sparql_xml, :caching =>true
37#adapter.title='PRESIDENT_PARALLAX_DEFAULT'
38#
39#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/NOKIA", :results => :sparql_xml, :caching =>true
40#adapter.title='NOKIA_DEFAULT'
41#
42#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/MONDIAL", :results => :sparql_xml, :caching =>true
43#adapter.title='MONDIAL_DEFAULT'
44#
45#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/CIA", :results => :sparql_xml, :caching =>true
46#adapter.title='CIA_DEFAULT'
47#
48#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/METAMODEL", :results => :sparql_xml, :caching =>true
49#adapter.title='METAMODEL_SPARQL'
50#
51#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://localhost:8080/openrdf-sesame/repositories/FACETO", :results => :sparql_xml, :caching =>true
52#adapter.title='FACETO_DEFAULT'
53#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://data.linkedmdb.org/sparql", :results => :sparql_xml, :caching =>true
54#adapter.title='IMDB_SPARQL'
55#
56begin
57  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 
58rescue Exception => e
59  puts 'Removing datasource: ' 
60  #puts e.backtrace
61  ConnectionPool.remove_last_data_source_added()
62  puts 'Datasource removed'
63end 
64 
65begin
66  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 
67rescue Exception => e
68  puts 'Removing datasource: ' 
69 # puts e.backtrace 
70  ConnectionPool.remove_last_data_source_added()
71  puts 'Datasource removed'
72end 
73
74
75
76#begin
77#  adapter =ConnectionPool.add_data_source :type => :sparql,:title=>'DRUGBANK(Local)', :url => "http://www4.wiwiss.fu-berlin.de/drugbank/sparql", :results => :sparql_xml, :caching =>true 
78#   rescue Exception => e
79# puts e.backtrace
80#end
81
82#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://dbtune.org:2105/sparql/", :results => :sparql_xml
83#adapter.title='BDTune'
84#
85#adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => "http://spade.lbl.gov:2020/sparql", :results => :sparql_xml
86#adapter.title='Spade'
87
88
89#You should insert here a line for each namespace that you want to use in your application.
90#The namespace must be unique. If you have doubt please see the ActiveRDF documentation.
91Namespace.register(:dp1, 'http://sw.nokia.com/DP-1/')
92Namespace.register(:fn1, 'http://sw.nokia.com/FN-1/')
93Namespace.register(:mars, 'http://sw.nokia.com/MARS-3/')
94Namespace.register(:voc1, 'http://sw.nokia.com/VOC-1/')
95Namespace.register(:fntype, 'http://sw.nokia.com/FN-1/Type/')
96Namespace.register(:sesame, 'http://www.openrdf.org/schema/sesame#')
97Namespace.register(:dc, 'http://purl.org/dc/elements/1.1/')
98Namespace.register(:dcterms, 'http://purl.org/dc/terms/')
99Namespace.register(:editor, 'http://sw.nokia.com/Editor-1/')
100Namespace.register(:webarch, 'http://sw.nokia.com/WebArch-1/')
101Namespace.register(:faceto, 'http://www.tecweb.inf.puc-rio.br/2008/faceto#')
102Namespace.register(:explorator, 'http://www.explorator.org/2008/explorator#')
103Namespace.register(:foaf, 'http://xmlns.com/foaf/0.1/')
104Namespace.register(:dbpedia, 'http://dbpedia.org/resource/')
105Namespace.register(:imdb, 'http://www.imdb.org/')
106Namespace.register(:wn, 'http://www.w3.org/2006/03/wn/wn20/schema/')
107
108Namespace.register(:explorator, 'http://www.tecweb.inf.puc-rio.br/ontologies/2008/explorator/01/core#')
109
110Namespace.register(:imdb2, 'http://wwwis.win.tue.nl/~ppartout/Blu-IS/Ontologies/IMDB/')
111
112Namespace.register(:oddlinker, "http://data.linkedmdb.org/resource/oddlinker/")
113Namespace.register(:map, "file:/C:/d2r-server-0.4/mapping.n3#")
114Namespace.register(:db, "http://data.linkedmdb.org/resource/")
115Namespace.register(:skos,"http://www.w3.org/2004/02/skos/core#")
116Namespace.register(:moviedmdb,"http://data.linkedmdb.org/resource/movie/")
117Namespace.register(:omdb,"http://triplify.org/vocabulary/omdb#")
118Namespace.register(:movie,"http://triplify.org/vocabulary/movie#")
119Namespace.register(:mondial,"http://www.semwebtech.org/mondial/10/meta#")
120
121
122# construct the necessary Ruby Modules and Classes to use the Namespace
123begin
124  ObjectManager.construct_classes
125rescue Exception => e
126  puts e.backtrace
127end
Note: See TracBrowser for help on using the browser.