workflowitem-data.service.ts (dspace-angular-dspace-7.0) | : | workflowitem-data.service.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
import { HttpClient } from '@angular/common/http'; | import { HttpClient } from '@angular/common/http'; | |||
import { Store } from '@ngrx/store'; | import { Store } from '@ngrx/store'; | |||
import { dataService } from '../cache/builders/build-decorators'; | import { dataService } from '../cache/builders/build-decorators'; | |||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.serv ice'; | import { RemoteDataBuildService } from '../cache/builders/remote-data-build.serv ice'; | |||
import { CoreState } from '../core.reducers'; | import { CoreState } from '../core.reducers'; | |||
import { DataService } from '../data/data.service'; | import { DataService } from '../data/data.service'; | |||
import { RequestService } from '../data/request.service'; | import { RequestService } from '../data/request.service'; | |||
import { WorkflowItem } from './models/workflowitem.model'; | import { WorkflowItem } from './models/workflowitem.model'; | |||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | import { HALEndpointService } from '../shared/hal-endpoint.service'; | |||
import { DeleteByIDRequest } from '../data/request.models'; | import { DeleteByIDRequest, FindListOptions } from '../data/request.models'; | |||
import { NotificationsService } from '../../shared/notifications/notifications.s ervice'; | import { NotificationsService } from '../../shared/notifications/notifications.s ervice'; | |||
import { ObjectCacheService } from '../cache/object-cache.service'; | import { ObjectCacheService } from '../cache/object-cache.service'; | |||
import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service'; | import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service'; | |||
import { Observable } from 'rxjs'; | import { Observable } from 'rxjs'; | |||
import { find, map } from 'rxjs/operators'; | import { find, map } from 'rxjs/operators'; | |||
import { hasValue } from '../../shared/empty.util'; | import { hasValue } from '../../shared/empty.util'; | |||
import { RemoteData } from '../data/remote-data'; | import { RemoteData } from '../data/remote-data'; | |||
import { NoContent } from '../shared/NoContent.model'; | import { NoContent } from '../shared/NoContent.model'; | |||
import { getFirstCompletedRemoteData } from '../shared/operators'; | import { getFirstCompletedRemoteData } from '../shared/operators'; | |||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; | ||||
import { WorkspaceItem } from './models/workspaceitem.model'; | ||||
import { RequestParam } from '../cache/models/request-param.model'; | ||||
/** | /** | |||
* A service that provides methods to make REST requests with workflow items end point. | * A service that provides methods to make REST requests with workflow items end point. | |||
*/ | */ | |||
@Injectable() | @Injectable() | |||
@dataService(WorkflowItem.type) | @dataService(WorkflowItem.type) | |||
export class WorkflowItemDataService extends DataService<WorkflowItem> { | export class WorkflowItemDataService extends DataService<WorkflowItem> { | |||
protected linkPath = 'workflowitems'; | protected linkPath = 'workflowitems'; | |||
protected searchByItemLinkPath = 'item'; | ||||
protected responseMsToLive = 10 * 1000; | protected responseMsToLive = 10 * 1000; | |||
constructor( | constructor( | |||
protected comparator: DSOChangeAnalyzer<WorkflowItem>, | protected comparator: DSOChangeAnalyzer<WorkflowItem>, | |||
protected halService: HALEndpointService, | protected halService: HALEndpointService, | |||
protected http: HttpClient, | protected http: HttpClient, | |||
protected notificationsService: NotificationsService, | protected notificationsService: NotificationsService, | |||
protected requestService: RequestService, | protected requestService: RequestService, | |||
protected rdbService: RemoteDataBuildService, | protected rdbService: RemoteDataBuildService, | |||
protected objectCache: ObjectCacheService, | protected objectCache: ObjectCacheService, | |||
skipping to change at line 89 | skipping to change at line 93 | |||
hrefObs.pipe( | hrefObs.pipe( | |||
find((href: string) => hasValue(href)), | find((href: string) => hasValue(href)), | |||
).subscribe((href: string) => { | ).subscribe((href: string) => { | |||
const request = new DeleteByIDRequest(requestId, href, id); | const request = new DeleteByIDRequest(requestId, href, id); | |||
this.requestService.send(request); | this.requestService.send(request); | |||
}); | }); | |||
return this.rdbService.buildFromRequestUUID(requestId); | return this.rdbService.buildFromRequestUUID(requestId); | |||
} | } | |||
/** | ||||
* Return the WorkflowItem object found through the UUID of an item | ||||
* | ||||
* @param uuid The uuid of the item | ||||
* @param useCachedVersionIfAvailable If this is true, the request will only b | ||||
e sent if there's | ||||
* no valid cached version. Defaults to tru | ||||
e | ||||
* @param reRequestOnStale Whether or not the request should automa | ||||
tically be re- | ||||
* requested after the response becomes sta | ||||
le | ||||
* @param options The {@link FindListOptions} object | ||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which | ||||
{@link HALLink}s should be automatically resolved | ||||
*/ | ||||
public findByItem(uuid: string, useCachedVersionIfAvailable = false, reRequest | ||||
OnStale = true, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfi | ||||
g<WorkspaceItem>[]): Observable<RemoteData<WorkspaceItem>> { | ||||
const findListOptions = new FindListOptions(); | ||||
findListOptions.searchParams = [new RequestParam('uuid', encodeURIComponent( | ||||
uuid))]; | ||||
const href$ = this.getSearchByHref(this.searchByItemLinkPath, findListOption | ||||
s, ...linksToFollow); | ||||
return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, | ||||
...linksToFollow); | ||||
} | ||||
} | } | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 34 lines changed or added |