mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 14:33:03 +00:00
68729: Version and VersionHistory model, normalized and data-service classes
This commit is contained in:
26
src/app/core/cache/models/normalized-version-history.model.ts
vendored
Normal file
26
src/app/core/cache/models/normalized-version-history.model.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
|
||||
import { NormalizedObject } from './normalized-object.model';
|
||||
import { TypedObject } from '../object-cache.reducer';
|
||||
import { mapsTo, relationship } from '../builders/build-decorators';
|
||||
import { VersionHistory } from '../../shared/version-history.model';
|
||||
import { Version } from '../../shared/version.model';
|
||||
|
||||
/**
|
||||
* Normalized model class for a DSpace Version History
|
||||
*/
|
||||
@mapsTo(VersionHistory)
|
||||
@inheritSerialization(NormalizedObject)
|
||||
export class NormalizedVersionHistory extends NormalizedObject<VersionHistory> implements TypedObject {
|
||||
/**
|
||||
* The identifier of this Version History
|
||||
*/
|
||||
@autoserialize
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* The list of versions within this history
|
||||
*/
|
||||
@deserialize
|
||||
@relationship(Version, true)
|
||||
versions: string[];
|
||||
}
|
52
src/app/core/cache/models/normalized-version.model.ts
vendored
Normal file
52
src/app/core/cache/models/normalized-version.model.ts
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
|
||||
import { Version } from '../../shared/version.model';
|
||||
import { mapsTo, relationship } from '../builders/build-decorators';
|
||||
import { TypedObject } from '../object-cache.reducer';
|
||||
import { NormalizedObject } from './normalized-object.model';
|
||||
import { Item } from '../../shared/item.model';
|
||||
import { VersionHistory } from '../../shared/version-history.model';
|
||||
|
||||
/**
|
||||
* Normalized model class for a DSpace Version
|
||||
*/
|
||||
@mapsTo(Version)
|
||||
@inheritSerialization(NormalizedObject)
|
||||
export class NormalizedVersion extends NormalizedObject<Version> implements TypedObject {
|
||||
/**
|
||||
* The identifier of this Version
|
||||
*/
|
||||
@autoserialize
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* The version number of the version's history this version represents
|
||||
*/
|
||||
@autoserialize
|
||||
version: number;
|
||||
|
||||
/**
|
||||
* The summary for the changes made in this version
|
||||
*/
|
||||
@autoserialize
|
||||
summary: string;
|
||||
|
||||
/**
|
||||
* The Date this version was created
|
||||
*/
|
||||
@deserialize
|
||||
created: Date;
|
||||
|
||||
/**
|
||||
* The full version history this version is apart of
|
||||
*/
|
||||
@deserialize
|
||||
@relationship(VersionHistory, false)
|
||||
versionhistory: string;
|
||||
|
||||
/**
|
||||
* The item this version represents
|
||||
*/
|
||||
@deserialize
|
||||
@relationship(Item, false)
|
||||
item: string;
|
||||
}
|
@@ -142,6 +142,10 @@ import { NormalizedExternalSource } from './cache/models/normalized-external-sou
|
||||
import { NormalizedExternalSourceEntry } from './cache/models/normalized-external-source-entry.model';
|
||||
import { ExternalSourceService } from './data/external-source.service';
|
||||
import { LookupRelationService } from './data/lookup-relation.service';
|
||||
import { VersionDataService } from './data/version-data.service';
|
||||
import { NormalizedVersion } from './cache/models/normalized-version.model';
|
||||
import { NormalizedVersionHistory } from './cache/models/normalized-version-history.model';
|
||||
import { VersionHistoryDataService } from './data/version-history-data.service';
|
||||
|
||||
/**
|
||||
* When not in production, endpoint responses can be mocked for testing purposes
|
||||
@@ -257,6 +261,8 @@ const PROVIDERS = [
|
||||
RelationshipTypeService,
|
||||
ExternalSourceService,
|
||||
LookupRelationService,
|
||||
VersionDataService,
|
||||
VersionHistoryDataService,
|
||||
// register AuthInterceptor as HttpInterceptor
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
@@ -304,7 +310,9 @@ export const normalizedModels =
|
||||
NormalizedRelationshipType,
|
||||
NormalizedItemType,
|
||||
NormalizedExternalSource,
|
||||
NormalizedExternalSourceEntry
|
||||
NormalizedExternalSourceEntry,
|
||||
NormalizedVersion,
|
||||
NormalizedVersionHistory
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
40
src/app/core/data/version-data.service.ts
Normal file
40
src/app/core/data/version-data.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DataService } from './data.service';
|
||||
import { Version } from '../shared/version.model';
|
||||
import { RequestService } from './request.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
|
||||
import { FindListOptions } from './request.models';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable()
|
||||
export class VersionDataService extends DataService<Version> {
|
||||
protected linkPath = 'versions';
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DefaultChangeAnalyzer<Version>) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the endpoint for browsing versions
|
||||
*/
|
||||
getBrowseEndpoint(options: FindListOptions = {}, linkPath?: string): Observable<string> {
|
||||
return this.halService.getEndpoint(this.linkPath);
|
||||
}
|
||||
}
|
40
src/app/core/data/version-history-data.service.ts
Normal file
40
src/app/core/data/version-history-data.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { DataService } from './data.service';
|
||||
import { VersionHistory } from '../shared/version-history.model';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RequestService } from './request.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
|
||||
import { FindListOptions } from './request.models';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable()
|
||||
export class VersionHistoryDataService extends DataService<VersionHistory> {
|
||||
protected linkPath = 'versionhistories';
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DefaultChangeAnalyzer<VersionHistory>) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the endpoint for browsing versions
|
||||
*/
|
||||
getBrowseEndpoint(options: FindListOptions = {}, linkPath?: string): Observable<string> {
|
||||
return this.halService.getEndpoint(this.linkPath);
|
||||
}
|
||||
}
|
40
src/app/core/shared/version-history.model.ts
Normal file
40
src/app/core/shared/version-history.model.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
||||
import { ResourceType } from './resource-type';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { GenericConstructor } from './generic-constructor';
|
||||
import { PaginatedList } from '../data/paginated-list';
|
||||
import { Version } from './version.model';
|
||||
|
||||
/**
|
||||
* Class representing a DSpace Version History
|
||||
*/
|
||||
export class VersionHistory extends ListableObject implements CacheableObject {
|
||||
static type = new ResourceType('versionhistory');
|
||||
|
||||
/**
|
||||
* Link to itself
|
||||
*/
|
||||
@excludeFromEquals
|
||||
self: string;
|
||||
|
||||
/**
|
||||
* The identifier of this Version History
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* The list of versions within this history
|
||||
*/
|
||||
@excludeFromEquals
|
||||
versions: Observable<RemoteData<PaginatedList<Version>>>;
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
}
|
61
src/app/core/shared/version.model.ts
Normal file
61
src/app/core/shared/version.model.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { ResourceType } from './resource-type';
|
||||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
import { GenericConstructor } from './generic-constructor';
|
||||
import { Item } from './item.model';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { VersionHistory } from './version-history.model';
|
||||
|
||||
/**
|
||||
* Class representing a DSpace Version
|
||||
*/
|
||||
export class Version extends ListableObject implements CacheableObject {
|
||||
static type = new ResourceType('version');
|
||||
|
||||
/**
|
||||
* Link to itself
|
||||
*/
|
||||
@excludeFromEquals
|
||||
self: string;
|
||||
|
||||
/**
|
||||
* The identifier of this Version
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* The version number of the version's history this version represents
|
||||
*/
|
||||
version: number;
|
||||
|
||||
/**
|
||||
* The summary for the changes made in this version
|
||||
*/
|
||||
summary: string;
|
||||
|
||||
/**
|
||||
* The Date this version was created
|
||||
*/
|
||||
created: Date;
|
||||
|
||||
/**
|
||||
* The full version history this version is apart of
|
||||
*/
|
||||
@excludeFromEquals
|
||||
versionhistory: Observable<RemoteData<VersionHistory>>;
|
||||
|
||||
/**
|
||||
* The item this version represents
|
||||
*/
|
||||
@excludeFromEquals
|
||||
item: Observable<RemoteData<Item>>;
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered
|
||||
*/
|
||||
getRenderTypes(): Array<string | GenericConstructor<ListableObject>> {
|
||||
return [this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user