Browse files

setting the resource type based off master_file file_format

  • Loading branch information...
1 parent 05d66c7 commit c973366eb15ff479198eea5f2cce2bfa3d2b7b78 @atomical atomical committed Mar 28, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 app/models/media_object.rb
@@ -349,11 +349,15 @@ def set_media_types!
mime_types = parts.collect { |mf|
mf.file_location.nil? ? nil : Rack::Mime.mime_type(File.extname(mf.file_location))
- resource_types = mime_types.collect { |mime| resource_type_names[mime.split('/').first] }.compact.uniq
+ master_file_media_type_map = {'Moving image' => 'moving image', 'Sound' => 'sound recording'}

cjcolvar Mar 29, 2013


It seems like we could avoid this mapping if we make MasterFile and MediaObject use the same vocabulary. And do we need to store lowercase in the MODS or can we use uppercase to avoid having to titleize in the to_solr?

+ resource_types ={|master_file| master_file_media_type_map[master_file.file_format] }.uniq
mime_types = nil if mime_types.empty?
resource_types = nil if resource_types.empty?
+ descMetadata.find_by_terms(:physical_description).remove

cjcolvar Mar 29, 2013


Do we really need to remove the terms before setting them? I'm afraid of removing physical_description and only setting [physical_description, internet_media_type]. It seems like we could accidentally remove more than we are setting.

+ descMetadata.find_by_terms(:resource_type).remove
descMetadata.update_values([:physical_description, :internet_media_type] => mime_types, [:resource_type] => resource_types)

1 comment on commit c973366

@cjcolvar I've made some changes and created a pull request based on your comments. Could you comment on the pull request and I'll update the pull request if necessary. In the case of removing terms, it's the only way to update them.

Please sign in to comment.