Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bugfix/vov 1419 #45

Merged
merged 2 commits into from

3 participants

@atomical

No description provided.

@cjcolvar

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.

@cjcolvar

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?

@atomical

@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.

@cjcolvar
Owner

I think this is great work identifying where these values were hard-coded. It seems to point toward a need for a more robust controlled vocabulary solution instead of ruby classes but this is a good first step. I would hope that we could change the constant values to "sound recording" and "moving image" to match what is needed for the MODS document and then we wouldn't need to do the mapping.

All that being said and despite my pushing in this direction, I think this changeset might be a little too risky and unnecessary right now. I think it would be great to merge this post-R1. I can work on making a pull request that has just what we need for this bug and tests for it.

@atomical

Updated.

@cjcolvar
Owner

+1 This is pretty much what I was thinking. It would be nice to have tests but I guess they can come later. When playing around in rails console I didn't need to do the ensure_root_node_exists! or remove before update_values, but it shouldn't hurt to have them for now. Something that testing should be able to help solve post-R1. Thanks for working through this one atomical!

@atomical

@mbklein Can we merge this?

@mbklein mbklein merged commit f51d9f0 into release/1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @atomical
Commits on Apr 2, 2013
  1. @atomical

    reverting some changes

    atomical authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 9 deletions.
  1. +9 −6 app/models/media_object.rb
  2. +3 −3 app/models/mods_behaviors.rb
View
15 app/models/media_object.rb
@@ -342,19 +342,22 @@ def update_attribute_in_metadata(attribute, value = [], attributes = [])
end
def set_media_types!
- resource_type_names = {
- 'audio' => 'sound recording',
- 'video' => 'moving image'
- }
mime_types = parts.collect { |mf|
mf.file_location.nil? ? nil : Rack::Mime.mime_type(File.extname(mf.file_location))
}.compact.uniq
- resource_types = mime_types.collect { |mime| resource_type_names[mime.split('/').first] }.compact.uniq
+
+ resource_type_to_formatted_text_map = {'Moving image' => 'Moving image', 'Sound' => 'Sound recording'}
+ resource_types = self.parts.collect{|master_file| resource_type_to_formatted_text_map[master_file.file_format] }.uniq
mime_types = nil if mime_types.empty?
resource_types = nil if resource_types.empty?
- descMetadata.ensure_physical_description_exists!
+ descMetadata.ensure_root_term_exists!(:physical_description)
+ descMetadata.ensure_root_term_exists!(:resource_type)
+
+ descMetadata.find_by_terms(:physical_description, :internet_media_type).remove
+ descMetadata.find_by_terms(:resource_type).remove
+
descMetadata.update_values([:physical_description, :internet_media_type] => mime_types, [:resource_type] => resource_types)
end
View
6 app/models/mods_behaviors.rb
@@ -89,9 +89,9 @@ def update_change_date!(t=Time.now.iso8601)
self.record_change_date = t
end
- def ensure_physical_description_exists!
- if find_by_terms(:physical_description).empty?
- ng_xml.root.add_child('<physicalDescription/>')
+ def ensure_root_term_exists!(term)
+ if find_by_terms(term).empty?
+ ng_xml.root.add_child("<#{term.to_s.camelcase(first_letter = :lower)}/>")
end
end
Something went wrong with that request. Please try again.