diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index 3decbc088..258f99b88 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -220,9 +220,10 @@ export class DatasetVersion { public readonly isLatest: boolean, public readonly isInReview: boolean, public readonly latestVersionStatus: DatasetPublishingStatus, + public readonly citation: string, public readonly majorNumber?: number, - public readonly minorNumber?: number, // requestedVersion will be set if the user requested a version that did not exist. + public readonly minorNumber?: number, public readonly requestedVersion?: string ) {} @@ -273,7 +274,6 @@ export class Dataset { constructor( public readonly persistentId: string, public readonly version: DatasetVersion, - public readonly citation: string, public readonly labels: DatasetLabel[], public readonly alerts: Alert[], public readonly summaryFields: DatasetMetadataBlock[], @@ -361,7 +361,6 @@ export class Dataset { constructor( public readonly persistentId: string, public readonly version: DatasetVersion, - public readonly citation: string, public readonly summaryFields: DatasetMetadataBlock[], public readonly license: DatasetLicense = defaultLicense, public readonly metadataBlocks: DatasetMetadataBlocks, @@ -470,7 +469,6 @@ export class Dataset { return new Dataset( this.persistentId, this.version, - this.citation, this.labels, this.alerts, this.summaryFields, diff --git a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts index 95703678d..1feb01ce8 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts @@ -26,8 +26,8 @@ import { export class JSDatasetMapper { static toDataset( jsDataset: JSDataset, - citation: string, - summaryFieldsNames: string[], + jsDatasetCitation: string, + jsDatasetSummaryFieldsNames: string[], jsDatasetPermissions: JSDatasetPermissions, jsDatasetLocks: JSDatasetLock[], requestedVersion?: string, @@ -36,13 +36,13 @@ export class JSDatasetMapper { const version = JSDatasetMapper.toVersion( jsDataset.versionId, jsDataset.versionInfo, + jsDatasetCitation, requestedVersion ) return new Dataset.Builder( jsDataset.persistentId, version, - citation, - JSDatasetMapper.toSummaryFields(jsDataset.metadataBlocks, summaryFieldsNames), + JSDatasetMapper.toSummaryFields(jsDataset.metadataBlocks, jsDatasetSummaryFieldsNames), jsDataset.license, JSDatasetMapper.toMetadataBlocks( jsDataset.metadataBlocks, @@ -66,14 +66,16 @@ export class JSDatasetMapper { static toVersion( jDatasetVersionId: number, jsDatasetVersionInfo: JSDatasetVersionInfo, + jsDatasetCitation: string, requestedVersion?: string ): DatasetVersion { return new DatasetVersion( jDatasetVersionId, JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), - true, // TODO Connect with dataset version isLatest - false, // TODO Connect with dataset version isInReview - JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), // TODO Connect with dataset version latestVersionState + true, + false, + JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), + jsDatasetCitation, jsDatasetVersionInfo.majorNumber, jsDatasetVersionInfo.minorNumber, requestedVersion diff --git a/src/sections/dataset/Dataset.tsx b/src/sections/dataset/Dataset.tsx index 8095e0ae8..27e0eb4ff 100644 --- a/src/sections/dataset/Dataset.tsx +++ b/src/sections/dataset/Dataset.tsx @@ -60,7 +60,6 @@ export function Dataset({ fileRepository }: DatasetProps) { diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.tsx b/src/sections/dataset/dataset-citation/DatasetCitation.tsx index 9b523c7c7..fa29beee4 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.tsx +++ b/src/sections/dataset/dataset-citation/DatasetCitation.tsx @@ -8,11 +8,10 @@ import { CitationThumbnail } from './CitationThumbnail' interface DatasetCitationProps { thumbnail?: string title: string - citation: string version: DatasetVersion } -export function DatasetCitation({ thumbnail, title, citation, version }: DatasetCitationProps) { +export function DatasetCitation({ thumbnail, title, version }: DatasetCitationProps) { const { t } = useTranslation('dataset') return ( <> @@ -32,7 +31,10 @@ export function DatasetCitation({ thumbnail, title, citation, version }: Dataset - +
@@ -53,13 +55,19 @@ export function DatasetCitation({ thumbnail, title, citation, version }: Dataset ) } -function CitationDescription({ citation, version }: { citation: string; version: DatasetVersion }) { +function CitationDescription({ + citation, + publishingStatus +}: { + citation: string + publishingStatus: DatasetPublishingStatus +}) { const citationAsReactElement = parse(citation) return ( {citationAsReactElement} - + ) } diff --git a/src/stories/dataset/dataset-alerts/DatasetAlert.stories.tsx b/src/stories/dataset/dataset-alerts/DatasetAlert.stories.tsx index 31de08bf7..0eabf83f2 100644 --- a/src/stories/dataset/dataset-alerts/DatasetAlert.stories.tsx +++ b/src/stories/dataset/dataset-alerts/DatasetAlert.stories.tsx @@ -62,7 +62,8 @@ export const DraftVersion: Story = { DatasetPublishingStatus.DRAFT, true, false, - DatasetPublishingStatus.DRAFT + DatasetPublishingStatus.DRAFT, + '' ), permissions: DatasetPermissionsMother.createWithPublishingDatasetAllowed() }) @@ -83,6 +84,7 @@ export const VersionNotFound: Story = { true, false, DatasetPublishingStatus.RELEASED, + '', 1, 0, '3.0' @@ -105,6 +107,7 @@ export const VersionNotFoundShowDraft: Story = { true, false, DatasetPublishingStatus.DRAFT, + '', 1, 0, '3.0' @@ -127,6 +130,7 @@ export const SharePrivateUrl: Story = { true, false, DatasetPublishingStatus.DRAFT, + '', 1, 0 ), @@ -153,6 +157,7 @@ export const UsePrivateUrl: Story = { true, false, DatasetPublishingStatus.DRAFT, + '', 1, 0 ), diff --git a/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx b/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx index cd7d511d4..359c5d133 100644 --- a/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx +++ b/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx @@ -1,9 +1,11 @@ import type { Meta, StoryObj } from '@storybook/react' import { WithI18next } from '../../WithI18next' import { DatasetCitation } from '../../../sections/dataset/dataset-citation/DatasetCitation' -import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' import { faker } from '@faker-js/faker' -import { DatasetMother } from '../../../../tests/component/dataset/domain/models/DatasetMother' +import { + DatasetMother, + DatasetVersionMother +} from '../../../../tests/component/dataset/domain/models/DatasetMother' const meta: Meta = { title: 'Sections/Dataset Page/DatasetCitation', @@ -21,11 +23,7 @@ export const Default: Story = {




- +
) } @@ -41,7 +39,6 @@ export const WithThumbnail: Story = {
@@ -52,15 +49,7 @@ export const WithThumbnail: Story = { export const DraftVersion: Story = { render: () => { const dataset = DatasetMother.createRealistic({ - citation: - 'Admin, Dataverse, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, DRAFT VERSION', - version: new DatasetVersion( - 1, - DatasetPublishingStatus.DRAFT, - true, - false, - DatasetPublishingStatus.DRAFT - ) + version: DatasetVersionMother.createDraft() }) /* @@ -70,11 +59,7 @@ export const DraftVersion: Story = {




- +
) } @@ -83,17 +68,7 @@ export const DraftVersion: Story = { export const Deaccessioned: Story = { render: () => { const dataset = DatasetMother.createRealistic({ - citation: - 'Admin, Dataverse, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1 DEACCESSIONED VERSION', - version: new DatasetVersion( - 1, - DatasetPublishingStatus.DEACCESSIONED, - true, - false, - DatasetPublishingStatus.DEACCESSIONED, - 1, - 0 - ) + version: DatasetVersionMother.createDeaccessioned() }) /* @@ -103,11 +78,7 @@ export const Deaccessioned: Story = {




- +
) } @@ -115,10 +86,7 @@ export const Deaccessioned: Story = { export const Anonymized: Story = { render: () => { - const dataset = DatasetMother.createRealistic({ - citation: - 'Author name(s) withheld, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1' - }) + const dataset = DatasetMother.createRealisticAnonymized() /* Includes extra breaks, so you can see the DRAFT tooltip message @@ -127,11 +95,7 @@ export const Anonymized: Story = {




- +
) } diff --git a/tests/component/dataset/domain/models/DatasetMother.ts b/tests/component/dataset/domain/models/DatasetMother.ts index 60e8e7e14..65a535d57 100644 --- a/tests/component/dataset/domain/models/DatasetMother.ts +++ b/tests/component/dataset/domain/models/DatasetMother.ts @@ -26,6 +26,8 @@ export class DatasetVersionMother { props?.isLatest ?? false, props?.isInReview ?? false, props?.latestVersionStatus ?? DatasetPublishingStatus.RELEASED, + props?.citation ?? + 'Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1', props?.majorNumber ?? 1, props?.minorNumber ?? 0 ) @@ -36,20 +38,28 @@ export class DatasetVersionMother { } static createDeaccessioned(): DatasetVersion { - return this.create({ publishingStatus: DatasetPublishingStatus.DEACCESSIONED }) + return this.create({ + publishingStatus: DatasetPublishingStatus.DEACCESSIONED, + citation: + 'Admin, Dataverse, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1 DEACCESSIONED VERSION' + }) } - static createDraftAsLatestVersion(): DatasetVersion { - return this.create({ publishingStatus: DatasetPublishingStatus.DRAFT, isLatest: true }) + static createDraft(props?: Partial): DatasetVersion { + return this.create({ + publishingStatus: DatasetPublishingStatus.DRAFT, + citation: + 'Admin, Dataverse, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, DRAFT VERSION', + ...props + }) } - static createDraft(): DatasetVersion { - return this.create({ publishingStatus: DatasetPublishingStatus.DRAFT }) + static createDraftAsLatestVersion(): DatasetVersion { + return this.createDraft({ publishingStatus: DatasetPublishingStatus.DRAFT, isLatest: true }) } static createDraftAsLatestVersionInReview(): DatasetVersion { - return this.create({ - publishingStatus: DatasetPublishingStatus.DRAFT, + return this.createDraft({ isLatest: true, isInReview: true }) @@ -64,8 +74,7 @@ export class DatasetVersionMother { } static createDraftWithLatestVersionIsADraft(): DatasetVersion { - return this.create({ - publishingStatus: DatasetPublishingStatus.DRAFT, + return this.createDraft({ isLatest: true, latestVersionStatus: DatasetPublishingStatus.DRAFT }) @@ -78,6 +87,12 @@ export class DatasetVersionMother { latestVersionStatus: DatasetPublishingStatus.RELEASED }) } + + static createAnonymized(): DatasetVersion { + return this.create({ + citation: `Author name(s) withheld, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1` + }) + } } export class DatasetPermissionsMother { @@ -222,8 +237,6 @@ export class DatasetMother { persistentId: faker.datatype.uuid(), title: faker.lorem.sentence(), version: DatasetVersionMother.create(), - citation: - 'Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1', license: { name: 'CC0 1.0', uri: 'https://creativecommons.org/publicdomain/zero/1.0/', @@ -328,7 +341,6 @@ export class DatasetMother { return new Dataset.Builder( dataset.persistentId, dataset.version, - dataset.citation, dataset.summaryFields, dataset.license, dataset.metadataBlocks, @@ -354,8 +366,7 @@ export class DatasetMother { static createAnonymized(): Dataset { return this.create({ - citation: - 'Author name(s) withheld, 2023, "citation", https://doi.org/10.5072/FK2/BUDNRV, Root, V1', + version: DatasetVersionMother.createAnonymized(), metadataBlocks: [ { name: MetadataBlockName.CITATION, @@ -385,13 +396,13 @@ export class DatasetMother { static createRealistic(props?: Partial): Dataset { return this.create({ persistentId: 'doi:10.5072/FK2/ABC123', - citation: `Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1`, version: new DatasetVersion( 1, DatasetPublishingStatus.RELEASED, false, false, DatasetPublishingStatus.RELEASED, + `Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1`, 1, 0 ), @@ -492,7 +503,7 @@ export class DatasetMother { static createRealisticAnonymized(): Dataset { return this.createRealistic({ - citation: `Author name(s) withheld, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1`, + version: DatasetVersionMother.createAnonymized(), metadataBlocks: [ { name: MetadataBlockName.CITATION, diff --git a/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx b/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx index 65d4c3fb3..d628fa278 100644 --- a/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx +++ b/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx @@ -1,20 +1,10 @@ import { DatasetCitation } from '../../../../../src/sections/dataset/dataset-citation/DatasetCitation' -import { DatasetMother } from '../../../dataset/domain/models/DatasetMother' -import { - DatasetPublishingStatus, - DatasetVersion -} from '../../../../../src/dataset/domain/models/Dataset' +import { DatasetMother, DatasetVersionMother } from '../../../dataset/domain/models/DatasetMother' describe('DatasetCitation', () => { it('renders the DatasetCitation fields of released Dataset', () => { const dataset = DatasetMother.create() - cy.customMount( - - ) + cy.customMount() cy.findByText('Data Citation Standards.').should('exist') cy.findByText(/Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title"/).should('exist') @@ -31,21 +21,9 @@ describe('DatasetCitation', () => { it('shows the draft tooltip when version is draft', () => { const dataset = DatasetMother.create({ - version: new DatasetVersion( - 1, - DatasetPublishingStatus.DRAFT, - true, - false, - DatasetPublishingStatus.DRAFT - ) + version: DatasetVersionMother.createDraft() }) - cy.customMount( - - ) + cy.customMount() cy.findByRole('img', { name: 'tooltip icon' }).should('exist').trigger('mouseover') cy.findByText( @@ -55,23 +33,9 @@ describe('DatasetCitation', () => { it('shows the deaccessioned tooltip when version is deaccessioned', () => { const dataset = DatasetMother.create({ - version: new DatasetVersion( - 1, - DatasetPublishingStatus.DEACCESSIONED, - true, - false, - DatasetPublishingStatus.DEACCESSIONED, - 1, - 0 - ) + version: DatasetVersionMother.createDeaccessioned() }) - cy.customMount( - - ) + cy.customMount() cy.findByRole('img', { name: 'tooltip icon' }).should('exist').trigger('mouseover') cy.findByText( diff --git a/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx b/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx index 5ef68d479..8a0cb0378 100644 --- a/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx @@ -21,6 +21,7 @@ const datasetVersion = new DatasetVersion( true, false, DatasetPublishingStatus.RELEASED, + '', 1, 0 ) diff --git a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts index 1aa52c69a..0bb66adc4 100644 --- a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts @@ -19,10 +19,13 @@ function getCurrentDateInYYYYMMDDFormat() { ).padStart(2, '0')}` } +function getPersistentIdUrl(persistentId: string) { + return `https://doi.org/${persistentId.replace('doi:', '')}` +} + const datasetData = (persistentId: string, versionId: number) => { - const persistentIdUrl = `https://doi.org/${persistentId.replace('doi:', '')}` + const persistentIdUrl = getPersistentIdUrl(persistentId) return { - citation: `Finch, Fiona, 2023, "Darwin's Finches", ${persistentIdUrl}, Root, DRAFT VERSION`, labels: [ { semanticMeaning: 'dataset', value: 'Draft' }, { semanticMeaning: 'warning', value: 'Unpublished' } @@ -80,7 +83,8 @@ const datasetData = (persistentId: string, versionId: number) => { requestedVersion: undefined, latestVersionStatus: 'draft', isLatest: true, - isInReview: false + isInReview: false, + citation: `Finch, Fiona, 2023, "Darwin's Finches", ${persistentIdUrl}, Root, DRAFT VERSION` }, permissions: { canDownloadFiles: true, @@ -109,7 +113,6 @@ describe('Dataset JSDataverse Repository', () => { const datasetExpected = datasetData(dataset.persistentId, dataset.version.id) expect(dataset.getTitle()).to.deep.equal(datasetExpected.title) - expect(dataset.citation).to.deep.equal(datasetExpected.citation) expect(dataset.labels).to.deep.equal(datasetExpected.labels) expect(dataset.license).to.deep.equal(datasetExpected.license) expect(dataset.metadataBlocks).to.deep.equal(datasetExpected.metadataBlocks) @@ -143,6 +146,9 @@ describe('Dataset JSDataverse Repository', () => { true, false, DatasetPublishingStatus.RELEASED, + `Finch, Fiona, 2023, "Darwin's Finches", ${getPersistentIdUrl(dataset.persistentId)}, Root, V1`, 1, 0 ) @@ -181,6 +187,9 @@ describe('Dataset JSDataverse Repository', () => { true, false, DatasetPublishingStatus.RELEASED, + `Finch, Fiona, 2023, "Darwin's Finches", ${getPersistentIdUrl(dataset.persistentId)}, Root, V1`, 1, 0 ) diff --git a/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts index 4f2c8b1a2..de359b7de 100644 --- a/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts @@ -150,6 +150,7 @@ describe('File JSDataverse Repository', () => { true, false, DatasetPublishingStatus.RELEASED, + '', 1, 0 ) @@ -186,6 +187,7 @@ describe('File JSDataverse Repository', () => { true, false, DatasetPublishingStatus.DEACCESSIONED, + '', 1, 0 )