yowl 0.4.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/CHANGES +15 -0
  2. data/INSTALL-MACOSX.md +107 -0
  3. data/README.md +92 -0
  4. data/Rakefile +76 -0
  5. data/bin/yowl +14 -0
  6. data/examples/introduction.html +5 -0
  7. data/lib/yowl/association.rb +66 -0
  8. data/lib/yowl/class.rb +296 -0
  9. data/lib/yowl/generator.rb +96 -0
  10. data/lib/yowl/import.rb +62 -0
  11. data/lib/yowl/individual.rb +398 -0
  12. data/lib/yowl/individual_association.rb +80 -0
  13. data/lib/yowl/ontology.rb +197 -0
  14. data/lib/yowl/options.rb +116 -0
  15. data/lib/yowl/optionsparser.rb +75 -0
  16. data/lib/yowl/person.rb +26 -0
  17. data/lib/yowl/property.rb +190 -0
  18. data/lib/yowl/repository.rb +100 -0
  19. data/lib/yowl/schema.rb +519 -0
  20. data/lib/yowl/template/css/jquery.ui.all.css +11 -0
  21. data/lib/yowl/template/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  22. data/lib/yowl/template/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  23. data/lib/yowl/template/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  24. data/lib/yowl/template/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  25. data/lib/yowl/template/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  26. data/lib/yowl/template/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  27. data/lib/yowl/template/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  28. data/lib/yowl/template/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  29. data/lib/yowl/template/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  30. data/lib/yowl/template/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  31. data/lib/yowl/template/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  32. data/lib/yowl/template/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  33. data/lib/yowl/template/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  34. data/lib/yowl/template/css/smoothness/jquery-ui-1.8.23.custom.css +563 -0
  35. data/lib/yowl/template/css/yowl.css +414 -0
  36. data/lib/yowl/template/import-diagram.erb +29 -0
  37. data/lib/yowl/template/index.erb +56 -0
  38. data/lib/yowl/template/js/jquery-1.7.2.min.js +4 -0
  39. data/lib/yowl/template/js/jquery-ui-1.8.23.custom.min.js +125 -0
  40. data/lib/yowl/template/js/jquery.ui.accordion.js +611 -0
  41. data/lib/yowl/template/js/yowl.js +72 -0
  42. data/lib/yowl/template/ontology.erb +598 -0
  43. data/lib/yowl/template/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  44. data/lib/yowl/template/themes/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  45. data/lib/yowl/template/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  46. data/lib/yowl/template/themes/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  47. data/lib/yowl/template/themes/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  48. data/lib/yowl/template/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  49. data/lib/yowl/template/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  50. data/lib/yowl/template/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  51. data/lib/yowl/template/themes/base/images/ui-icons_222222_256x240.png +0 -0
  52. data/lib/yowl/template/themes/base/images/ui-icons_2e83ff_256x240.png +0 -0
  53. data/lib/yowl/template/themes/base/images/ui-icons_454545_256x240.png +0 -0
  54. data/lib/yowl/template/themes/base/images/ui-icons_888888_256x240.png +0 -0
  55. data/lib/yowl/template/themes/base/images/ui-icons_cd0a0a_256x240.png +0 -0
  56. data/lib/yowl/template/themes/base/jquery.ui.accordion.css +19 -0
  57. data/lib/yowl/template/themes/base/jquery.ui.all.css +11 -0
  58. data/lib/yowl/template/themes/base/jquery.ui.autocomplete.css +53 -0
  59. data/lib/yowl/template/themes/base/jquery.ui.base.css +11 -0
  60. data/lib/yowl/template/themes/base/jquery.ui.button.css +38 -0
  61. data/lib/yowl/template/themes/base/jquery.ui.core.css +38 -0
  62. data/lib/yowl/template/themes/base/jquery.ui.datepicker.css +66 -0
  63. data/lib/yowl/template/themes/base/jquery.ui.dialog.css +21 -0
  64. data/lib/yowl/template/themes/base/jquery.ui.progressbar.css +11 -0
  65. data/lib/yowl/template/themes/base/jquery.ui.resizable.css +20 -0
  66. data/lib/yowl/template/themes/base/jquery.ui.selectable.css +10 -0
  67. data/lib/yowl/template/themes/base/jquery.ui.slider.css +24 -0
  68. data/lib/yowl/template/themes/base/jquery.ui.tabs.css +18 -0
  69. data/lib/yowl/template/themes/base/jquery.ui.theme.css +247 -0
  70. data/lib/yowl/template/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  71. data/lib/yowl/template/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  72. data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  73. data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  74. data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  75. data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  76. data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  77. data/lib/yowl/template/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  78. data/lib/yowl/template/themes/smoothness/images/ui-icons_222222_256x240.png +0 -0
  79. data/lib/yowl/template/themes/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  80. data/lib/yowl/template/themes/smoothness/images/ui-icons_454545_256x240.png +0 -0
  81. data/lib/yowl/template/themes/smoothness/images/ui-icons_888888_256x240.png +0 -0
  82. data/lib/yowl/template/themes/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  83. data/lib/yowl/template/themes/smoothness/jquery-ui-1.8.23.custom.css +563 -0
  84. data/lib/yowl/template/themes/smoothness/jquery.ui.accordion.css +19 -0
  85. data/lib/yowl/template/themes/smoothness/jquery.ui.all.css +11 -0
  86. data/lib/yowl/template/themes/smoothness/jquery.ui.autocomplete.css +53 -0
  87. data/lib/yowl/template/themes/smoothness/jquery.ui.base.css +11 -0
  88. data/lib/yowl/template/themes/smoothness/jquery.ui.button.css +38 -0
  89. data/lib/yowl/template/themes/smoothness/jquery.ui.core.css +38 -0
  90. data/lib/yowl/template/themes/smoothness/jquery.ui.datepicker.css +66 -0
  91. data/lib/yowl/template/themes/smoothness/jquery.ui.dialog.css +21 -0
  92. data/lib/yowl/template/themes/smoothness/jquery.ui.progressbar.css +11 -0
  93. data/lib/yowl/template/themes/smoothness/jquery.ui.resizable.css +20 -0
  94. data/lib/yowl/template/themes/smoothness/jquery.ui.selectable.css +10 -0
  95. data/lib/yowl/template/themes/smoothness/jquery.ui.slider.css +24 -0
  96. data/lib/yowl/template/themes/smoothness/jquery.ui.tabs.css +18 -0
  97. data/lib/yowl/template/themes/smoothness/jquery.ui.theme.css +249 -0
  98. data/lib/yowl/util.rb +221 -0
  99. data/lib/yowl/version.rb +3 -0
  100. data/lib/yowl.rb +42 -0
  101. data/test/input/base-with-comments.ttl +163 -0
  102. data/test/input/base.ttl +221 -0
  103. data/test/input/empty.ttl +8 -0
  104. data/test/input/example.ttl +73 -0
  105. data/test/test_example_ttl.rb +62 -0
  106. data/test/test_yowl.rb +4 -0
  107. data/test/testcases.md +24 -0
  108. metadata +311 -0
