lib/bolognese/datacite_utils.rb in bolognese-1.0.29 vs lib/bolognese/datacite_utils.rb in bolognese-1.0.30
- old
+ new
@@ -65,16 +65,18 @@
end
end
def insert_person(xml, person, type)
person_name = person["familyName"].present? ? [person["familyName"], person["givenName"]].compact.join(", ") : person["name"]
- attributes = person["type"].present? ? { "nameType" => person["type"] + "al" } : {}
+ attributes = { "nameType" => person["nameType"] }.compact
xml.send(type + "Name", person_name, attributes)
xml.givenName(person["givenName"]) if person["givenName"].present?
xml.familyName(person["familyName"]) if person["familyName"].present?
- xml.nameIdentifier(person["id"], 'schemeURI' => 'http://orcid.org/', 'nameIdentifierScheme' => 'ORCID') if person["id"].present?
+ Array.wrap(person["nameIdentifiers"]).each do |ni|
+ xml.nameIdentifier(ni["nameIdentifier"], 'nameIdentifierScheme' => ni["nameIdentifierScheme"])
+ end
end
def insert_titles(xml)
xml.titles do
Array.wrap(titles).each do |title|
@@ -90,11 +92,11 @@
end
end
end
def insert_publisher(xml)
- xml.publisher(publisher || periodical && periodical["title"])
+ xml.publisher(publisher || container && container["title"])
end
def insert_publication_year(xml)
xml.publicationYear(publication_year)
end
@@ -105,15 +107,16 @@
xml.resourceType(types["resourceType"] || types["schemaOrg"],
'resourceTypeGeneral' => types["resourceTypeGeneral"] || Metadata::SO_TO_DC_TRANSLATIONS[types["schemaOrg"]] || "Other")
end
def insert_alternate_identifiers(xml)
+ alternate_identifiers = Array.wrap(identifiers).select { |r| r["identifierType"] != "DOI" }
return xml unless alternate_identifiers.present?
xml.alternateIdentifiers do
Array.wrap(alternate_identifiers).each do |alternate_identifier|
- xml.alternateIdentifier(alternate_identifier["alternateIdentifier"], 'alternateIdentifierType' => alternate_identifier["alternateIdentifierType"])
+ xml.alternateIdentifier(alternate_identifier["identifier"], 'alternateIdentifierType' => alternate_identifier["identifierType"])
end
end
end
def insert_dates(xml)
@@ -205,14 +208,19 @@
end
end
end
def insert_descriptions(xml)
- return xml unless descriptions.present? || periodical && periodical["title"].present?
+ return xml unless descriptions.present? || container && container["title"].present?
xml.descriptions do
- if periodical && periodical["title"].present?
- xml.description(periodical["title"], 'descriptionType' => "SeriesInformation")
+ if container && container["title"].present?
+ title = [container["title"]]
+ volume = "#{container["volume"]}" if container["volume"].present?
+ volume += "(#{container["issue"]})" if container["issue"].present?
+ pages = [container["firstPage"], container["lastPage"]].compact.join("-") if container["firstPage"].present?
+ series_information = [title, volume, pages].compact.join(", ")
+ xml.description(series_information, 'descriptionType' => "SeriesInformation")
end
Array.wrap(descriptions).each do |description|
if description.is_a?(Hash)
d = description