Skip to content

Commit

Permalink
Merge pull request #1184 from datacite/revert-1182-codycooperross/iss…
Browse files Browse the repository at this point in the history
…ue1179

Revert "Populate `schema_version` based on namespace of `current_metadata`"
  • Loading branch information
codycooperross authored Apr 22, 2024
2 parents 3ea3d23 + 27aa372 commit 86c4526
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
7 changes: 0 additions & 7 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def validate_publisher_obj?(doi)
before_validation :update_identifiers
before_validation :update_types
before_save :set_defaults, :save_metadata
before_save :update_schema_version
before_create { self.created = Time.zone.now.utc.iso8601 }

FIELD_OF_SCIENCE_SCHEME = "Fields of Science and Technology (FOS)"
Expand Down Expand Up @@ -2333,12 +2332,6 @@ def update_types
).compact
end

def update_schema_version
if current_metadata.present? && current_metadata.valid?
self.schema_version = current_metadata.namespace
end
end

def update_publisher
case publisher_before_type_cast
when Hash
Expand Down
28 changes: 4 additions & 24 deletions spec/requests/datacite_dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1996,21 +1996,19 @@
expect(json.dig("data", "attributes", "creators")).to eq([{ "affiliation" => [], "familyName" => "Fenner", "givenName" => "Martin", "nameIdentifiers" => [{ "nameIdentifier" => "https://orcid.org/0000-0003-1419-2405", "nameIdentifierScheme" => "ORCID", "schemeUri" => "https://orcid.org" }], "name" => "Fenner, Martin", "nameType" => "Personal" }])
expect(json.dig("data", "attributes", "publisher")).to eq("DataCite")
expect(json.dig("data", "attributes", "publicationYear")).to eq(2016)
expect(json.dig("data", "attributes", "schemaVersion")).to eq("http://datacite.org/schema/kernel-4")
# expect(json.dig('data', 'attributes', 'schemaVersion')).to eq("http://datacite.org/schema/kernel-4")
expect(json.dig("data", "attributes", "source")).to eq("test")
expect(json.dig("data", "attributes", "types")).to eq("bibtex" => "article", "citeproc" => "article-journal", "resourceType" => "BlogPosting", "resourceTypeGeneral" => "Text", "ris" => "RPRT", "schemaOrg" => "ScholarlyArticle")
expect(json.dig("data", "attributes", "state")).to eq("findable")

doc = Nokogiri::XML(Base64.decode64(json.dig("data", "attributes", "xml")), nil, "UTF-8", &:noblanks)
expect(doc.at_css("identifier").content).to eq("10.14454/10703")

