Skip to content
Ryan Wick edited this page Jul 18, 2017 · 3 revisions

Re-Fetch

i = Image.find("oregondigital:3f462578h")
p = i.institution.first
p.fetch
p.rdf_label # => [whatyouwant]
p.persist!
i.save

.fetch may not work if there is still a value in .rdf_label, so it needs to be cleared:

irb(main):082:0> ro.rdf_label
=> ["Registrar's Office Records, 1900-2009 (RG 053 - SG 1)"]
irb(main):083:0> ro.hiddenLabel
=> ["Registrar's Office Records, 1900-2009 (RG 053 - SG 1)"]
irb(main):084:0> ro.rdf_label.clear
=> nil
irb(main):085:0> ro.rdf_label
=> ["Registrar's Office Records, 1900-2009 (RG 053 - SG 1)"]
irb(main):086:0> ro.rdf_label.clear
=> nil
irb(main):087:0> ro.rdf_label
=> ["http://opaquenamespace.org/ns/localCollectionName/rg_053_-_sg_1"]
irb(main):088:0> ro.fetch
=> #<OregonDigital::ControlledVocabularies::LocalCollection:0x3fa826a2b120(default)>
irb(main):089:0> ro.rdf_label
=> ["Registrar's Office Records, 1870-2015 (RG 053 - SG 1)"]
irb(main):090:0> ro.persist!
=> true

You'll have to reindex any existing items, see below.

Assert Own Label

i = Image.find("oregondigital:3f462578h")
p = i.institution.first
p << [p.rdf_subject, RDF::SKOS.hiddenLabel, RDF::Literal.new("Oregon State University", :language => :en)]
p.persist!

Reindex Items for New Facet Labels

results = ActiveFedora::SolrService.query("desc_metadata__localCollectionName_label_sim:#{RSolr.escape("Oregon Multicultural Archives Oral History Collection, 2011-2014 (OH 18)$http://opaquenamespace.org/ns/localCollectionName/oh_18")}", :fl => "id", :rows => 100000)
results.count

results.map{|x| x["id"]}.each do |pid|
item = Image.find(:pid => pid).first || Document.find(:pid => pid).first || Audio.find(:pid => pid).first || GenericAsset.find(:pid => pid).first
puts pid

item.update_index unless item.nil?
end