-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGetCollectionMetadataBlocks.ts
More file actions
33 lines (30 loc) · 1.61 KB
/
GetCollectionMetadataBlocks.ts
File metadata and controls
33 lines (30 loc) · 1.61 KB
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
31
32
33
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { MetadataBlock } from '../..'
import { ROOT_COLLECTION_ID } 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.
* @param {string} [datasetType] - The name of the dataset type. If provided, additional fields from metadata blocks linked to this dataset type will be returned.
* @returns {Promise<MetadataBlock[]>}
*/
async execute(
collectionIdOrAlias: number | string = ROOT_COLLECTION_ID,
onlyDisplayedOnCreate = false,
datasetType?: string
): Promise<MetadataBlock[]> {
return await this.metadataBlocksRepository.getCollectionMetadataBlocks(
collectionIdOrAlias,
onlyDisplayedOnCreate,
datasetType
)
}
}