Skip to content
Merged
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 docs/useCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,8 @@ The `collectionIdOrAlias` is a generic collection identifier, which can be eithe

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.

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.

## Users

### Users read use cases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export interface IMetadataBlocksRepository {

getCollectionMetadataBlocks(
collectionIdOrAlias: number | string,
onlyDisplayedOnCreate: boolean
onlyDisplayedOnCreate: boolean,
datasetType?: string
): Promise<MetadataBlock[]>

getAllMetadataBlocks(): Promise<MetadataBlock[]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ export class GetCollectionMetadataBlocks implements UseCase<MetadataBlock[]> {
* @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
onlyDisplayedOnCreate = false,
datasetType?: string
): Promise<MetadataBlock[]> {
return await this.metadataBlocksRepository.getCollectionMetadataBlocks(
collectionIdOrAlias,
onlyDisplayedOnCreate
onlyDisplayedOnCreate,
datasetType
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export class MetadataBlocksRepository extends ApiRepository implements IMetadata

public async getCollectionMetadataBlocks(
collectionIdOrAlias: string | number,
onlyDisplayedOnCreate: boolean
onlyDisplayedOnCreate: boolean,
datasetType?: string
): Promise<MetadataBlock[]> {
return this.doGet(`/dataverses/${collectionIdOrAlias}/metadatablocks`, true, {
onlyDisplayedOnCreate: onlyDisplayedOnCreate,
returnDatasetFieldTypes: true
returnDatasetFieldTypes: true,
datasetType: datasetType
})
.then((response) => transformMetadataBlocksResponseToMetadataBlocks(response))
.catch((error) => {
Expand Down
Loading