-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGetCollectionsForLinking.ts
More file actions
34 lines (30 loc) · 1.46 KB
/
GetCollectionsForLinking.ts
File metadata and controls
34 lines (30 loc) · 1.46 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
34
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
import { CollectionSummary } from '../models/CollectionSummary'
export type LinkingObjectType = 'collection' | 'dataset'
export class GetCollectionsForLinking implements UseCase<CollectionSummary[]> {
private collectionsRepository: ICollectionsRepository
constructor(collectionsRepository: ICollectionsRepository) {
this.collectionsRepository = collectionsRepository
}
/**
* Returns an array of CollectionSummary (id, alias, displayName) to which the given Dataverse collection or Dataset may be linked.
* @param objectType - 'collection' when providing a collection identifier/alias; 'dataset' when providing a dataset persistentId.
* @param id - For objectType 'collection', a numeric id or alias string. For 'dataset', the persistentId string (e.g., doi:...)
* @param searchTerm - Optional search term to filter by collection name. Defaults to empty string (no filtering).
* @param alreadyLinked - Optional flag. When true, returns collections currently linked (candidates to unlink). Defaults to false.
*/
async execute(
objectType: LinkingObjectType,
id: number | string,
searchTerm = '',
alreadyLinked = false
): Promise<CollectionSummary[]> {
return await this.collectionsRepository.getCollectionsForLinking(
objectType,
id,
searchTerm,
alreadyLinked
)
}
}