Sha256: 9b0bb3872a26d59924ed55f7ff9d95b46df4b45975b04dfb2d67a7d32c297e99
Contents?: true
Size: 1.33 KB
Versions: 6
Compression:
Stored size: 1.33 KB
Contents
module PublishMyData class Resource include Tripod::Resource include BasicFeatures field :rdf_type, RDF.type, :multivalued => true, :is_uri => true cattr_accessor :LOCAL_RESOURCES, :THIRD_PARTY_RESOURCES, :RESOURCES @@LOCAL_RESOURCES = [ConceptScheme, Ontology] @@THIRD_PARTY_RESOURCES = [ThirdParty::Ontology, ThirdParty::ConceptScheme] @@RESOURCES = [Dataset, Concept, OntologyClass, Property, RdfType] class << self def uri_from_host_and_doc_path(host, doc_path, format="") 'http://' + host + '/id/' + doc_path.split('?')[0].sub(/\.#{format}$/,'') end alias_method :find_by_uri, :find 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 end def theme dataset.theme_obj if dataset end def dataset Dataset.find(Dataset.uri_from_data_graph_uri(self.graph_uri)) rescue nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems