forked from IQSS/dataverse-client-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetCollectionMetadataBlocks.ts
30 lines (27 loc) · 1.41 KB
/
GetCollectionMetadataBlocks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { MetadataBlock } from '../..'
import { ROOT_COLLECTION_ALIAS } from '../../../collections/domain/models/Collection'
import { IMetadataBlocksRepository } from '../repositories/IMetadataBlocksRepository'
export class GetCollectionMetadataBlocks implements UseCase<MetadataBlock[]> {
private metadataBlocksRepository: IMetadataBlocksRepository
constructor(metadataBlocksRepository: IMetadataBlocksRepository) {
this.metadataBlocksRepository = metadataBlocksRepository
}
/**
* Returns a MetadataBlock array containing the metadata blocks from the requested collection.
*
* @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)
* If this parameter is not set, the default value is: 'root'
* @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.
* @returns {Promise<MetadataBlock[]>}
*/
async execute(
collectionIdOrAlias: number | string = ROOT_COLLECTION_ALIAS,
onlyDisplayedOnCreate = false
): Promise<MetadataBlock[]> {
return await this.metadataBlocksRepository.getCollectionMetadataBlocks(
collectionIdOrAlias,
onlyDisplayedOnCreate
)
}
}