Class: PublishMyData::Ontology

Inherits:
Object
  • Object
show all
Includes:
AllFeatures, Tripod::Resource
Defined in:
app/models/publish_my_data/ontology.rb

Direct Known Subclasses

ThirdParty::Ontology

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AllFeatures

#deprecated?, #download_prefix, #resource_type, #slug

Class Method Details

.uri_from_slug(slug) ⇒ Object



9
10
11
# File 'app/models/publish_my_data/ontology.rb', line 9

def self.uri_from_slug(slug)
  "http://#{PublishMyData.local_domain}/def/#{slug}"
end

Instance Method Details

#classesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/publish_my_data/ontology.rb', line 13

def classes
  @classes ||= OntologyClass.find_by_sparql("
    SELECT DISTINCT ?uri ?graph
    WHERE {
      GRAPH ?graph {
        {
          ?uri <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <#{self.uri}> .
          ?uri a <http://www.w3.org/2002/07/owl#Class> .
        }
        UNION
        {
          ?uri <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <#{self.uri}> .
          ?uri a <http://www.w3.org/2000/01/rdf-schema#Class>
        }
      }
    }"
  )
end

#classes_sortedObject



32
33
34
# File 'app/models/publish_my_data/ontology.rb', line 32

def classes_sorted
  Ontology.sort_by_label_or_uri(classes)
end

#eager_load!Object



56
57
58
59
60
# File 'app/models/publish_my_data/ontology.rb', line 56

def eager_load!
  super
  classes.each{|c| c.eager_load!}
  properties.each{|p| p.eager_load!}
end

#local?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/publish_my_data/ontology.rb', line 52

def local?
  true
end

#propertiesObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/publish_my_data/ontology.rb', line 36

def properties
  @properties ||= Property.find_by_sparql("
    SELECT DISTINCT ?uri ?graph
     WHERE {
      GRAPH ?graph {
        ?uri <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <#{self.uri}> .
        ?uri a <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
      }
    }"
  )
end

#properties_sortedObject



48
49
50
# File 'app/models/publish_my_data/ontology.rb', line 48

def properties_sorted
  Ontology.sort_by_label_or_uri(properties)
end