collection-data.service.ts (dspace-angular-dspace-7.0) | : | collection-data.service.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
import { COLLECTION } from '../shared/collection.resource-type'; | import { COLLECTION } from '../shared/collection.resource-type'; | |||
import { ContentSource } from '../shared/content-source.model'; | import { ContentSource } from '../shared/content-source.model'; | |||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | import { HALEndpointService } from '../shared/hal-endpoint.service'; | |||
import { Item } from '../shared/item.model'; | import { Item } from '../shared/item.model'; | |||
import { getFirstCompletedRemoteData } from '../shared/operators'; | import { getFirstCompletedRemoteData } from '../shared/operators'; | |||
import { ComColDataService } from './comcol-data.service'; | import { ComColDataService } from './comcol-data.service'; | |||
import { CommunityDataService } from './community-data.service'; | import { CommunityDataService } from './community-data.service'; | |||
import { DSOChangeAnalyzer } from './dso-change-analyzer.service'; | import { DSOChangeAnalyzer } from './dso-change-analyzer.service'; | |||
import { PaginatedList } from './paginated-list.model'; | import { PaginatedList } from './paginated-list.model'; | |||
import { RemoteData } from './remote-data'; | import { RemoteData } from './remote-data'; | |||
import { | import { ContentSourceRequest, FindListOptions, RestRequest, UpdateContentSource | |||
ContentSourceRequest, | Request } from './request.models'; | |||
FindListOptions, | ||||
UpdateContentSourceRequest, | ||||
RestRequest | ||||
} from './request.models'; | ||||
import { RequestService } from './request.service'; | import { RequestService } from './request.service'; | |||
import { BitstreamDataService } from './bitstream-data.service'; | import { BitstreamDataService } from './bitstream-data.service'; | |||
@Injectable() | @Injectable() | |||
@dataService(COLLECTION) | @dataService(COLLECTION) | |||
export class CollectionDataService extends ComColDataService<Collection> { | export class CollectionDataService extends ComColDataService<Collection> { | |||
protected linkPath = 'collections'; | protected linkPath = 'collections'; | |||
protected errorTitle = 'collection.source.update.notifications.error.title'; | protected errorTitle = 'collection.source.update.notifications.error.title'; | |||
protected contentSourceError = 'collection.source.update.notifications.error.c ontent'; | protected contentSourceError = 'collection.source.update.notifications.error.c ontent'; | |||
skipping to change at line 88 | skipping to change at line 83 | |||
const searchHref = 'findSubmitAuthorized'; | const searchHref = 'findSubmitAuthorized'; | |||
options = Object.assign({}, options, { | options = Object.assign({}, options, { | |||
searchParams: [new RequestParam('query', query)] | searchParams: [new RequestParam('query', query)] | |||
}); | }); | |||
return this.searchBy(searchHref, options, useCachedVersionIfAvailable, reReq uestOnStale, ...linksToFollow).pipe( | return this.searchBy(searchHref, options, useCachedVersionIfAvailable, reReq uestOnStale, ...linksToFollow).pipe( | |||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collection s.isResponsePending)); | filter((collections: RemoteData<PaginatedList<Collection>>) => !collection s.isResponsePending)); | |||
} | } | |||
/** | /** | |||
* Get all collections the user is authorized to submit to | ||||
* | ||||
* @param query limit the returned collection to those with metadata values ma | ||||
tching the query terms. | ||||
* @param entityType The entity type used to limit the returned collection | ||||
* @param options The [[FindListOptions]] object | ||||
* @param reRequestOnStale Whether or not the request should automatically be | ||||
re-requested after | ||||
* the response becomes stale | ||||
* @param linksToFollow The array of [[FollowLinkConfig]] | ||||
* @return Observable<RemoteData<PaginatedList<Collection>>> | ||||
* collection list | ||||
*/ | ||||
getAuthorizedCollectionByEntityType( | ||||
query: string, | ||||
entityType: string, | ||||
options: FindListOptions = {}, | ||||
reRequestOnStale = true, | ||||
...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<Pag | ||||
inatedList<Collection>>> { | ||||
const searchHref = 'findSubmitAuthorizedByEntityType'; | ||||
options = Object.assign({}, options, { | ||||
searchParams: [ | ||||
new RequestParam('query', query), | ||||
new RequestParam('entityType', entityType) | ||||
] | ||||
}); | ||||
return this.searchBy(searchHref, options, true, reRequestOnStale, ...linksTo | ||||
Follow).pipe( | ||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collection | ||||
s.isResponsePending)); | ||||
} | ||||
/** | ||||
* Get all collections the user is authorized to submit to, by community | * Get all collections the user is authorized to submit to, by community | |||
* | * | |||
* @param communityId The community id | * @param communityId The community id | |||
* @param query limit the returned collection to those with metadata values ma tching the query terms. | * @param query limit the returned collection to those with metadata values ma tching the query terms. | |||
* @param options The [[FindListOptions]] object | * @param options The [[FindListOptions]] object | |||
* @param reRequestOnStale Whether or not the request should automatically be | ||||
re- | ||||
* requested after the response becomes stale | ||||
* @return Observable<RemoteData<PaginatedList<Collection>>> | * @return Observable<RemoteData<PaginatedList<Collection>>> | |||
* collection list | * collection list | |||
*/ | */ | |||
getAuthorizedCollectionByCommunity(communityId: string, query: string, options : FindListOptions = {}): Observable<RemoteData<PaginatedList<Collection>>> { | getAuthorizedCollectionByCommunity(communityId: string, query: string, options : FindListOptions = {}, reRequestOnStale = true,): Observable<RemoteData<Paginat edList<Collection>>> { | |||
const searchHref = 'findSubmitAuthorizedByCommunity'; | const searchHref = 'findSubmitAuthorizedByCommunity'; | |||
options = Object.assign({}, options, { | options = Object.assign({}, options, { | |||
searchParams: [ | searchParams: [ | |||
new RequestParam('uuid', communityId), | new RequestParam('uuid', communityId), | |||
new RequestParam('query', query) | new RequestParam('query', query) | |||
] | ] | |||
}); | }); | |||
return this.searchBy(searchHref, options).pipe( | return this.searchBy(searchHref, options, reRequestOnStale).pipe( | |||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collection | ||||
s.isResponsePending)); | ||||
} | ||||
/** | ||||
* Get all collections the user is authorized to submit to, by community and h | ||||
as the metadata | ||||
* | ||||
* @param communityId The community id | ||||
* @param entityType The entity type used to limit the returned collection | ||||
* @param options The [[FindListOptions]] object | ||||
* @param reRequestOnStale Whether or not the request should automatically be | ||||
re-requested after | ||||
* the response becomes stale | ||||
* @param linksToFollow The array of [[FollowLinkConfig]] | ||||
* @return Observable<RemoteData<PaginatedList<Collection>>> | ||||
* collection list | ||||
*/ | ||||
getAuthorizedCollectionByCommunityAndEntityType( | ||||
communityId: string, | ||||
entityType: string, | ||||
options: FindListOptions = {}, | ||||
reRequestOnStale = true, | ||||
...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<Pag | ||||
inatedList<Collection>>> { | ||||
const searchHref = 'findSubmitAuthorizedByCommunityAndEntityType'; | ||||
const searchParams = [ | ||||
new RequestParam('uuid', communityId), | ||||
new RequestParam('entityType', entityType) | ||||
]; | ||||
options = Object.assign({}, options, { | ||||
searchParams: searchParams | ||||
}); | ||||
return this.searchBy(searchHref, options, true, reRequestOnStale, ...linksTo | ||||
Follow).pipe( | ||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collection s.isResponsePending)); | filter((collections: RemoteData<PaginatedList<Collection>>) => !collection s.isResponsePending)); | |||
} | } | |||
/** | /** | |||
* Find whether there is a collection whom user has authorization to submit to | * Find whether there is a collection whom user has authorization to submit to | |||
* | * | |||
* @return boolean | * @return boolean | |||
* true if the user has at least one collection to submit to | * true if the user has at least one collection to submit to | |||
*/ | */ | |||
hasAuthorizedCollection(): Observable<boolean> { | hasAuthorizedCollection(): Observable<boolean> { | |||
skipping to change at line 141 | skipping to change at line 199 | |||
getHarvesterEndpoint(collectionId: string): Observable<string> { | getHarvesterEndpoint(collectionId: string): Observable<string> { | |||
return this.halService.getEndpoint(this.linkPath).pipe( | return this.halService.getEndpoint(this.linkPath).pipe( | |||
switchMap((href: string) => this.halService.getEndpoint('harvester', `${hr ef}/${collectionId}`)) | switchMap((href: string) => this.halService.getEndpoint('harvester', `${hr ef}/${collectionId}`)) | |||
); | ); | |||
} | } | |||
/** | /** | |||
* Get the collection's content harvester | * Get the collection's content harvester | |||
* @param collectionId | * @param collectionId | |||
*/ | */ | |||
getContentSource(collectionId: string): Observable<RemoteData<ContentSource>> { | getContentSource(collectionId: string, useCachedVersionIfAvailable = true): Ob servable<RemoteData<ContentSource>> { | |||
const href$ = this.getHarvesterEndpoint(collectionId).pipe( | const href$ = this.getHarvesterEndpoint(collectionId).pipe( | |||
isNotEmptyOperator(), | isNotEmptyOperator(), | |||
take(1) | take(1) | |||
); | ); | |||
href$.subscribe((href: string) => { | href$.subscribe((href: string) => { | |||
const request = new ContentSourceRequest(this.requestService.generateReque stId(), href); | const request = new ContentSourceRequest(this.requestService.generateReque stId(), href); | |||
this.requestService.send(request, true); | this.requestService.send(request, useCachedVersionIfAvailable); | |||
}); | }); | |||
return this.rdbService.buildSingle<ContentSource>(href$); | return this.rdbService.buildSingle<ContentSource>(href$); | |||
} | } | |||
/** | /** | |||
* Update the settings of the collection's content harvester | * Update the settings of the collection's content harvester | |||
* @param collectionId | * @param collectionId | |||
* @param contentSource | * @param contentSource | |||
*/ | */ | |||
skipping to change at line 211 | skipping to change at line 269 | |||
} | } | |||
protected getFindByParentHref(parentUUID: string): Observable<string> { | protected getFindByParentHref(parentUUID: string): Observable<string> { | |||
return this.halService.getEndpoint('communities').pipe( | return this.halService.getEndpoint('communities').pipe( | |||
switchMap((communityEndpointHref: string) => | switchMap((communityEndpointHref: string) => | |||
this.halService.getEndpoint('collections', `${communityEndpointHref}/${p arentUUID}`)), | this.halService.getEndpoint('collections', `${communityEndpointHref}/${p arentUUID}`)), | |||
); | ); | |||
} | } | |||
/** | /** | |||
* Returns {@link RemoteData} of {@link Collection} that is the owing collecti on of the given item | * Returns {@link RemoteData} of {@link Collection} that is the owning collect ion of the given item | |||
* @param item Item we want the owning collection of | * @param item Item we want the owning collection of | |||
*/ | */ | |||
findOwningCollectionFor(item: Item): Observable<RemoteData<Collection>> { | findOwningCollectionFor(item: Item): Observable<RemoteData<Collection>> { | |||
return this.findByHref(item._links.owningCollection.href); | return this.findByHref(item._links.owningCollection.href); | |||
} | } | |||
/** | ||||
* Get a list of mapped collections for the given item. | ||||
* @param item Item for which the mapped collections should be retrieved. | ||||
* @param findListOptions Pagination and search options. | ||||
*/ | ||||
findMappedCollectionsFor(item: Item, findListOptions?: FindListOptions): Obser | ||||
vable<RemoteData<PaginatedList<Collection>>> { | ||||
return this.findAllByHref(item._links.mappedCollections.href, findListOption | ||||
s); | ||||
} | ||||
} | } | |||
End of changes. 9 change blocks. | ||||
11 lines changed or deleted | 93 lines changed or added |