add docs, rename classes for clarity

This commit is contained in:
Art Lowel
2019-01-17 14:59:48 +01:00
parent e387f9446f
commit 586a4ac35b
23 changed files with 186 additions and 77 deletions

View File

@@ -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(