Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/collections/domain/models/Collection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DvObjectOwnerNode } from '../../../core'
import { CollectionContact } from './CollectionContact'
import { CollectionType } from './CollectionType'
import { DatasetType } from '../../../datasets'

export interface Collection {
id: number
Expand All @@ -13,6 +14,7 @@ export interface Collection {
inputLevels?: CollectionInputLevel[]
type: CollectionType
contacts?: CollectionContact[]
allowedDatasetTypes?: DatasetType[]
Comment thread
jp-tosca marked this conversation as resolved.
isMetadataBlockRoot: boolean
isFacetRoot: boolean
childCount: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface CollectionPayload {
isPartOf: OwnerNodePayload
inputLevels?: CollectionInputLevelPayload[]
dataverseContacts?: CollectionContactPayload[]
allowedDatasetTypes?: AllowedDatasetTypePayload[]
dataverseType: string
isMetadataBlockRoot: boolean
isFacetRoot: boolean
Expand All @@ -26,3 +27,10 @@ export interface CollectionContactPayload {
contactEmail: string
displayOrder: number
}

export interface AllowedDatasetTypePayload {
id: number
name: string
displayName: string
description?: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { AxiosResponse } from 'axios'
import {
CollectionContactPayload,
CollectionInputLevelPayload,
CollectionPayload
CollectionPayload,
AllowedDatasetTypePayload
} from './CollectionPayload'
import { transformPayloadToOwnerNode } from '../../../../core/infra/repositories/transformers/dvObjectOwnerNodeTransformer'
import { CollectionFacet } from '../../../domain/models/CollectionFacet'
Expand All @@ -13,7 +14,7 @@ import {
CollectionItemSubset,
CountPerObjectType
} from '../../../domain/models/CollectionItemSubset'
import { DatasetPreview } from '../../../../datasets'
import { DatasetPreview, DatasetType } from '../../../../datasets'
import { FilePreview } from '../../../../files'
import { DatasetPreviewPayload } from '../../../../datasets/infra/repositories/transformers/DatasetPreviewPayload'
import { FilePreviewPayload } from '../../../../files/infra/repositories/transformers/FilePreviewPayload'
Expand Down Expand Up @@ -82,6 +83,11 @@ const transformPayloadToCollection = (collectionPayload: CollectionPayload): Col
}),
...(collectionPayload.dataverseContacts && {
contacts: transformContactsPayloadToContacts(collectionPayload.dataverseContacts)
}),
...(collectionPayload.allowedDatasetTypes && {
allowedDatasetTypes: transformAllowedDatasetTypesPayloadToAllowedDatasetTypes(
collectionPayload.allowedDatasetTypes
)
})
}
return collectionModel
Expand Down Expand Up @@ -252,3 +258,14 @@ const transformContactsPayloadToContacts = (
displayOrder: contactPayload.displayOrder
}))
}

const transformAllowedDatasetTypesPayloadToAllowedDatasetTypes = (
allowedDatasetTypesPayload: AllowedDatasetTypePayload[]
): DatasetType[] => {
return allowedDatasetTypesPayload.map((allowedDatasetType) => ({
id: allowedDatasetType.id,
name: allowedDatasetType.name,
displayName: allowedDatasetType.displayName,
description: allowedDatasetType.description
}))
}
2 changes: 1 addition & 1 deletion test/integration/collections/CollectionsRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ describe('CollectionsRepository', () => {
// TODO: uncomment this test when https://github.com/IQSS/dataverse/issues/12027 is fixed
// const expectedDatasetCitationFragment = `Admin, Dataverse; Owner, Dataverse, ${currentYear}, "Dataset created using the createDataset use case`
const expectedDatasetDescription = 'Dataset created using the createDataset use case'
const expectedFileName = 'test-file-4.tab'
const expectedFileName = 'test-file-4.tsv'
const expectedCollectionsName = 'Scientific Research'

expect(actualFilePreview.checksum?.type).toBe('MD5')
Expand Down
16 changes: 16 additions & 0 deletions test/testHelpers/collections/collectionHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ export const createCollectionModel = (): Collection => {
displayOrder: 0
}
],
allowedDatasetTypes: [
{
id: 1,
name: 'review',
displayName: 'Review',
description: 'A review of a dataset compiled by the expert community.'
}
],
isMetadataBlockRoot: true,
isFacetRoot: true,
childCount: 0
Expand Down Expand Up @@ -75,6 +83,14 @@ export const createCollectionPayload = (): CollectionPayload => {
displayOrder: 0
}
],
allowedDatasetTypes: [
{
id: 1,
name: 'review',
displayName: 'Review',
description: 'A review of a dataset compiled by the expert community.'
}
],
isMetadataBlockRoot: true,
isFacetRoot: true,
childCount: 0
Expand Down
Loading