Skip to content

Commit c43f17c

Browse files
committed
Added: extended properties to CollectionDTO for creation
1 parent 2d4fe7e commit c43f17c

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

src/collections/domain/dtos/CollectionDTO.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ export interface CollectionDTO {
55
type: CollectionType
66
affiliation?: string
77
description?: string
8+
metadataBlockNames: string[]
9+
facetIds?: string[]
10+
inputLevels?: DatasetFieldTypeInputLevelDTO[]
11+
}
12+
13+
export interface DatasetFieldTypeInputLevelDTO {
14+
datasetFieldName: string
15+
include: boolean
16+
required: boolean
817
}
918

1019
export enum CollectionType {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO

src/collections/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ const createCollection = new CreateCollection(collectionsRepository)
1010

1111
export { getCollection, createCollection }
1212
export { Collection } from './domain/models/Collection'
13-
export { CollectionDTO } from './domain/dtos/CollectionDTO'
13+
export { CollectionDTO, DatasetFieldTypeInputLevelDTO } from './domain/dtos/CollectionDTO'

src/collections/infra/repositories/CollectionsRepository.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@ export interface NewCollectionRequestPayload {
99
name: string
1010
dataverseContacts: NewCollectionContactRequestPayload[]
1111
dataverseType: string
12+
metadataBlocks: NewCollectionMetadataBlocksRequestPayload
1213
}
1314

1415
export interface NewCollectionContactRequestPayload {
1516
contactEmail: string
1617
}
1718

19+
export interface NewCollectionMetadataBlocksRequestPayload {
20+
metadataBlockNames: string[]
21+
facetIds: string[]
22+
inputLevels: NewCollectionInputLevelRequestPayload[]
23+
}
24+
25+
export interface NewCollectionInputLevelRequestPayload {
26+
datasetFieldTypeName: string
27+
include: boolean
28+
required: boolean
29+
}
30+
1831
export class CollectionsRepository extends ApiRepository implements ICollectionsRepository {
1932
private readonly collectionsResourceName: string = 'dataverses'
2033

@@ -40,11 +53,25 @@ export class CollectionsRepository extends ApiRepository implements ICollections
4053
})
4154
)
4255

56+
const inputLevelsRequestBody: NewCollectionInputLevelRequestPayload[] = []
57+
collectionDTO.inputLevels.forEach((element) => {
58+
inputLevelsRequestBody.push({
59+
datasetFieldTypeName: element.datasetFieldName,
60+
include: element.include,
61+
required: element.required
62+
})
63+
})
64+
4365
const requestBody: NewCollectionRequestPayload = {
4466
alias: collectionDTO.alias,
4567
name: collectionDTO.name,
4668
dataverseContacts: dataverseContacts,
47-
dataverseType: collectionDTO.type.toString()
69+
dataverseType: collectionDTO.type.toString(),
70+
metadataBlocks: {
71+
metadataBlockNames: collectionDTO.metadataBlockNames,
72+
facetIds: collectionDTO.facetIds,
73+
inputLevels: inputLevelsRequestBody
74+
}
4875
}
4976

5077
return this.doPost(`/${this.collectionsResourceName}/${parentCollectionId}`, requestBody)

test/testHelpers/collections/collectionHelper.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,16 @@ export const createCollectionDTO = (alias = 'test-collection'): CollectionDTO =>
108108
alias: alias,
109109
name: 'Test Collection',
110110
contacts: ['[email protected]'],
111-
type: CollectionType.DEPARTMENT
111+
type: CollectionType.DEPARTMENT,
112+
metadataBlockNames: ['citation', 'geospatial'],
113+
facetIds: ['authorName', 'authorAffiliation'],
114+
inputLevels: [
115+
{
116+
datasetFieldName: 'geographicCoverage',
117+
required: true,
118+
include: true
119+
}
120+
]
112121
}
113122
}
114123

@@ -121,6 +130,17 @@ export const createNewCollectionRequestPayload = (): NewCollectionRequestPayload
121130
contactEmail: '[email protected]'
122131
}
123132
],
124-
dataverseType: 'DEPARTMENT'
133+
dataverseType: 'DEPARTMENT',
134+
metadataBlocks: {
135+
metadataBlockNames: ['citation', 'geospatial'],
136+
facetIds: ['authorName', 'authorAffiliation'],
137+
inputLevels: [
138+
{
139+
datasetFieldTypeName: 'geographicCoverage',
140+
include: true,
141+
required: true
142+
}
143+
]
144+
}
125145
}
126146
}

0 commit comments

Comments
 (0)