Skip to content

Commit 008b3aa

Browse files
committed
Merge branch 'develop' into 334-create-use-cases-for-get-notifications-and-delete-notifications
2 parents 252e08c + 158f842 commit 008b3aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+992
-7
lines changed

docs/useCases.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ The different use cases currently available in the package are classified below,
3636
- [Get Differences between Two Dataset Versions](#get-differences-between-two-dataset-versions)
3737
- [List All Datasets](#list-all-datasets)
3838
- [Get Dataset Versions Summaries](#get-dataset-versions-summaries)
39+
- [Get Dataset Linked Collections](#get-dataset-linked-collections)
3940
- [Datasets write use cases](#datasets-write-use-cases)
4041
- [Create a Dataset](#create-a-dataset)
4142
- [Update a Dataset](#update-a-dataset)
4243
- [Publish a Dataset](#publish-a-dataset)
4344
- [Deaccession a Dataset](#deaccession-a-dataset)
4445
- [Delete a Draft Dataset](#delete-a-draft-dataset)
46+
- [Link a Dataset](#link-a-dataset)
47+
- [Unlink a Dataset](#unlink-a-dataset)
4548
- [Files](#Files)
4649
- [Files read use cases](#files-read-use-cases)
4750
- [Get a File](#get-a-file)
@@ -88,6 +91,8 @@ The different use cases currently available in the package are classified below,
8891
- [Notifications](#Notifications)
8992
- [Get All Notifications by User](#get-all-notifications-by-user)
9093
- [Delete Notification](#delete-notification)
94+
- [Search](#Search)
95+
- [Get Search Services](#get-search-services)
9196

9297
## Collections
9398

@@ -225,6 +230,8 @@ This use case supports the following optional parameters depending on the search
225230
- **limit**: (number) Limit for pagination.
226231
- **offset**: (number) Offset for pagination.
227232
- **collectionSearchCriteria**: ([CollectionSearchCriteria](../src/collections/domain/models/CollectionSearchCriteria.ts)) Supports filtering the collection items by different properties.
233+
- **searchServiceName**: The search service name on which to execute the search (Optional).
234+
- **showTypeCounts**: If true, the response will include the count per object type (Optional).
228235

229236
#### List My Data Collection Items
230237

@@ -560,6 +567,37 @@ The `datasetId` parameter can be a string, for persistent identifiers, or a numb
560567

561568
There is an optional third parameter called `includeDeaccessioned`, which indicates whether to consider deaccessioned versions or not in the dataset search. If not set, the default value is `false`.
562569

570+
#### Get Dataset Citation In Other Formats
571+
572+
Retrieves the citation for a dataset in a specified bibliographic format.
573+
574+
##### Example call:
575+
576+
```typescript
577+
import { getDatasetCitationInOtherFormats } from '@iqss/dataverse-client-javascript'
578+
579+
/* ... */
580+
581+
const datasetId = 2
582+
const datasetVersionId = '1.0'
583+
584+
getDatasetCitationInOtherFormats
585+
.execute(datasetId, datasetVersionId, format)
586+
.then((citationText: FormattedCitation) => {
587+
/* ... */
588+
})
589+
590+
/* ... */
591+
```
592+
593+
_See [use case](../src/datasets/domain/useCases/GetDatasetCitationInOtherFormats.ts) implementation_.
594+
595+
Supported formats include 'EndNote' (XML), 'RIS' (plain text), 'BibTeX' (plain text), 'CSLJson' (JSON), and 'Internal' (HTML). The response contains the raw citation content in the requested format, the format type, and the content type (MIME type).
596+
597+
The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
598+
599+
There is an optional third parameter called `includeDeaccessioned`, which indicates whether to consider deaccessioned versions or not in the dataset search. If not set, the default value is `false`.
600+
563601
#### Get Dataset Citation Text By Private URL Token
564602

565603
Returns the Dataset citation text, given an associated Private URL Token.
@@ -738,6 +776,30 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetVersionsSummaries.ts)
738776

739777
The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
740778

779+
#### Get Dataset Linked Collections
780+
781+
Returns an array of [DatasetLinkedCollection](../src/datasets/domain/models/DatasetLinkedCollection.ts) that contains the collections linked to a dataset.
782+
783+
##### Example call:
784+
785+
```typescript
786+
import { getDatasetLinkedCollections } from '@iqss/dataverse-client-javascript'
787+
788+
/* ... */
789+
790+
const datasetId = 'doi:10.77777/FK2/AAAAAA'
791+
792+
getDatasetLinkedCollections
793+
.execute(datasetId)
794+
.then((datasetLinkedCollections: DatasetLinkedCollection[]) => {
795+
/* ... */
796+
})
797+
798+
/* ... */
799+
```
800+
801+
_See [use case](../src/datasets/domain/useCases/GetDatasetLinkedCollections.ts) implementation_.
802+
741803
### Datasets Write Use Cases
742804

743805
#### Create a Dataset
@@ -947,6 +1009,48 @@ The `datasetId` parameter is a number for numeric identifiers or string for pers
9471009

9481010
If you try to delete a dataset without draft version, you will get a not found error.
9491011

1012+
#### Link a Dataset
1013+
1014+
Creates a link between a Dataset and a Collection.
1015+
1016+
##### Example call:
1017+
1018+
```typescript
1019+
import { linkDataset } from '@iqss/dataverse-client-javascript'
1020+
1021+
/* ... */
1022+
1023+
const datasetId = 1
1024+
const collectionAlias = 'collection-alias'
1025+
1026+
linkDataset.execute(datasetId, collectionAlias)
1027+
1028+
/* ... */
1029+
```
1030+
1031+
_See [use case](../src/datasets/domain/useCases/LinkDataset.ts) implementation_.
1032+
1033+
#### Unlink a Dataset
1034+
1035+
Removes a link between a Dataset and a Collection.
1036+
1037+
##### Example call:
1038+
1039+
```typescript
1040+
import { unlinkDataset } from '@iqss/dataverse-client-javascript'
1041+
1042+
/* ... */
1043+
1044+
const datasetId = 1
1045+
const collectionAlias = 'collection-alias'
1046+
1047+
unlinkDataset.execute(datasetId, collectionAlias)
1048+
1049+
/* ... */
1050+
```
1051+
1052+
_See [use case](../src/datasets/domain/useCases/UnlinkDataset.ts) implementation_.
1053+
9501054
#### Get Download Count of a Dataset
9511055

9521056
Total number of downloads requested for a dataset, given a dataset numeric identifier,
@@ -2038,3 +2142,25 @@ deleteNotification.execute(notificationId: number).then(() => {
20382142
```
20392143

20402144
_See [use case](../src/notifications/domain/useCases/DeleteNotification.ts) implementation_.
2145+
2146+
## Search
2147+
2148+
#### Get Search Services
2149+
2150+
Returns all [Search Services](../src/search/domain/models/SearchService.ts) available in the installation.
2151+
2152+
##### Example call:
2153+
2154+
```typescript
2155+
import { getSearchServices } from '@iqss/dataverse-client-javascript'
2156+
2157+
/* ... */
2158+
2159+
getSearchServices.execute().then((searchServices: SearchService[]) => {
2160+
/* ... */
2161+
})
2162+
2163+
/* ... */
2164+
```
2165+
2166+
_See [use case](../src/search/domain/useCases/GetSearchServices.ts) implementation_.

src/collections/domain/repositories/ICollectionsRepository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface ICollectionsRepository {
2727
limit?: number,
2828
offset?: number,
2929
collectionSearchCriteria?: CollectionSearchCriteria,
30+
searchServiceName?: string,
3031
showTypeCounts?: boolean
3132
): Promise<CollectionItemSubset>
3233
getMyDataCollectionItems(

src/collections/domain/useCases/GetCollectionItems.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class GetCollectionItems implements UseCase<CollectionItemSubset> {
1818
* @param {number} [limit] - Limit for pagination (optional).
1919
* @param {number} [offset] - Offset for pagination (optional).
2020
* @param {CollectionSearchCriteria} [collectionSearchCriteria] - Supports filtering the collection items by different properties (optional).
21+
* @param {string} [searchServiceName] - The search service name on which to execute the search (optional).
2122
* @param {boolean} [showTypeCounts] - If true, the response will include the count per object type (optional).
2223
* @returns {Promise<CollectionItemSubset>}
2324
*/
@@ -26,13 +27,15 @@ export class GetCollectionItems implements UseCase<CollectionItemSubset> {
2627
limit?: number,
2728
offset?: number,
2829
collectionSearchCriteria?: CollectionSearchCriteria,
30+
searchServiceName?: string,
2931
showTypeCounts = false
3032
): Promise<CollectionItemSubset> {
3133
return await this.collectionsRepository.getCollectionItems(
3234
collectionId,
3335
limit,
3436
offset,
3537
collectionSearchCriteria,
38+
searchServiceName,
3639
showTypeCounts
3740
)
3841
}

src/collections/infra/repositories/CollectionsRepository.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export enum GetCollectionItemsQueryParams {
7575
START = 'start',
7676
TYPE = 'type',
7777
FILTERQUERY = 'fq',
78-
SHOW_TYPE_COUNTS = 'show_type_counts'
78+
SHOW_TYPE_COUNTS = 'show_type_counts',
79+
SEARCH_SERVICE_NAME = 'search_service'
7980
}
8081

8182
export enum GetMyDataCollectionItemsQueryParams {
@@ -168,6 +169,7 @@ export class CollectionsRepository extends ApiRepository implements ICollections
168169
limit?: number,
169170
offset?: number,
170171
collectionSearchCriteria?: CollectionSearchCriteria,
172+
searchServiceName?: string,
171173
showTypeCounts?: boolean
172174
): Promise<CollectionItemSubset> {
173175
const queryParams = new URLSearchParams({
@@ -193,6 +195,10 @@ export class CollectionsRepository extends ApiRepository implements ICollections
193195
queryParams.set(GetCollectionItemsQueryParams.SHOW_TYPE_COUNTS, 'true')
194196
}
195197

198+
if (searchServiceName) {
199+
queryParams.set(GetCollectionItemsQueryParams.SEARCH_SERVICE_NAME, searchServiceName)
200+
}
201+
196202
if (collectionSearchCriteria) {
197203
this.applyCollectionSearchCriteriaToQueryParams(queryParams, collectionSearchCriteria)
198204
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export enum CitationFormat {
2+
Internal = 'Internal',
3+
EndNote = 'EndNote',
4+
RIS = 'RIS',
5+
BibTeX = 'BibTeX',
6+
CSLJson = 'CSL'
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface DatasetLinkedCollection {
2+
id: number
3+
alias: string
4+
displayName: string
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type FormattedCitation = {
2+
content: string
3+
contentType: string
4+
}

src/datasets/domain/repositories/IDatasetsRepository.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { MetadataBlock } from '../../../metadataBlocks'
99
import { DatasetVersionDiff } from '../models/DatasetVersionDiff'
1010
import { DatasetDownloadCount } from '../models/DatasetDownloadCount'
1111
import { DatasetVersionSummaryInfo } from '../models/DatasetVersionSummaryInfo'
12+
import { DatasetLinkedCollection } from '../models/DatasetLinkedCollection'
13+
import { CitationFormat } from '../models/CitationFormat'
14+
import { FormattedCitation } from '../models/FormattedCitation'
1215

1316
export interface IDatasetsRepository {
1417
getDataset(
@@ -61,4 +64,13 @@ export interface IDatasetsRepository {
6164
): Promise<DatasetDownloadCount>
6265
getDatasetVersionsSummaries(datasetId: number | string): Promise<DatasetVersionSummaryInfo[]>
6366
deleteDatasetDraft(datasetId: number | string): Promise<void>
67+
linkDataset(datasetId: number, collectionAlias: string): Promise<void>
68+
unlinkDataset(datasetId: number, collectionAlias: string): Promise<void>
69+
getDatasetLinkedCollections(datasetId: number | string): Promise<DatasetLinkedCollection[]>
70+
getDatasetCitationInOtherFormats(
71+
datasetId: number | string,
72+
datasetVersionId: string,
73+
format: CitationFormat,
74+
includeDeaccessioned?: boolean
75+
): Promise<FormattedCitation>
6476
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { UseCase } from '../../../core/domain/useCases/UseCase'
2+
import { IDatasetsRepository } from '../repositories/IDatasetsRepository'
3+
import { DatasetNotNumberedVersion } from '../models/DatasetNotNumberedVersion'
4+
import { FormattedCitation } from '../models/FormattedCitation'
5+
import { CitationFormat } from '../models/CitationFormat'
6+
7+
export class GetDatasetCitationInOtherFormats implements UseCase<FormattedCitation> {
8+
private datasetsRepository: IDatasetsRepository
9+
10+
constructor(datasetsRepository: IDatasetsRepository) {
11+
this.datasetsRepository = datasetsRepository
12+
}
13+
14+
/**
15+
* Returns the dataset citation in the specified format.
16+
*
17+
* @param {number | string} datasetId - The dataset identifier.
18+
* @param {string | DatasetNotNumberedVersion} [datasetVersionId=DatasetNotNumberedVersion.LATEST] - The dataset version identifier, which can be a version-specific string (e.g., '1.0') or a DatasetNotNumberedVersion enum value. Defaults to LATEST.
19+
* @param {CitationFormat} format - The citation format to return. One of: 'EndNote', 'RIS', 'BibTeX', 'CSLJson', 'Internal'.
20+
* @param {boolean} [includeDeaccessioned=false] - Whether to include deaccessioned versions in the search. Defaults to false.
21+
* @returns {Promise<FormattedCitation>} The citation content, format, and content type.
22+
*/
23+
async execute(
24+
datasetId: number | string,
25+
datasetVersionId: string | DatasetNotNumberedVersion = DatasetNotNumberedVersion.LATEST,
26+
format: CitationFormat,
27+
includeDeaccessioned = false
28+
): Promise<FormattedCitation> {
29+
return await this.datasetsRepository.getDatasetCitationInOtherFormats(
30+
datasetId,
31+
datasetVersionId,
32+
format,
33+
includeDeaccessioned
34+
)
35+
}
36+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { UseCase } from '../../../core/domain/useCases/UseCase'
2+
import { DatasetLinkedCollection } from '../models/DatasetLinkedCollection'
3+
import { IDatasetsRepository } from '../repositories/IDatasetsRepository'
4+
5+
export class GetDatasetLinkedCollections implements UseCase<DatasetLinkedCollection[]> {
6+
private datasetsRepository: IDatasetsRepository
7+
8+
constructor(datasetsRepository: IDatasetsRepository) {
9+
this.datasetsRepository = datasetsRepository
10+
}
11+
12+
/**
13+
* Returns a list of collections linked to a dataset.
14+
*
15+
* @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers).
16+
* @returns {Promise<DatasetLinkedCollection[]>}
17+
*/
18+
async execute(datasetId: number | string): Promise<DatasetLinkedCollection[]> {
19+
return await this.datasetsRepository.getDatasetLinkedCollections(datasetId)
20+
}
21+
}

0 commit comments

Comments
 (0)