diff --git a/docs/useCases.md b/docs/useCases.md index ff66d77f..395723f2 100644 --- a/docs/useCases.md +++ b/docs/useCases.md @@ -11,8 +11,9 @@ The different use cases currently available in the package are classified below, - [Datasets](#Datasets) - [Datasets read use cases](#datasets-read-use-cases) - [Get a Dataset](#get-a-dataset) - - [Get Citation Text from a Dataset](#get-citation-text-from-a-dataset) - - [List all Datasets](#list-all-datasets) + - [Get Dataset Citation Text](#get-dataset-citation-text) + - [Get Dataset Locks](#get-dataset-locks) + - [List All Datasets](#list-all-datasets) - [Files](#Files) - [Metadata Blocks](#metadata-blocks) - [Users](#Users) @@ -53,7 +54,7 @@ The `datasetVersionId` parameter can correspond to a numeric version identifier, There is a third optional parameter called `includeDeaccessioned`, which indicates whether to consider deaccessioned versions or not in the dataset search. If not set, the default value is `false`. -#### Get Citation Text from a Dataset +#### Get Dataset Citation Text Returns the Dataset citation text. @@ -64,7 +65,7 @@ import { getDatasetCitation } from '@iqss/dataverse-client-javascript' /* ... */ -const datasetId = 'doi:10.77777/FK2/AAAAAA'; +const datasetId = 2; const datasetVersionId = '1.0'; getDatasetCitation @@ -80,6 +81,32 @@ getDatasetCitation There is a third optional parameter called `includeDeaccessioned`, which indicates whether to consider deaccessioned versions or not in the dataset search. If not set, the default value is `false`. +#### Get Dataset Locks + +Returns a [DatasetLock](../src/datasets/domain/models/DatasetLock.ts) array of all locks present in a Dataset. + +##### Example call: + +````typescript +import { getDatasetLocks } from '@iqss/dataverse-client-javascript' + +/* ... */ + +const datasetId = 'doi:10.77777/FK2/AAAAAA'; + +getDatasetLocks + .execute(datasetId) + .then((datasetLocks: DatasetLock[]) => { + /* ... */ + }); + +/* ... */ +```` + +*See [use case](../src/datasets/domain/useCases/GetDatasetLocks.ts) definition*. + +The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers. + #### List All Datasets Returns an instance of [DatasetPreviewSubset](../src/datasets/domain/models/DatasetPreviewSubset.ts) that contains reduced information for each dataset that the calling user can access in the installation. diff --git a/src/datasets/domain/useCases/GetDatasetLocks.ts b/src/datasets/domain/useCases/GetDatasetLocks.ts index f44dccda..b4164567 100644 --- a/src/datasets/domain/useCases/GetDatasetLocks.ts +++ b/src/datasets/domain/useCases/GetDatasetLocks.ts @@ -9,6 +9,12 @@ export class GetDatasetLocks implements UseCase { this.datasetsRepository = datasetsRepository; } + /** + * Returns all locks present in a Dataset. + * + * @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers). + * @returns {Promise} + */ async execute(datasetId: number | string): Promise { return await this.datasetsRepository.getDatasetLocks(datasetId); }