Skip to content

Commit 8387b4e

Browse files
committed
docs: add use case docs
1 parent 5695023 commit 8387b4e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

docs/useCases.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The different use cases currently available in the package are classified below,
1616
- [List All Collection Items](#list-all-collection-items)
1717
- [List My Data Collection Items](#list-my-data-collection-items)
1818
- [Get Collection Featured Items](#get-collection-featured-items)
19+
- [Get Collections for Linking](#get-collections-for-linking)
1920
- [Collections write use cases](#collections-write-use-cases)
2021
- [Create a Collection](#create-a-collection)
2122
- [Update a Collection](#update-a-collection)
@@ -324,6 +325,56 @@ The `collectionIdOrAlias` is a generic collection identifier, which can be eithe
324325

325326
If no collection identifier is specified, the default collection identifier; `:root` will be used. If you want to search for a different collection, you must add the collection identifier as a parameter in the use case call.
326327

328+
#### Get Collections for Linking
329+
330+
Returns an array of [CollectionSummary](../src/collections/domain/models/CollectionSummary.ts) (id, alias, displayName) representing the Dataverse collections to which a given Dataverse collection or Dataset may be linked.
331+
332+
This use case supports an optional `searchTerm` to filter by collection name.
333+
334+
##### Example calls:
335+
336+
```typescript
337+
import { getCollectionsForLinking } from '@iqss/dataverse-client-javascript'
338+
339+
/* ... */
340+
341+
// Case 1: For a given Dataverse collection (by numeric id or alias)
342+
const collectionIdOrAlias: number | string = 'collectionAlias' // or 123
343+
const searchTerm = 'searchOn'
344+
345+
getCollectionsForLinking
346+
.execute('dataverse', collectionIdOrAlias, searchTerm)
347+
.then((collections) => {
348+
// collections: CollectionSummary[]
349+
/* ... */
350+
})
351+
.catch((error: Error) => {
352+
/* ... */
353+
})
354+
355+
/* ... */
356+
357+
// Case 2: For a given Dataset (by persistent identifier)
358+
const persistentId = 'doi:10.5072/FK2/J8SJZB'
359+
360+
getCollectionsForLinking
361+
.execute('dataset', persistentId, searchTerm)
362+
.then((collections) => {
363+
// collections: CollectionSummary[]
364+
/* ... */
365+
})
366+
.catch((error: Error) => {
367+
/* ... */
368+
})
369+
```
370+
371+
_See [use case](../src/collections/domain/useCases/GetCollectionsForLinking.ts) implementation_.
372+
373+
Notes:
374+
375+
- When the first argument is `'collection'`, the second argument can be a numeric collection id or a collection alias.
376+
- When the first argument is `'dataset'`, the second argument must be the dataset persistent identifier string (e.g., `doi:...`).
377+
327378
### Collections Write Use Cases
328379

329380
#### Create a Collection

0 commit comments

Comments
 (0)