Module: Bplmodels::Characterization

Extended by:
ActiveSupport::Concern
Included in:
File
Defined in:
app/models/bplmodels/characterization.rb

Instance Method Summary collapse

Instance Method Details

#append_metadataObject

Populate descMetadata with fields from FITS (e.g. Author from pdfs)



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/bplmodels/characterization.rb', line 57

def 
  terms = self.characterization_terms
  #Sufia.config.fits_to_desc_mapping.each_pair do |k, v|
  fits_config_values.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_termsObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/models/bplmodels/characterization.rb', line 77

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

#characterizeObject

Extract the metadata from the content datastream and record it in the characterization datastream



49
50
51
52
53
54
# File 'app/models/bplmodels/characterization.rb', line 49

def characterize
  self.characterization.ng_xml = self.productionMaster.
  self.
  self.filename = self.label
  save
end

#durationObject



40
41
42
# File 'app/models/bplmodels/characterization.rb', line 40

def duration
  characterization.duration.blank? ? characterization.video_duration : characterization.duration
end

#fits_config_valuesObject



26
27
28
29
30
# File 'app/models/bplmodels/characterization.rb', line 26

def fits_config_values
  #This is to add that to the end metadata record from FITS...
  #return {:file_title => :title, :file_author => :creator }
  return {}
end

#heightObject



36
37
38
# File 'app/models/bplmodels/characterization.rb', line 36

def height
  characterization.height.blank? ? characterization.video_height : characterization.height
end

#sample_rateObject



44
45
46
# File 'app/models/bplmodels/characterization.rb', line 44

def sample_rate
  characterization.sample_rate.blank? ? characterization.video_sample_rate : characterization.sample_rate
end

#widthObject



32
33
34
# File 'app/models/bplmodels/characterization.rb', line 32

def width
  characterization.width.blank? ? characterization.video_width : characterization.width
end