@@ -0,0 +1,519 @@
1
+ require 'rexml/document'
2
+
3
+ module YOWL
4
+
5
+ #
6
+ # Utility class providing access to information about the schema, e.g. its description, lists of classes, etc
7
+ #
8
+ class Schema
9
+
10
+ @@PredefinedNamespaces = Hash.new
11
+ @@PredefinedNamespaces["http://protege.stanford.edu/plugins/owl/dc/protege-dc.owl"] = "http://purl.org/dc/elements/1.1/"
12
+
13
+ @@LastUsedOntologyNumber = 0
14
+
15
+ attr_reader :options
16
+ attr_reader :repository
17
+ attr_reader :model
18
+ attr_reader :base
19
+ attr_reader :fileName
20
+ attr_reader :prefixes
21
+ attr_reader :name
22
+ attr_reader :introduction
23
+ attr_reader :datatype_properties
24
+ attr_reader :object_properties
25
+ attr_reader :classes
26
+ attr_reader :dir
27
+ attr_reader :ontology
28
+
29
+ private
30
+ def initialize(repository_, model_, prefixes_, base_, fileName_)
31
+
32
+ @repository = repository_
33
+ @options = repository_.options
34
+ @model = model_
35
+ @prefixes = prefixes_
36
+ @base = base_
37
+ @fileName = fileName_
38
+
39
+ if options.verbose
40
+ @prefixes.each_pair do |prefix, namespace|
41
+ puts "#{fileName_}: PREFIX #{prefix}: #{namespace}"
42
+ end
43
+ end
44
+
45
+ @classes = Hash.new
46
+
47
+ init_classes(YOWL::Namespaces::OWL.Class)
48
+ init_classes(YOWL::Namespaces::RDFS.Class)
49
+
50
+ @datatype_properties = init_properties(YOWL::Namespaces::OWL.DatatypeProperty)
51
+ @object_properties = init_properties(YOWL::Namespaces::OWL.ObjectProperty)
52
+
53
+ init_ontology()
54
+ init_name()
55
+
56
+ if not @options.quiet
57
+ puts "***********************************"
58
+ puts "* Instantiated Schema"
59
+ puts "* File: #{@fileName}"
60
+ puts "* URI : #{uri}"
61
+ puts "* Base: #{@base}"
62
+ puts "* Name: #{@name}"
63
+ puts "***********************************"
64
+ end
65
+ end
66
+
67
+ public
68
+ def Schema.fromFile(ontology_file_name_, repository_)
69
+
70
+ if repository_.options.verbose
71
+ puts "Read Schema #{ontology_file_name_}"
72
+ end
73
+ prefixes, base = Schema::read_prefixes(ontology_file_name_, repository_.options)
74
+
75
+ format = RDF::Format.for(ontology_file_name_)
76
+ if format.nil?()
77
+ format = RDF::Format.for(:file_extension => "rdf")
78
+ end
79
+ begin
80
+ model = RDF::Graph.load(ontology_file_name_, { :format => format.to_sym, :prefixes => prefixes })
81
+ rescue Addressable::URI::InvalidURIError => e
82
+ warn "ERROR: Invalid URI Error while parsing #{ontology_file_name_}: #{e.to_s}"
83
+ return nil
84
+ rescue Exception => e
85
+ warn "ERROR: #{e.class.to_s} Error while parsing #{ontology_file_name_}: #{e}"
86
+ return nil
87
+ end
88
+
89
+ return Schema.new(repository_, model, prefixes, base, ontology_file_name_)
90
+ end
91
+
92
+ #
93
+ # Read the prefixes from the XML file using REXML
94
+ #
95
+ private
96
+ def Schema.read_prefixes(ontology_file_name_, options_)
97
+ prefixes = {}
98
+ xmldoc = nil
99
+ base = nil
100
+ begin
101
+ xmldoc = REXML::Document.new(IO.read(ontology_file_name_))
102
+ rescue REXML::ParseException => bang
103
+ if not options_.quiet
104
+ warn "WARNING: Could not parse prefixes from #{ontology_file_name_} (only works for RDF/XML format)"
105
+ end
106
+ return prefixes
107
+ end
108
+ if xmldoc.doctype
109
+ xmldoc.doctype.entities.each() do |prefix, entity|
110
+ namespace = entity.normalized()
111
+ if namespace.include?('://')
112
+ prefixes[prefix.to_sym] = Schema.isValidNamespace?(namespace, prefix, ontology_file_name_)
113
+ end
114
+ end
115
+ end
116
+ if xmldoc.root
117
+ xmldoc.root.namespaces.each() do |prefix, namespace|
118
+ #
119
+ # Ignore the default namespace until we know what to do with it
120
+ #
121
+ if prefix != "xmlns"
122
+ #puts "@@@@@@@@@@@@ #{prefix} #{namespace}"
123
+ prefixes[prefix.to_sym] = Schema.isValidNamespace?(namespace, prefix, ontology_file_name_)
124
+ end
125
+ end
126
+ base = xmldoc.root.attribute('base')
127
+ if base
128
+ base = base.to_s
129
+ end
130
+ end
131
+
132
+ return prefixes, base
133
+ end
134
+
135
+ private
136
+ def Schema.isValidNamespace?(ns_, prefix_, fileName_)
137
+ #puts "prefix #{prefix_}: #{ns_}"
138
+ if ns_[-1..-1] != '#' and ns_[-1..-1] != '/'
139
+ raise "ERROR: Namespace for prefix #{prefix_} in @prefixes of #{fileName_} without trailing hash or slash: #{ns_}"
140
+ end
141
+ return ns_
142
+ end
143
+
144
+ public
145
+ def uri
146
+ return @ontology ? @ontology.uri : @base
147
+ #return @ontology.nil? ? @base : @ontology.uri
148
+ end
149
+
150
+ private
151
+ def testIsNamespace?(ns1_, ns2_)
152
+ ns1 = ns1_.chomp('#').chomp('/')
153
+ ns2 = ns2_.chomp('#').chomp('/')
154
+ #puts "testIsNamespace #{ns1} == #{ns2}"
155
+ return ns1 == ns2
156
+ end
157
+
158
+ #
159
+ # Return the prefix and the corresponding namespace for the given namespace,
160
+ # where various forms of the given namespace are tried, like <ns>, <ns>/ and <ns>#.
161
+ # When no namespace could be found, return two nils.
162
+ public
163
+ def prefixForNamespace(namespace_)
164
+ _ns = @@PredefinedNamespaces.include?(namespace_) ? @@PredefinedNamespaces[namespace_] : namespace_
165
+ @prefixes.each() do |prefix, namespace|
166
+ if testIsNamespace?(namespace, _ns)
167
+ return prefix, namespace
168
+ end
169
+ end
170
+ return nil, nil
171
+ end
172
+
173
+ private
174
+ def init_classes(type)
175
+ @model.query(RDF::Query::Pattern.new(nil, RDF.type, type)) do |statement|
176
+ Class.withUri(statement.subject, self)
177
+ end
178
+ end
179
+
180
+ private
181
+ def init_properties(type)
182
+ properties = Hash.new
183
+ @model.query(RDF::Query::Pattern.new(nil, RDF.type, type)) do |statement|
184
+ properties[statement.subject.to_s] = YOWL::Property.new(statement.subject, self)
185
+ end
186
+ return properties
187
+ end
188
+
189
+ public
190
+ def properties()
191
+ return @datatype_properties.merge( @object_properties )
192
+ end
193
+
194
+ public
195
+ def list_properties()
196
+ return properties().sort { |x,y| x[1] <=> y[1] }
197
+ end
198
+
199
+ public
200
+ def list_datatype_properties()
201
+ return datatype_properties().sort { |x,y| x[1] <=> y[1] }
202
+ end
203
+
204
+ public
205
+ def hasClasses?
206
+ return ! @classes.empty?
207
+ end
208
+
209
+ public
210
+ def list_object_properties()
211
+ return object_properties().sort { |x,y| x[1] <=> y[1] }
212
+ end
213
+
214
+ #Return sorted, nested array
215
+ public
216
+ def list_classes()
217
+ sorted = classes().sort { |x,y| x[1] <=> y[1] }
218
+ return sorted
219
+ end
220
+
221
+ public
222
+ #
223
+ # Return the class with the given URI as it is defined in this schema.
224
+ # Do not check the imported ontologies.
225
+ #
226
+ def classInSchemaWithURI(uri_)
227
+ return classes[uri_.to_s]
228
+ end
229
+
230
+ public
231
+ #
232
+ # See YOWL::Individual::classWithURI(uri)
233
+ #
234
+ def classWithURI(uri)
235
+ if @ontology
236
+ return @ontology.classWithURI(uri)
237
+ end
238
+ klass = classInSchemaWithURI(uri)
239
+ if klass
240
+ return klass
241
+ end
242
+ return nil
243
+ end
244
+
245
+ public
246
+ def root_classes()
247
+ allClasses = classes().collect() do |uri,klass|
248
+ klass
249
+ end
250
+ return allClasses.to_set.delete_if() do |klass|
251
+ klass.hasSuperClassesInSchema?
252
+ end
253
+ end
254
+
255
+ private
256
+ def init_ontology()
257
+ ontology = @model.first_subject(RDF::Query::Pattern.new(nil, RDF.type, YOWL::Namespaces::OWL.Ontology))
258
+ if ontology
259
+ @ontology = Ontology.new(ontology, self)
260
+ else
261
+ raise "ERROR: Ontology not found in schema"
262
+ end
263
+ end
264
+
265
+ private
266
+ def init_name()
267
+ @name = nil
268
+ if @ontology
269
+ prefix, ns = prefixForNamespace(@ontology.uri())
270
+ if prefix
271
+ @name = prefix.to_s
272
+ end
273
+ end
274
+ if @name.nil? and @ontology and not @options.noVann
275
+ #
276
+ # Searching for vann:preferredNamespacePrefix to use as the name for the schema
277
+ #
278
+ prefix = @ontology.get_literal(YOWL::Namespaces::VANN.preferredNamespacePrefix)
279
+ if prefix
280
+ @name = prefix.to_s
281
+ if @options.verbose
282
+ puts "Found vann:preferredNamespacePrefix: #{prefix}"
283
+ end
284
+ #
285
+ # Add the found prefix to the collection of prefixes/namespaces
286
+ # (perhaps we should search for vann:preferredNamespaceUri to make it complete)
287
+ #
288
+ ns = @ontology.get_literal(YOWL::Namespaces::VANN.preferredNamespaceUri)
289
+ if ns
290
+ @prefixes[@name.to_sym] = Schema.isValidNamespace?(ns, prefix, @fileName)
291
+ else
292
+ @prefixes[@name.to_sym] = Schema.isValidNamespace?(@ontology.ns, prefix, @fileName)
293
+ end
294
+ else
295
+ warn "WARNING: vann:preferredNamespacePrefix not found in #{@fileName}"
296
+ end
297
+ end
298
+ if @name.nil? and @ontology
299
+ @name = File.basename(@fileName, File.extname(@fileName))
300
+ #@name = @ontology.escaped_short_name()
301
+ end
302
+ #puts "Schema #{@fileName} gets name #{@name} #{uri}"
303
+ if (@name.nil? or @name.empty?())
304
+ raise "ERROR: No name found for the schema"
305
+ end
306
+ if @options.verbose
307
+ puts "Schema has name #{name}"
308
+ end
309
+ end
310
+
311
+ #
312
+ # Replace the namespace in the given uri with the corresponding prefix, if defined
313
+ #
314
+ public
315
+ def prefixedUri(uri)
316
+ if uri.nil?
317
+ raise "ERROR: Passed nil to Schema:prefixedUri()"
318
+ end
319
+ uri = uri.to_s()
320
+ if uri.empty?
321
+ raise "ERROR: Passed empty string to Schema:prefixedUri()"
322
+ end
323
+ uri = uri.gsub(",", "_")
324
+ @prefixes.each() do |prefix, namespace|
325
+ if uri == namespace
326
+ return prefix.to_s
327
+ end
328
+ if "#{uri}/" == namespace
329
+ return prefix.to_s
330
+ end
331
+ if "#{uri}#" == namespace
332
+ return prefix.to_s
333
+ end
334
+ if namespace[-1..-1] != '#' and namespace[-1..-1] != '/'
335
+ @prefixes.each_pair do |prefix, namespace|
336
+ puts "#{@fileName}: PREFIX #{prefix}: #{namespace}"
337
+ end
338
+ raise "ERROR: Namespace in @prefixes of #{@fileName} without trailing hash or slash: #{namespace}"
339
+ end
340
+ if uri.include?(namespace)
341
+ if @ontology and namespace == @ontology.ns
342
+ return uri.gsub(namespace, '')
343
+ end
344
+ return uri.gsub(namespace, "#{prefix.to_s}:")
345
+ end
346
+ end
347
+ =begin
348
+ #
349
+ # First look up in the import hierarchy to see if we can find a prefix definition
350
+ # there that we can use...
351
+ #
352
+ if @ontology
353
+ @ontology.imports.each do |import|
354
+ if import.importedSchema and import.importedSchema != self
355
+ uri = import.importedSchema.prefixedUri(uri)
356
+ if uri
357
+ return uri
358
+ end
359
+ end
360
+ end
361
+ end
362
+ #
363
+ # If all else failed, lets scan all schema's for a usable prefix
364
+ #
365
+ @repository.schemas.values.each do |otherSchema|
366
+ if otherSchema != self
367
+ uri = otherSchema.prefixedUri(uri)
368
+ if uri
369
+ return uri
370
+ end
371
+ end
372
+ end
373
+ =end
374
+ if @ontology
375
+ ontology_uri = @ontology.uri
376
+ if ontology_uri == uri
377
+ return uri
378
+ end
379
+ uri = uri.gsub(ontology_uri + '#', '')
380
+ uri = uri.gsub(ontology_uri + '/', '')
381
+ end
382
+ return uri
383
+ end
384
+
385
+ public
386
+ #
387
+ # Generate the main Class Diagram
388
+ #
389
+ def classDiagramAsSvg
390
+ if @options.verbose
391
+ puts "Generating SVG Class Diagram for #{name}"
392
+ end
393
+
394
+ g = GraphvizUtility.setDefaults(GraphViz.new(:G, :type => :digraph))
395
+ g[:rankdir] = "LR"
396
+ sg = g.subgraph() { |sg|
397
+ sg[:rank => "same"]
398
+ }
399
+
400
+ nodes = Hash.new
401
+ edges = Hash.new
402
+ allClasses = classes.values.to_set
403
+ nonRootClasses = allClasses
404
+ rootClasses = root_classes.to_set
405
+
406
+ #
407
+ # Add the GraphViz nodes for each class, but do the
408
+ # root classes in a subgraph to keep them at top level
409
+ #
410
+ rootClasses.each() do |klass|
411
+ nonRootClasses.delete(klass)
412
+ nodes, edges = klass.addAsGraphvizNode(sg, nodes, edges)
413
+ end
414
+ nonRootClasses.each() do |klass|
415
+ nodes, edges = klass.addAsGraphvizNode(g, nodes, edges)
416
+ end
417
+ #
418
+ # Process edges to super classes, we can ignore the root classes here
419
+ #
420
+ nonRootClasses.each() do |klass|
421
+ if @options.verbose
422
+ puts "- Processing class #{klass.short_name}"
423
+ end
424
+ superClasses = klass.super_classes()
425
+ superClasses.each() do |superClass|
426
+ superClassNode = nodes[superClass.uri]
427
+ if superClassNode
428
+ if @options.verbose
429
+ puts " - Processing super class #{superClass.short_name}"
430
+ end
431
+ Class.newGraphVizEdge(g, nodes[klass.uri], superClassNode)
432
+ else
433
+ if @options.verbose
434
+ puts " - Processing super class #{superClass.short_name}, not found"
435
+ end
436
+ end
437
+ end
438
+ end
439
+ #
440
+ # Process the other associations here
441
+ #
442
+ allClasses.each() do |domainClass|
443
+ domainClassNode = nodes[domainClass.uri]
444
+ if @options.verbose
445
+ puts " - Processing associations of class #{domainClass.short_name}:"
446
+ end
447
+ domainClass.associations().each() do |association|
448
+ if @options.verbose
449
+ puts " - Adding edge #{association.rangeClass.short_name}, #{association.label}"
450
+ end
451
+ nodes, edges = association.addAsGraphVizEdge(g, nodes, edges)
452
+ end
453
+ end
454
+
455
+ return GraphvizUtility.embeddableSvg(g)
456
+ end
457
+
458
+ public
459
+ def skosConceptSchemes
460
+ return individuals.values.find_all do |individual|
461
+ individual.isSkosConceptScheme?
462
+ end
463
+ end
464
+
465
+ public
466
+ def skosConceptsInScheme(conceptScheme)
467
+ return individuals.values.find_all do |individual|
468
+ individual.isSkosConceptInScheme?(conceptScheme)
469
+ end
470
+ end
471
+
472
+ public
473
+ def individualsNotSkosConcepts
474
+ return individuals.values.find_all do |individual|
475
+ not individual.isSkosConceptScheme?
476
+ end
477
+ end
478
+
479
+ public
480
+ def individuals
481
+ if not defined?(@individuals)
482
+ init_individuals
483
+ end
484
+ return @individuals
485
+ end
486
+
487
+ private
488
+ def init_individuals
489
+
490
+ @individuals = Hash.new
491
+
492
+ if @options.verbose
493
+ puts "Searching for Individuals in schema #{@name}"
494
+ end
495
+
496
+ # FILTER (?type != owl:NamedIndividual && regex(str(?resource), "r29-.*"))
497
+ sparql = <<sparql
498
+ SELECT DISTINCT * WHERE {
499
+ ?resource a owl:NamedIndividual .
500
+ ?resource a ?type .
501
+ FILTER (?type != owl:NamedIndividual)
502
+ }
503
+ sparql
504
+ solutions = SPARQL.execute(sparql, @model, { :prefixes => @prefixes })
505
+ if @options.verbose
506
+ puts " - Found #{solutions.count} Individuals"
507
+ end
508
+
509
+ solutions.each do |solution|
510
+ Individual.withUri(solution[:resource], self)
511
+ end
512
+ if @options.verbose
513
+ puts "Initialized All Individuals in #{@name}"
514
+ end
515
+ end
516
+
517
+ end
518
+
519
+ end
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * jQuery UI CSS Framework 1.8.23
3
+ *
4
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Theming
9
+ */
10
+ @import "jquery.ui.base.css";
11
+ @import "jquery.ui.theme.css";