doi = Doi.where(doi: "10.14454/10703").first
expect(doi.publisher).to eq(
expect(Doi.where(doi: "10.14454/10703").first.publisher).to eq(
{
"name" => "DataCite"
}
)
expect(doi.schema_version).to eq("http://datacite.org/schema/kernel-4")
end
end

Expand Down Expand Up @@ -2090,7 +2088,6 @@
expect(json.dig("data", "attributes", "relatedIdentifiers")).to eq([{ "relatedIdentifier" => "10.5438/55e5-t5c0", "relatedIdentifierType" => "DOI", "relationType" => "References" }])
expect(json.dig("data", "attributes", "descriptions", 0, "description")).to start_with("Diet and physical activity")
expect(json.dig("data", "attributes", "geoLocations")).to eq([{ "geoLocationPoint" => { "pointLatitude" => "49.0850736", "pointLongitude" => "-123.3300992" } }])
expect(json.dig("data", "attributes", "schemaVersion")).to eq("http://datacite.org/schema/kernel-4")
expect(json.dig("data", "attributes", "source")).to eq("test")
expect(json.dig("data", "attributes", "types")).to eq("bibtex" => "article", "citeproc" => "article-journal", "resourceType" => "BlogPosting", "resourceTypeGeneral" => "Text", "ris" => "RPRT", "schemaOrg" => "ScholarlyArticle")
expect(json.dig("data", "attributes", "state")).to eq("findable")
Expand All @@ -2103,9 +2100,6 @@
expect(doc.at_css("relatedIdentifiers").content).to eq("10.5438/55e5-t5c0")
expect(doc.at_css("descriptions").content).to start_with("Diet and physical activity")
expect(doc.at_css("geoLocations").content).to eq("49.0850736-123.3300992")

doi = Doi.where(doi: "10.14454/10703").first
expect(doi.schema_version).to eq("http://datacite.org/schema/kernel-4")
end
end

Expand Down Expand Up @@ -2172,7 +2166,7 @@
expect(json.dig("data", "attributes", "creators")).to eq([{ "affiliation" => [], "familyName" => "Fenner", "givenName" => "Martin", "nameIdentifiers" => [{ "nameIdentifier" => "https://orcid.org/0000-0003-1419-2405", "nameIdentifierScheme" => "ORCID", "schemeUri" => "https://orcid.org" }], "name" => "Fenner, Martin", "nameType" => "Personal" }])
expect(json.dig("data", "attributes", "publisher")).to eq("DataCite")
expect(json.dig("data", "attributes", "publicationYear")).to eq(2016)
expect(json.dig("data", "attributes", "schemaVersion")).to eq("http://datacite.org/schema/kernel-4")
# expect(json.dig('data', 'attributes', 'schemaVersion')).to eq("http://datacite.org/schema/kernel-4")
expect(json.dig("data", "attributes", "language")).to eq("en")
expect(json.dig("data", "attributes", "identifiers")).to eq([{ "identifier" => "123", "identifierType" => "Repository ID" }])
expect(json.dig("data", "attributes", "alternateIdentifiers")).to eq([{ "alternateIdentifier" => "123", "alternateIdentifierType" => "Repository ID" }])
Expand Down Expand Up @@ -2220,9 +2214,6 @@
expect(doc.at_css("formats").content).to eq("application/pdftext/csv")
expect(doc.at_css("version").content).to eq("1.1")
expect(doc.at_css("fundingReferences").content).to eq("The Wellcome Trust DBT India Alliancehttps://doi.org/10.13039/501100009053")

doi = Doi.where(doi: "10.14454/10703").first
expect(doi.schema_version).to eq("http://datacite.org/schema/kernel-4")
end
end

Expand Down Expand Up @@ -2714,9 +2705,6 @@
expect(json.dig("data", "attributes", "source")).to eq("test")
expect(json.dig("data", "attributes", "schemaVersion")).to eq("http://datacite.org/schema/kernel-3")
expect(json.dig("data", "attributes", "state")).to eq("findable")

doi = Doi.where(doi: "10.14454/10703").first
expect(doi.schema_version).to eq("http://datacite.org/schema/kernel-3")
end
end

Expand Down Expand Up @@ -3702,6 +3690,7 @@
"type" => "dois",
"attributes" => {
"schemaVersion" => "http://datacite.org/schema/kernel-4",
"regenerate" => true,
},
},
}
Expand All @@ -3717,15 +3706,6 @@
doc = Nokogiri::XML(Base64.decode64(json.dig("data", "attributes", "xml")), nil, "UTF-8", &:noblanks)
expect(doc.collect_namespaces).to eq("xmlns" => "http://datacite.org/schema/kernel-3", "xmlns:dim" => "http://www.dspace.org/xmlns/dspace/dim", "xmlns:dryad" => "http://purl.org/dryad/terms/", "xmlns:dspace" => "http://www.dspace.org/xmlns/dspace/dim", "xmlns:mets" => "http://www.loc.gov/METS/", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance")
end

it "updates a Doi" do
put "/dois/10.14454/10703", update_attributes, headers

expect(json.dig("data", "attributes", "schemaVersion")).to eq("http://datacite.org/schema/kernel-4")

doi = Doi.where(doi: "10.14454/10703").first
expect(doi.schema_version).to eq("http://datacite.org/schema/kernel-4")
end
end

context "mds doi" do
Expand Down

0 comments on commit 86c4526

Please sign in to comment.