mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
add docs, rename classes for clarity
This commit is contained in:
@@ -41,20 +41,20 @@ import { NotificationOptions } from '../../shared/notifications/models/notificat
|
||||
import { DSpaceRESTv2Serializer } from '../dspace-rest-v2/dspace-rest-v2.serializer';
|
||||
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
||||
import { DataBuildService } from '../cache/builders/data-build.service';
|
||||
import { UpdateComparator } from './update-comparator';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
|
||||
export abstract class DataService<TNormalized extends NormalizedObject, TDomain extends CacheableObject> {
|
||||
protected abstract requestService: RequestService;
|
||||
protected abstract rdbService: RemoteDataBuildService;
|
||||
protected abstract dataBuildService: DataBuildService;
|
||||
protected abstract dataBuildService: NormalizedObjectBuildService;
|
||||
protected abstract store: Store<CoreState>;
|
||||
protected abstract linkPath: string;
|
||||
protected abstract halService: HALEndpointService;
|
||||
protected abstract objectCache: ObjectCacheService;
|
||||
protected abstract notificationsService: NotificationsService;
|
||||
protected abstract http: HttpClient;
|
||||
protected abstract comparator: UpdateComparator<TNormalized>;
|
||||
protected abstract comparator: ChangeAnalyzer<TNormalized>;
|
||||
|
||||
public abstract getBrowseEndpoint(options: FindAllOptions, linkPath?: string): Observable<string>
|
||||
|
||||
@@ -138,7 +138,7 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain
|
||||
const oldVersion$ = this.objectCache.getBySelfLink(object.self);
|
||||
return oldVersion$.pipe(first(), mergeMap((oldVersion: TNormalized) => {
|
||||
const newVersion = this.dataBuildService.normalize<TDomain, TNormalized>(object);
|
||||
const operations = this.comparator.compare(oldVersion, newVersion);
|
||||
const operations = this.comparator.diff(oldVersion, newVersion);
|
||||
if (isNotEmpty(operations)) {
|
||||
this.objectCache.addPatch(object.self, operations);
|
||||
}
|
||||
@@ -148,6 +148,15 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DSpaceObject on the server, and store the response
|
||||
* in the object cache
|
||||
*
|
||||
* @param {DSpaceObject} dso
|
||||
* The object to create
|
||||
* @param {string} parentUUID
|
||||
* The UUID of the parent to create the new object under
|
||||
*/
|
||||
create(dso: TDomain, parentUUID: string): Observable<RemoteData<TDomain>> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
const endpoint$ = this.halService.getEndpoint(this.linkPath).pipe(
|
||||
|
Reference in New Issue
Block a user