Module: Sufia::GenericFile::Characterization
- Extended by:
- ActiveSupport::Concern
- Included in:
- Sufia::GenericFile
- Defined in:
- lib/sufia/generic_file/characterization.rb
Instance Method Summary collapse
-
#append_metadata ⇒ Object
Populate descMetadata with fields from FITS (e.g. Author from pdfs).
- #characterization_terms ⇒ Object
-
#characterize ⇒ Object
Extract the metadata from the content datastream and record it in the characterization datastream.
- #characterize_if_changed ⇒ Object
Instance Method Details
#append_metadata ⇒ Object
Populate descMetadata with fields from FITS (e.g. Author from pdfs)
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/sufia/generic_file/characterization.rb', line 44 def terms = self.characterization_terms Sufia::Engine.config.fits_to_desc_mapping.each_pair do |k, v| if terms.has_key?(k) # coerce to array to remove a conditional terms[k] = [terms[k]] unless terms[k].is_a? Array terms[k].each do |term_value| proxy_term = self.send(v) if proxy_term.kind_of?(Array) proxy_term << term_value unless proxy_term.include?(term_value) else # these are single-valued terms which cannot be appended to self.send("#{v}=", term_value) end end end end end |
#characterization_terms ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sufia/generic_file/characterization.rb', line 63 def characterization_terms h = {} self.characterization.class.terminology.terms.each_pair do |k, v| next unless v.respond_to? :proxied_term term = v.proxied_term begin value = self.send(term.name) h[term.name] = value unless value.empty? rescue NoMethodError next end end h end |
#characterize ⇒ Object
Extract the metadata from the content datastream and record it in the characterization datastream
36 37 38 39 40 41 |
# File 'lib/sufia/generic_file/characterization.rb', line 36 def characterize self.characterization.ng_xml = self.content. self. self.filename = self.label save unless self.new_object? end |
#characterize_if_changed ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sufia/generic_file/characterization.rb', line 28 def characterize_if_changed content_changed = self.content.changed? yield #logger.debug "DOING CHARACTERIZE ON #{self.pid}" Sufia.queue.push(CharacterizeJob.new(self.pid)) if content_changed end |