talia_core 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 1
4
+ :patch: 2
5
5
  :build:
@@ -12,6 +12,7 @@ module Swicky
12
12
  end
13
13
 
14
14
  def to_json
15
+ puts @triples.inspect
15
16
  @items ||= begin
16
17
  items = []
17
18
  # First a round to make sure that each item has a label
@@ -20,7 +21,8 @@ module Swicky
20
21
  triple_hash.each { |object, values| items += build_item(object, values) }
21
22
  items
22
23
  end
23
- hashy = { 'items' => @items, 'types' => @types_hash, 'properties' => @properties_hash }
24
+ # hashy = { 'items' => @items, 'types' => @types_hash, 'properties' => @properties_hash }
25
+ # puts hashy.inspect
24
26
  { 'items' => @items, 'types' => @types_hash, 'properties' => @properties_hash }.to_json
25
27
  end
26
28
 
@@ -73,6 +75,7 @@ module Swicky
73
75
  additional_items << additional if(additional)
74
76
  label
75
77
  end
78
+ labels.uniq!
76
79
  [(labels.size == 1) ? labels.first : labels, additional_items]
77
80
  end
78
81
 
@@ -94,6 +97,7 @@ module Swicky
94
97
  end
95
98
  # All types will be referred to by their local name
96
99
  types.collect! { |type| make_type_local(type) }
100
+ types.uniq!
97
101
  types
98
102
  end
99
103
 
@@ -112,9 +112,9 @@ module Swicky
112
112
  # TODO: Fix this to better query once available in ActiveRDF
113
113
  additional_triples = []
114
114
  result_triples.each do |trip|
115
- additional_triples += ActiveRDF::Query.new(N::URI).select(:predicate, :object).where(trip[1].to_uri, :predicate, :object).execute.collect { |result| [trip[1].to_uri] + result }
115
+ additional_triples += ActiveRDF::Query.new(N::URI).select(:predicate, :object).distinct.where(trip[1].to_uri, :predicate, :object).execute.collect { |result| [trip[1].to_uri] + result }
116
116
  if(trip.last.respond_to?(:uri))
117
- additional_triples += ActiveRDF::Query.new(N::URI).select(:predicate, :object).where(trip.last, :predicate, :object).execute.collect { |result| [trip.last] + result }
117
+ additional_triples += ActiveRDF::Query.new(N::URI).select(:predicate, :object).distinct.where(trip.last, :predicate, :object).execute.collect { |result| [trip.last] + result }
118
118
  end
119
119
  end
120
120
 
@@ -354,11 +354,11 @@ module TaliaCore
354
354
  onto_dir = File.join(TALIA_ROOT, @config['auto_ontologies'])
355
355
  raise(SystemInitializationError, "Cannot find configured ontology dir #{onto_dir}") unless(File.directory?(onto_dir))
356
356
  adapter = ActiveRDF::ConnectionPool.write_adapter
357
- raise(SystemInitializationError, "Ontology autoloading without a context-aware adapter deletes all RDF data. This is only allowed in testing, please load the ontology manually.") unless(adapter.supports_context? || (@environment == 'testing'))
357
+ raise(SystemInitializationError, "Ontology autoloading without a context-aware adapter deletes all RDF data. This is only allowed in testing, please load the ontology manually.") unless(adapter.contexts || (@environment == 'testing'))
358
358
  raise(SystemInitializationError, "Ontology autoloading requires 'load' capability on the adapter.") unless(adapter.respond_to?(:load))
359
359
 
360
360
  # Clear out the RDF
361
- if(adapter.supports_context?)
361
+ if(adapter.contexts)
362
362
  TaliaCore::RdfImport.clear_file_contexts
363
363
  else
364
364
  adapter.respond_to?(:clear) ? adapter.clear : TaliaUtil::Util::flush_rdf
@@ -369,7 +369,7 @@ module TaliaCore
369
369
  Dir.foreach(onto_dir) do |file|
370
370
  if(file =~ /\.owl$|\.rdf$|\.rdfs$/)
371
371
  file = File.expand_path(File.join(onto_dir, file))
372
- adapter.supports_context? ? TaliaCore::RdfImport.import_file(file, 'rdfxml', :auto) : TaliaCore::RdfImport.import_file(file, 'rdfxml')
372
+ adapter.contexts ? TaliaCore::RdfImport.import_file(file, 'rdfxml', :auto) : TaliaCore::RdfImport.import_file(file, 'rdfxml')
373
373
  loaded_ontos << File.basename(file)
374
374
  end
375
375
  end
@@ -383,7 +383,7 @@ module TaliaCore
383
383
  path_to_core_ext = File.join(TALIA_CODE_ROOT, 'lib', 'core_ext')
384
384
  Dir[path_to_core_ext + '/**/*.rb'].each { |f| require f}
385
385
  end
386
-
386
+
387
387
  # Register the default mime types
388
388
  def register_mime_types
389
389
 
@@ -411,7 +411,7 @@ module TaliaCore
411
411
  Mime::Type.register "application/xml+#{type}", type.gsub(/-/, '_').to_sym, [], [ type ]
412
412
  end
413
413
  end
414
-
414
+
415
415
  end
416
416
  end
417
417
 
@@ -14,7 +14,7 @@ module TaliaCore
14
14
  def import(rdf_syntax, files, context=nil)
15
15
  puts "Importing #{files.size} files into the triple store."
16
16
 
17
- raise(ArgumentError, "Cannot use context, adapter doesn't support it.") if(context && !adapter.supports_context?)
17
+ raise(ArgumentError, "Cannot use context, adapter doesn't support it.") if(context && !adapter.contexts)
18
18
 
19
19
  # check if the connection to te triplestore is ok...otherwise exit the script
20
20
  if !adapter
@@ -26,7 +26,7 @@ module TaliaUtil
26
26
  def setup_ontologies
27
27
  # Clear the ontologies from RDF, if possible
28
28
  adapter = ActiveRDF::ConnectionPool.write_adapter
29
- if(adapter.supports_context?)
29
+ if(adapter.contexts)
30
30
  TaliaCore::RdfImport.clear_file_contexts
31
31
  else
32
32
  puts "WARNING: Cannot remove old ontologies, adapter doesn't support contexts."
@@ -36,7 +36,7 @@ module TaliaUtil
36
36
  files = Dir[File.join(ontology_folder, '*.{rdf*,owl}')]
37
37
  ENV['rdf_syntax'] ||= 'rdfxml'
38
38
  params = [ENV['rdf_syntax'], files]
39
- params << :auto if(adapter.supports_context?)
39
+ params << :auto if(adapter.contexts)
40
40
  TaliaCore::RdfImport::import(*params)
41
41
  RdfUpdate::owl_to_rdfs
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talia_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Giacomi
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-02-11 00:00:00 +01:00
16
+ date: 2010-02-15 00:00:00 +01:00
17
17
  default_executable: talia
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency