Class: ActiveFedora::RelsExtDatastream
- Inherits:
-
Datastream
- Object
- Fedora::BaseObject
- Fedora::Datastream
- Datastream
- ActiveFedora::RelsExtDatastream
- Includes:
- SemanticNode, SolrMapper
- Defined in:
- lib/active_fedora/rels_ext_datastream.rb
Constant Summary
Constants included from SemanticNode
SemanticNode::PREDICATE_MAPPINGS
Instance Attribute Summary
Attributes included from SemanticNode
Attributes inherited from Datastream
#dirty, #fields, #last_modified
Attributes inherited from Fedora::Datastream
Attributes inherited from Fedora::BaseObject
#attributes, #blob, #errors, #new_object, #uri
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs = nil) ⇒ RelsExtDatastream
constructor
A new instance of RelsExtDatastream.
- #pid=(pid) ⇒ Object
- #save ⇒ Object
- #to_solr(solr_doc = Solr::Document.new) ⇒ Object
Methods included from SolrMapper
Methods included from SemanticNode
#add_relationship, #assert_kind_of, included, #outbound_relationships, #register_predicate, #register_subject, #register_triple, #relationships_from_class, #to_rels_ext
Methods included from MediaShelfClassLevelInheritableAttributes
Methods inherited from Datastream
#after_save, #before_save, #check_concurrency, #content, #content=, #delete, delete, #dirty?, #dsid=, #last_modified_in_repository, #pid, #to_param
Methods inherited from Fedora::Datastream
#control_group, #control_group=, #dsid, #label, #label=, #pid, #uri, #url
Methods inherited from Fedora::BaseObject
Constructor Details
#initialize(attrs = nil) ⇒ RelsExtDatastream
Returns a new instance of RelsExtDatastream.
9 10 11 12 |
# File 'lib/active_fedora/rels_ext_datastream.rb', line 9 def initialize(attrs=nil) super self.dsid = "RELS-EXT" end |
Class Method Details
.from_xml(tmpl, node) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/active_fedora/rels_ext_datastream.rb', line 33 def self.from_xml(tmpl, node) # node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*").each do |f| node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*", {"rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", "foxml"=>"info:fedora/fedora-system:def/foxml#"}).each do |f| r = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>ActiveFedora::SemanticNode::PREDICATE_MAPPINGS.invert[f.name], :object=>f["resource"]) tmpl.add_relationship(r) end tmpl.send(:dirty=, false) tmpl end |
Instance Method Details
#pid=(pid) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/active_fedora/rels_ext_datastream.rb', line 21 def pid=(pid) super self.blob = <<-EOL <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="info:fedora/#{pid}"> </rdf:Description> </rdf:RDF> EOL end |
#save ⇒ Object
14 15 16 17 18 19 |
# File 'lib/active_fedora/rels_ext_datastream.rb', line 14 def save if @dirty == true self.content = to_rels_ext(self.pid) end super end |
#to_solr(solr_doc = Solr::Document.new) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/active_fedora/rels_ext_datastream.rb', line 43 def to_solr(solr_doc = Solr::Document.new) self.relationships.each_pair do |subject, predicates| if subject == :self || subject == "info:fedora/#{self.pid}" predicates.each_pair do |predicate, values| values.each do |val| solr_doc << Solr::Field.new(solr_name(predicate, :symbol) => val) end end end end return solr_doc end |