Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
277 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { Observable } from 'rxjs'; | ||
import { ProcessOutput } from '../../process-page/processes/process-output.model'; | ||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; | ||
import { dataService } from '../cache/builders/build-decorators'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { CoreState } from '../core.reducers'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { PROCESS_OUTPUT_TYPE } from '../shared/process-output.resource-type'; | ||
import { DataService } from './data.service'; | ||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service'; | ||
import { RemoteData } from './remote-data'; | ||
import { RequestService } from './request.service'; | ||
|
||
/* tslint:disable:max-classes-per-file */ | ||
/** | ||
* A private DataService implementation to delegate specific methods to. | ||
*/ | ||
class DataServiceImpl extends DataService<ProcessOutput> { | ||
protected linkPath = 'processes'; | ||
|
||
constructor( | ||
protected requestService: RequestService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected store: Store<CoreState>, | ||
protected objectCache: ObjectCacheService, | ||
protected halService: HALEndpointService, | ||
protected notificationsService: NotificationsService, | ||
protected http: HttpClient, | ||
protected comparator: DefaultChangeAnalyzer<ProcessOutput>) { | ||
super(); | ||
} | ||
} | ||
|
||
/** | ||
* A service to retrieve output from processes from the REST API. | ||
*/ | ||
@Injectable() | ||
@dataService(PROCESS_OUTPUT_TYPE) | ||
export class ProcessOutputDataService { | ||
/** | ||
* A private DataService instance to delegate specific methods to. | ||
*/ | ||
private dataService: DataServiceImpl; | ||
|
||
constructor( | ||
protected requestService: RequestService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected store: Store<CoreState>, | ||
protected objectCache: ObjectCacheService, | ||
protected halService: HALEndpointService, | ||
protected notificationsService: NotificationsService, | ||
protected http: HttpClient, | ||
protected comparator: DefaultChangeAnalyzer<ProcessOutput>) { | ||
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator); | ||
} | ||
|
||
/** | ||
* Returns an observable of {@link RemoteData} of a {@link ProcessOutput}, based on an href, with a list of {@link FollowLinkConfig}, | ||
* to automatically resolve {@link HALLink}s of the {@link ProcessOutput} | ||
* @param href The url of {@link ProcessOutput} we want to retrieve | ||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved | ||
*/ | ||
findByHref(href: string, ...linksToFollow: Array<FollowLinkConfig<ProcessOutput>>): Observable<RemoteData<ProcessOutput>> { | ||
return this.dataService.findByHref(href, ...linksToFollow); | ||
} | ||
} | ||
/* tslint:enable:max-classes-per-file */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ResourceType } from './resource-type'; | ||
|
||
/** | ||
* The resource type for ProcessOutput | ||
* | ||
* Needs to be in a separate file to prevent circular | ||
* dependencies in webpack. | ||
*/ | ||
export const PROCESS_OUTPUT_TYPE = new ResourceType('processOutput'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.