Skip to content

Commit

Permalink
Merge pull request #892 from datacite/schema-3-dep
Browse files Browse the repository at this point in the history
Fabrica Schema 3 Deprecation Tasks
  • Loading branch information
svogt0511 authored Jan 8, 2025
2 parents 6b2c5f3 + a955ead commit cf3798d
Show file tree
Hide file tree
Showing 14 changed files with 704 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/components/doi-contributor.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
{{/if}}

<div>
<div data-test-contributor-name>
<label for="name" class="subtitle required-label">Name{{if this.isReadonly ' (from Given Name and Family Name)'}}</label>
<div class="input-group">
<input type="text" class="form-control name-field" value={{this.fragment.name}} placeholder="Name" oninput={{action "updateName" value="target.value"}} readonly={{this.isReadonly}} data-test-name/>
Expand Down
4 changes: 2 additions & 2 deletions app/components/doi-contributors.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="form-group">
<label class="control-label col-md-3" data-test-contributors>Contributors</label>
<div class="form-group data-test-contributors">
<label class="control-label col-md-3">Contributors</label>
<div class="col-md-9">
<div class="label-vertical">The institution or person responsible for collecting, managing, distributing, or otherwise contributing to the development of the resource.</div>
{{#if this.showContributors}}
Expand Down
4 changes: 3 additions & 1 deletion app/components/doi-funding-reference.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div data-test-funding-reference>
<div class="power-select-label">
<label for="funder-name" class="subtitle">Funder Name</label>
</div>
Expand Down Expand Up @@ -71,4 +72,5 @@
The URI leading to a page provided by the funder for more information about the award (grant). For example, <a target="_blank" rel="noopener noreferrer" href="https://www.moore.org/grants/list/GBMF3859.01">https://www.moore.org/grants/list/GBMF3859.01</a>.
</div>

<hr />
<hr />
</div>
4 changes: 2 additions & 2 deletions app/components/doi-funding-references.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="form-group">
<label class="control-label col-md-3" data-test-funding-references>Funding References</label>
<div class="form-group" data-test-funding-references>
<label class="control-label col-md-3">Funding References</label>
<div class="col-md-9 compact-select">
<div class="label-vertical">Information about financial support (funding) for the resource being registered.</div>
{{#if this.showFundingReferences}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/dois/show/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<DoiState @class="required-nested-label" @model={{this.model}} @form={{form}} />

<div class="form-group required-nested-label {{if (v-get this.model 'url' 'isInvalid') 'has-error' 'has-feedback'}}">
<div class="form-group required-nested-label {{if (v-get this.model 'url' 'isInvalid') 'has-error' 'has-feedback'}}" data-test-doi-url>
<label class="control-label col-md-3">URL</label>
<div class="col-md-9 input-fragment">
<div class="label-vertical">The location of the landing page with more information about the resource.</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/dois/show/modify.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<DoiState @class="required-nested-label" @model={{this.model}} @form={{form}} />

<div class="form-group required-nested-label {{if (v-get this.model 'url' 'isInvalid') 'has-error' 'has-feedback'}}">
<div class="form-group required-nested-label {{if (v-get this.model 'url' 'isInvalid') 'has-error' 'has-feedback'}}" data-test-doi-url>
<label class="control-label col-md-3">URL</label>
<div class="col-md-9 input-fragment">
<div class="label-vertical">The location of the landing page with more information about the resource.</div>
Expand All @@ -30,7 +30,7 @@
</div>
</div>

<DoiUpload @model={{this.model}} @form={{form}} />
<DoiUpload @model={{this.model}} @form={{form}} data-test-doi-metadata />

<div class="col-md-9 col-md-offset-3">
{{#if (is-empty (doi-form-errors this.model))}}
Expand Down
146 changes: 146 additions & 0 deletions cypress/e2e/client_admin/doi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,150 @@ describe('ACCEPTANCE: CLIENT_ADMIN | DOIS', () => {
cy.contains('No DOIs found.').should('not.exist')
});
});

it('can update a doi with outdated kernel-3 to the latest kernel-4 (Via form update.)', () => {
// For local dev with different prefix
// let prefix = "10.14454"

cy.getCookie('_jwt').then((cookie) => {

// Create a doi we can work with.
cy.createRegisteredDoi(prefix, Cypress.env('api_url'), cookie.value).then((id) => {
let encDoi = encodeURIComponent(id)
let prefix = id.split('/', 1)[0]
let suffix = id.substr(prefix + '/'.length)

cy.fixture('doi_v3.json').then((doi) => {
doi.data.id = id;
doi.data.attributes.doi = id;
doi.data.attributes.prefix = prefix;
doi.data.attributes.suffix = suffix;

// Intercept the call to GET the DOI info so we can substitute a v3 response which will show in the form.
cy.intercept('GET', '/dois/' + encDoi + '?affiliation=true&publisher=true', doi).as('backendAPI');
cy.visit('/dois/' + encDoi + '/edit');
cy.wait('@backendAPI').then(xhr => {
expect(xhr.response.statusCode).to.equal(200);
});
});

// Check the page for appropriate warnings in the form.
cy.contains('div.flash-message.alert.alert-warning.active', 'Using the Form would update this DOI to the latest schema version.')
cy.contains('div.alert.fade.alert-danger.show', 'To save this DOI, first resolve the errors with these properties:')
cy.get('[data-test-doi-url]').should('have.class', 'has-error')
cy.contains('div.alert.fade.alert-danger.show', 'publisher.name, types.resourceTypeGeneral, contributorType')

// Check that the form 'Update DOI' button (the submit button) is disabled.
cy.get('#doi-update:button').should('be.disabled')

//
// Now fix the schema 3 elements for transition doi to schema 4 metadata.
//

cy.get('[data-test-doi-url] .form-group#url input').click()
cy.get('[data-test-doi-url] .form-group#url input').type('https://example.org{enter}')

// Fix the publisher.
cy.get('[data-test-doi-publisher]').click({ waitForAnimations: true })
cy.get('input.ember-power-select-search-input').type('University of Illinois at Chicago{enter}', { force: true });

// Add a resourceTypeGeneral.
cy.get('#resource-type-general .ember-basic-dropdown-trigger').click()
cy.contains('ul[role=listbox].ember-power-select-options li.ember-power-select-option', 'Dataset').click()

// Show the contributors.
cy.get('button#toggle-contributors').click()

// Remove the contributor with the 'Funder' contributorType. (Find it and click its 'trash' button.)
cy.get('.form-group.data-test-contributors .ember-view:has(.ember-power-select-selected-item:contains("Funder")) [data-test-contributor-name] button').click()

//
// Now add the schema 4 fundingReference to replace the removed 'Funder' contributor.
//

cy.get('button#add-funding-reference').click()

// Add a fundingReference.
cy.get('.form-group[data-test-funding-references] [data-test-funding-reference] [data-test-funder-name] .ember-basic-dropdown-trigger').click()
cy.get('#ember-basic-dropdown-wormhole .ember-power-select-search-input').type('University of Illinois at Urbana-Champaign{enter}')

// Make sure alerts have gone away.
cy.contains('div.alert.fade.alert-danger.show', 'To save this DOI, first resolve the errors with these properties: types.resourceTypeGeneral, contributorType.').should('not.exist')

// Make sure the form doi-update button is enabled.
cy.get('#doi-update:button').should('be.enabled')
cy.get('#doi-update:button').click()

// Check the metadata version,
cy.contains('div.schema-version', '4');
});
});
});


it('can update a doi with outdated kernel-3 to the latest kernel-4 (Via file upload.)', () => {
// For local dev with different prefix
// let prefix = "10.14454"

cy.getCookie('_jwt').then((cookie) => {

// Create a doi we can work with.
cy.createRegisteredDoi(prefix, Cypress.env('api_url'), cookie.value).then((id) => {
let encDoi = encodeURIComponent(id)
let prefix = id.split('/', 1)[0]
let suffix = id.substr(prefix + '/'.length)
let xml = ''

// Intercept the call to GET the DOI info so we can substitute a v3 response which will show in the form.
cy.fixture('doi_v3_1.json').then((doi) => {
doi.data.id = id;
doi.data.attributes.doi = id;
doi.data.attributes.prefix = prefix;
doi.data.attributes.suffix = suffix;
xml = atob(doi.data.attributes.xml);
xml = xml.replace(/<identifier identifierType="DOI">.*<\/identifier>/, '<identifier identifierType="DOI">' + id + '</identifier>')
xml = btoa(xml)
doi.data.attributes.xml = xml

// Intercept the call to get the DOI info so we can substitute a v3 response which will show in the form.
cy.intercept('GET', '/dois/' + encDoi + '?affiliation=true&publisher=true', doi).as('backendAPI');
cy.visit('/dois/' + encDoi + '/modify');
cy.wait('@backendAPI').then(xhr => {
expect(xhr.response.statusCode).to.equal(200);
});
});

// Check the page for appropriate warnings.
cy.get('[data-test-doi-url]').should('have.class', 'has-error')
cy.get('[data-test-doi-metadata] div.form-group').should('have.class', 'has-error')
cy.get('div[data-test-doi-metadata] .has-error')
cy.contains('div.alert-danger.show', 'To save this DOI, first resolve the errors with these properties:')
cy.contains('div.alert-danger.show', 'url, xml')

// Check that the form 'Update DOI' button (the submit button) is disabled.
cy.get('button#doi-modify').should('be.disabled')

// update the url
cy.get('[data-test-doi-url] input#url-field').click()
cy.get('[data-test-doi-url] input#url-field').type('https://example.org{enter}')

// bring in the v4 metadata
cy.fixture('doi_v4_1.xml').then((xml) => {
xml = xml.replace(/<identifier identifierType="DOI">.*<\/identifier>/, '<identifier identifierType="DOI">' + id + '</identifier>')
cy.get('textarea,metadata').clear().invoke('val', xml).trigger('input');
cy.get('textarea,metadata').type(" {backspace}");
});

// Make sure alerts have gone away.
cy.contains('div.alert-danger.show', 'To save this DOI, first resolve the errors with these properties:').should('not.exist')

// Make sure the doi-update button is enabled and submit
cy.get('button#doi-modify').should('be.enabled')
cy.get('button#doi-modify').click()

// Check the metadata version on the show page.
cy.contains('div.schema-version', '4');
})
})
})
});
138 changes: 138 additions & 0 deletions cypress/fixtures/doi_v3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"data": {
"id": "10.14454/0000-0003",
"type": "dois",
"attributes": {
"doi": "10.14454/0000-0003",
"prefix": "10.14454",
"suffix": "0000-0003",
"identifiers": [],
"alternateIdentifiers": [],
"creators": [
{
"name": "Travolta, John",
"nameType": "Personal",
"givenName": "John",
"familyName": "Travolta",
"affiliation": [],
"nameIdentifiers": []
},
{
"name": "X, Mr",
"nameType": "Personal",
"givenName": "Mr",
"familyName": "X",
"affiliation": [],
"nameIdentifiers": []
},
{
"name": "Mozart, Wolfgang Amadeus",
"nameType": "Personal",
"givenName": "Wolfgang Amadeus",
"familyName": "Mozart",
"affiliation": [],
"nameIdentifiers": []
}
],
"titles": [
{
"title": "Test Title"
}
],
"publisher": "University of Illinois at Chicago",
"container": {},
"publicationYear": 2024,
"subjects": [],
"contributors": [
{
"name": "Durham University",
"affiliation": [],
"contributorType": "RightsHolder",
"nameIdentifiers": []
},
{
"name": "Durham University",
"affiliation": [],
"contributorType": "HostingInstitution",
"nameIdentifiers": []
},
{
"name": "Durham University",
"affiliation": [],
"contributorType": "Funder",
"nameIdentifiers": []
}
],
"dates": [],
"language": null,
"relatedIdentifiers": [],
"relatedItems": [],
"sizes": [],
"formats": [],
"version": null,
"rightsList": [],
"descriptions": [],
"geoLocations": [],
"fundingReferences": [],
"xml": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHJlc291cmNlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyIgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC0zL21ldGFkYXRhLnhzZCI+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9IkRPSSI+MTAuMTQ0NTQvMDAwMC0wMDAzPC9pZGVudGlmaWVyPgogIDxjcmVhdG9ycz4KICAgIDxjcmVhdG9yPgogICAgICA8Y3JlYXRvck5hbWUgbmFtZVR5cGU9IlBlcnNvbmFsIj5UcmF2b2x0YSwgSm9objwvY3JlYXRvck5hbWU+CiAgICAgIDxnaXZlbk5hbWU+Sm9objwvZ2l2ZW5OYW1lPgogICAgICA8ZmFtaWx5TmFtZT5UcmF2b2x0YTwvZmFtaWx5TmFtZT4KICAgIDwvY3JlYXRvcj4KICAgIDxjcmVhdG9yPgogICAgICA8Y3JlYXRvck5hbWUgbmFtZVR5cGU9IlBlcnNvbmFsIj5YLCBNcjwvY3JlYXRvck5hbWU+CiAgICAgIDxnaXZlbk5hbWU+TXI8L2dpdmVuTmFtZT4KICAgICAgPGZhbWlseU5hbWU+WDwvZmFtaWx5TmFtZT4KICAgIDwvY3JlYXRvcj4KICAgIDxjcmVhdG9yPgogICAgICA8Y3JlYXRvck5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emaVersion": "http://datacite.org/schema/kernel-3",
"source": "api",
"isActive": false,
"state": "registered",
"reason": null,
"landingPage": null,
"viewCount": 0,
"viewsOverTime": [],
"downloadCount": 0,
"downloadsOverTime": [],
"referenceCount": 0,
"citationCount": 0,
"citationsOverTime": [],
"partCount": 0,
"partOfCount": 0,
"versionCount": 0,
"versionOfCount": 0,
"created": "2024-10-11T14:24:51.000Z",
"registered": "2024-10-11T14:24:51.000Z",
"published": "2024",
"updated": "2024-10-11T14:28:50.000Z"
},
"relationships": {
"client": {
"data": {
"id": "datacite.test",
"type": "clients"
}
},
"provider": {
"data": {
"id": "datacite",
"type": "providers"
}
},
"media": {
},
"references": {
"data": []
},
"citations": {
"data": []
},
"parts": {
"data": []
},
"partOf": {
"data": []
},
"versions": {
"data": []
},
"versionOf": {
"data": []
}
}
}
}
40 changes: 40 additions & 0 deletions cypress/fixtures/doi_v3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-3" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
<identifier identifierType="DOI">10.14454/AMZE-V007</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Travolta, John</creatorName>
<givenName>John</givenName>
<familyName>Travolta</familyName>
</creator>
<creator>
<creatorName nameType="Personal">X, Mr</creatorName>
<givenName>Mr</givenName>
<familyName>X</familyName>
</creator>
<creator>
<creatorName nameType="Personal">Mozart, Wolfgang Amadeus</creatorName>
<givenName>Wolfgang Amadeus</givenName>
<familyName>Mozart</familyName>
</creator>
</creators>
<titles>
<title>Test Title</title>
</titles>
<publisher>University of Illinois at Chicago</publisher>
<publicationYear>2024</publicationYear>
<contributors>
<contributor contributorType="RightsHolder">
<contributorName>Durham University</contributorName>
</contributor>
<contributor contributorType="HostingInstitution">
<contributorName>Durham University</contributorName>
</contributor>
<contributor contributorType="Funder">
<contributorName>Durham University</contributorName>
</contributor>
</contributors>
<sizes/>
<formats/>
<version/>
</resource>
Loading

0 comments on commit cf3798d

Please sign in to comment.