Skip to content

Commit

Permalink
Merge pull request #240 from datacite/bug_conflic_saving_jsonld
Browse files Browse the repository at this point in the history
defaults to schema 4version  when the metadata is in schema_org, ris ,bibtex, crosrref, codemeta
  • Loading branch information
kjgarza authored Apr 16, 2019
2 parents c3e5737 + d724330 commit 01ceb5e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ def safe_params
end

meta = xml.present? ? parse_xml(xml, doi: p[:doi]) : {}
p[:schemaVersion] = METADATA_FORMATS.include?(meta["from"]) ? LAST_SCHEMA_VERSION : p[:schemaVersion]
xml = meta["string"]

read_attrs = [p[:creators], p[:contributors], p[:titles], p[:publisher],
Expand Down
11 changes: 11 additions & 0 deletions config/initializers/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ class IdentifierError < RuntimeError; end
"EMEA" => "Europe, Middle East and Africa",
"AMER" => "Americas"
}

LAST_SCHEMA_VERSION = "http://datacite.org/schema/kernel-4"

METADATA_FORMATS = [
"schema_org",
"ris",
"bibtex",
"citeproc",
"crossref",
"codemeta"
]
1 change: 1 addition & 0 deletions spec/concerns/crosscitable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
expect(meta["titles"]).to eq([{"title"=>"Hydrological and meteorological investigations in a lake near Kangerlussuaq, west Greenland"}])
expect(meta["publication_year"]).to eq("2014")
expect(meta["publisher"]).to eq("PANGAEA")
expect(meta["schema_version"]).to eq(nil)
end
end

Expand Down

Large diffs are not rendered by default.

0 comments on commit 01ceb5e

Please sign in to comment.