Skip to content

Commit 351424d

Browse files
authored
Merge pull request #374 from IQSS/210-get-blocks-datasettype
update getCollectionMetadataBlocks use case to support passing a dataset type
2 parents 16c83fe + d1ee276 commit 351424d

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

docs/useCases.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,8 @@ The `collectionIdOrAlias` is a generic collection identifier, which can be eithe
20122012

20132013
There is a second optional parameter called `onlyDisplayedOnCreate` which indicates whether or not to return only the metadata blocks that are displayed on dataset creation. The default value is false.
20142014

2015+
There is a third optional parameter called `datasetType` which will include additional fields from metadata blocks linked to the provided type, if any. Before using this parameter, you will probably want to [list available dataset types](#get-dataset-available-dataset-types) for your installation.
2016+
20152017
## Users
20162018

20172019
### Users read use cases

src/metadataBlocks/domain/repositories/IMetadataBlocksRepository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export interface IMetadataBlocksRepository {
55

66
getCollectionMetadataBlocks(
77
collectionIdOrAlias: number | string,
8-
onlyDisplayedOnCreate: boolean
8+
onlyDisplayedOnCreate: boolean,
9+
datasetType?: string
910
): Promise<MetadataBlock[]>
1011

1112
getAllMetadataBlocks(): Promise<MetadataBlock[]>

src/metadataBlocks/domain/useCases/GetCollectionMetadataBlocks.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ export class GetCollectionMetadataBlocks implements UseCase<MetadataBlock[]> {
1616
* @param {number | string} [collectionIdOrAlias = ':root'] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId)
1717
* If this parameter is not set, the default value is: ':root'
1818
* @param {boolean} [onlyDisplayedOnCreate=false] - Indicates whether or not to return only the metadata blocks that are displayed on dataset creation. The default value is false.
19+
* @param {string} [datasetType] - The name of the dataset type. If provided, additional fields from metadata blocks linked to this dataset type will be returned.
1920
* @returns {Promise<MetadataBlock[]>}
2021
*/
2122
async execute(
2223
collectionIdOrAlias: number | string = ROOT_COLLECTION_ID,
23-
onlyDisplayedOnCreate = false
24+
onlyDisplayedOnCreate = false,
25+
datasetType?: string
2426
): Promise<MetadataBlock[]> {
2527
return await this.metadataBlocksRepository.getCollectionMetadataBlocks(
2628
collectionIdOrAlias,
27-
onlyDisplayedOnCreate
29+
onlyDisplayedOnCreate,
30+
datasetType
2831
)
2932
}
3033
}

src/metadataBlocks/infra/repositories/MetadataBlocksRepository.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ export class MetadataBlocksRepository extends ApiRepository implements IMetadata
1717

1818
public async getCollectionMetadataBlocks(
1919
collectionIdOrAlias: string | number,
20-
onlyDisplayedOnCreate: boolean
20+
onlyDisplayedOnCreate: boolean,
21+
datasetType?: string
2122
): Promise<MetadataBlock[]> {
2223
return this.doGet(`/dataverses/${collectionIdOrAlias}/metadatablocks`, true, {
2324
onlyDisplayedOnCreate: onlyDisplayedOnCreate,
24-
returnDatasetFieldTypes: true
25+
returnDatasetFieldTypes: true,
26+
datasetType: datasetType
2527
})
2628
.then((response) => transformMetadataBlocksResponseToMetadataBlocks(response))
2729
.catch((error) => {

0 commit comments

Comments
 (0)