Class: PublishMyData::Resource

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

Constant Summary collapse

@@LOCAL_RESOURCES =
[Dataset, ConceptScheme, Ontology]
@@THIRD_PARTY_RESOURCES =
[ThirdParty::Ontology, ThirdParty::ConceptScheme]
@@RESOURCES =
[Concept, OntologyClass, Property, RdfType]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BasicFeatures

#eager_load!, #in_domain?

Class Method Details

.find(uri, opts = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/publish_my_data/resource.rb', line 20

def find(uri, opts={})
  resource = self.find_by_uri(uri)
  type = resource.read_predicate(RDF.type)

  if opts[:local]
    self.LOCAL_RESOURCES.each do |klass|
      return klass.find(uri) if type.include?(klass.get_rdf_type)
    end
  end
  self.THIRD_PARTY_RESOURCES.each do |klass|
    return klass.find(uri, :ignore_graph => true) if type.include?(klass.get_rdf_type)
  end
  self.RESOURCES.each do |klass|
    return klass.find(uri) if type.include?(klass.get_rdf_type)
  end
  return resource
end

.find_by_uriObject



19
# File 'app/models/publish_my_data/resource.rb', line 19

alias_method :find_by_uri, :find

.uri_from_host_and_doc_path(host, doc_path, format = "") ⇒ Object



15
16
17
# File 'app/models/publish_my_data/resource.rb', line 15

def uri_from_host_and_doc_path(host, doc_path, format="")
  'http://' + host + '/id/' + doc_path.split('?')[0].sub(/\.#{format}$/,'')
end

Instance Method Details

#datasetObject



43
44
45
# File 'app/models/publish_my_data/resource.rb', line 43

def dataset
  Dataset.find(Dataset.uri_from_data_graph_uri(self.graph_uri)) rescue nil
end

#themeObject



39
40
41
# File 'app/models/publish_my_data/resource.rb', line 39

def theme
  dataset.theme_obj if dataset
end