lib/cul-fedora/item.rb in cul-fedora-0.8.3 vs lib/cul-fedora/item.rb in cul-fedora-0.8.4
- old
+ new
@@ -115,12 +115,13 @@
search_to_content = lambda { |x| x.kind_of?(Nokogiri::XML::Element) ? x.content : x.to_s }
add_field = lambda { |name, value| results[name] << search_to_content.call(value) }
get_fullname = lambda { |node| node.nil? ? nil : (node.css("namePart[@type='family']").collect(&:content) | node.css("namePart[@type='given']").collect(&:content)).join(", ") }
- roles = ["Author","Creator","Thesis Advisor","Collector","Owner","Speaker","Seminar Chairman","Secretary","Rapporteur","Committee Member","Degree Grantor","Moderator","Editor","Interviewee","Interviewer","Organizer of Meeting","Originator","Teacher"]
- roles = roles.map { |role| role.downcase }
+ author_roles = ["author","creator","editor","speaker","moderator","interviewee","interviewer","contributor"]
+ other_name_roles = ["thesis advisor"]
+ corporate_author_roles = ["author"]
organizations = []
departments = []
begin
@@ -152,33 +153,45 @@
add_field.call("record_creation_date", record_creation_date.strftime("%Y-%m-%dT%H:%M:%SZ"))
end
add_field.call("title_display", title)
add_field.call("title_search", title_search)
- all_names = []
+ all_author_names = []
mods.css("name[@type='personal']").each do |name_node|
- if name_node.css("role>roleTerm").collect(&:content).any? { |role| roles.include?(role) }
+
+ fullname = get_fullname.call(name_node)
+ note_org = false
+
+ if name_node.css("role>roleTerm").collect(&:content).any? { |role| author_roles.include?(role) }
- fullname = get_fullname.call(name_node)
-
- all_names << fullname
+ note_org = true
+ all_author_names << fullname
if(!name_node["ID"].nil?)
add_field.call("author_id_uni", name_node["ID"])
end
add_field.call("author_search", fullname.downcase)
add_field.call("author_facet", fullname)
-
+
+ elsif name_node.css("role>roleTerm").collect(&:content).any? { |role| other_name_roles.include?(role) }
+
+ note_org = true
+ first_role = name_node.at_css("role>roleTerm").text
+ add_field.call(first_role.gsub(/\s/, '_'), fullname)
+
+ end
+
+ if (note_org == true)
name_node.css("affiliation").each do |affiliation_node|
affiliation_text = affiliation_node.text
if(affiliation_text.include?(". "))
affiliation_split = affiliation_text.split(". ")
organizations.push(affiliation_split[0].strip)
departments.push(affiliation_split[1].strip)
end
end
-
end
+
end
mods.css("name[@type='corporate']").each do |corp_name_node|
if(!corp_name_node["ID"].nil? && corp_name_node["ID"].include?("originator"))
name_part = corp_name_node.at_css("namePart").text
@@ -186,13 +199,24 @@
name_part_split = name_part.split(". ")
organizations.push(name_part_split[0].strip)
departments.push(name_part_split[1].strip)
end
end
+ if corp_name_node.css("role>roleTerm").collect(&:content).any? { |role| corporate_author_roles.include?(role) }
+ display_form = corp_name_node.at_css("displayForm")
+ if(!display_form.nil?)
+ fullname = display_form.text
+ else
+ fullname = corp_name_node.at_css("namePart").text
+ end
+ all_author_names << fullname
+ add_field.call("author_search", fullname.downcase)
+ add_field.call("author_facet", fullname)
+ end
end
- add_field.call("authors_display",all_names.join("; "))
+ add_field.call("authors_display",all_author_names.join("; "))
add_field.call("pub_date", mods.at_css("*[@keyDate='yes']"))
mods.css("genre").each do |genre_node|
add_field.call("genre_facet", genre_node)
add_field.call("genre_search", genre_node)
@@ -231,9 +255,13 @@
add_field.call("book_journal_title", book_journal_title)
add_field.call("book_author", get_fullname.call(related_host.at_css("name")))
add_field.call("issn", related_host.at_css("identifier[@type='issn']"))
+ end
+
+ if(related_series = mods.at_css("relatedItem[@type='series']"))
+ add_field.call("series", related_series.at_css("titleInfo>title"))
end
add_field.call("publisher", mods.at_css("relatedItem>originInfo>publisher"))
add_field.call("publisher_location", mods.at_css("relatedItem > originInfo>place>placeTerm[@type='text']"))
add_field.call("isbn", mods.at_css("relatedItem>identifier[@type='isbn']"))