Class: PublishMyData::Resource
- Inherits:
-
Object
- Object
- PublishMyData::Resource
show all
- Includes:
- BasicFeatures, Tripod::Resource
- Defined in:
- app/models/publish_my_data/resource.rb
Constant Summary
collapse
- @@LOCAL_RESOURCES =
[ConceptScheme, Ontology]
- @@THIRD_PARTY_RESOURCES =
[ThirdParty::Ontology, ThirdParty::ConceptScheme]
- @@RESOURCES =
[Dataset, Concept, OntologyClass, Property, RdfType]
Class Method Summary
collapse
Instance Method Summary
collapse
#eager_load!, #in_domain?
Class Method Details
.find(uri, opts = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# 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)
resource_klasses = opts.fetch(:local, false) ? self.LOCAL_RESOURCES : self.THIRD_PARTY_RESOURCES
resource_klasses.each do |klass|
return klass.find(uri) if type.include?(klass.get_rdf_type)
end
self.RESOURCES.each do |klass|
return klass.find(uri, :ignore_graph => true) if type.include?(klass.get_rdf_type)
end
return resource
end
|
.find_by_uri ⇒ Object
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
#dataset ⇒ Object
39
40
41
|
# File 'app/models/publish_my_data/resource.rb', line 39
def dataset
Dataset.find(Dataset.uri_from_data_graph_uri(self.graph_uri)) rescue nil
end
|
#human_readable_label ⇒ Object
43
44
45
|
# File 'app/models/publish_my_data/resource.rb', line 43
def human_readable_label
label end
|
#human_readable_name ⇒ Object
47
48
49
|
# File 'app/models/publish_my_data/resource.rb', line 47
def human_readable_name
human_readable_label || uri.to_s
end
|
#human_readable_name_is_uri? ⇒ Boolean
51
52
53
|
# File 'app/models/publish_my_data/resource.rb', line 51
def human_readable_name_is_uri?
human_readable_label ? false : true;
end
|
#theme ⇒ Object
35
36
37
|
# File 'app/models/publish_my_data/resource.rb', line 35
def theme
dataset.theme_obj if dataset
end
|