forked from hazza/dspace-angular
Cache redesign part 1, and add support for alternative links
This commit is contained in:
@@ -3,7 +3,6 @@ import { of as observableOf, Observable } from 'rxjs';
|
||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||
import { SubmissionService } from '../../submission/submission.service';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { RemoteDataError } from '../data/remote-data-error';
|
||||
import { SubmissionObject } from './models/submission-object.model';
|
||||
import { SubmissionScopeType } from './submission-scope-type';
|
||||
import { WorkflowItemDataService } from './workflowitem-data.service';
|
||||
@@ -11,6 +10,8 @@ import { WorkspaceitemDataService } from './workspaceitem-data.service';
|
||||
import { DataService } from '../data/data.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { RequestEntryState } from '../data/request.reducer';
|
||||
|
||||
/**
|
||||
* A service to retrieve submission objects (WorkspaceItem/WorkflowItem)
|
||||
@@ -42,22 +43,28 @@ export class SubmissionObjectDataService {
|
||||
/**
|
||||
* Retrieve a submission object based on its ID.
|
||||
*
|
||||
* @param id The identifier of a submission object
|
||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||
* @param id The identifier of a submission object
|
||||
* @param reRequestOnStale Whether or not the request should automatically be re-requested after
|
||||
* the response becomes stale
|
||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||
*/
|
||||
findById(id: string, ...linksToFollow: Array<FollowLinkConfig<SubmissionObject>>): Observable<RemoteData<SubmissionObject>> {
|
||||
findById(id: string, reRequestOnStale = true, ...linksToFollow: Array<FollowLinkConfig<SubmissionObject>>): Observable<RemoteData<SubmissionObject>> {
|
||||
switch (this.submissionService.getSubmissionScope()) {
|
||||
case SubmissionScopeType.WorkspaceItem:
|
||||
return this.workspaceitemDataService.findById(id,...linksToFollow);
|
||||
return this.workspaceitemDataService.findById(id, reRequestOnStale,...linksToFollow);
|
||||
case SubmissionScopeType.WorkflowItem:
|
||||
return this.workflowItemDataService.findById(id,...linksToFollow);
|
||||
return this.workflowItemDataService.findById(id, reRequestOnStale,...linksToFollow);
|
||||
default:
|
||||
const error = new RemoteDataError(
|
||||
const now = new Date().getTime();
|
||||
return observableOf(new RemoteData(
|
||||
now,
|
||||
environment.cache.msToLive.default,
|
||||
now,
|
||||
RequestEntryState.Error,
|
||||
'The request couldn\'t be sent. Unable to determine the type of submission object',
|
||||
undefined,
|
||||
undefined,
|
||||
'The request couldn\'t be sent. Unable to determine the type of submission object'
|
||||
);
|
||||
return observableOf(new RemoteData(false, false, false, error, undefined));
|
||||
400
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user