mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
continued refactoring
This commit is contained in:
@@ -17,9 +17,9 @@ import { NotificationsService } from '../../../shared/notifications/notification
|
|||||||
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
|
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { RegistryService } from '../../../core/registry/registry.service';
|
import { RegistryService } from '../../../core/registry/registry.service';
|
||||||
import { MetadataField } from '../../../core/metadata/metadatafield.model';
|
|
||||||
import { MetadatumViewModel } from '../../../core/shared/metadata.models';
|
import { MetadatumViewModel } from '../../../core/shared/metadata.models';
|
||||||
import { Metadata } from '../../../core/shared/metadata.utils';
|
import { Metadata } from '../../../core/shared/metadata.utils';
|
||||||
|
import { MetadataField } from '../../../core/metadata/metadata-field.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-metadata',
|
selector: 'ds-item-metadata',
|
||||||
|
@@ -3,9 +3,10 @@ import { AuthTokenInfo } from './auth-token-info.model';
|
|||||||
import { EPerson } from '../../eperson/models/eperson.model';
|
import { EPerson } from '../../eperson/models/eperson.model';
|
||||||
import { RemoteData } from '../../data/remote-data';
|
import { RemoteData } from '../../data/remote-data';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { CacheableObject } from '../../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../../cache/object-cache.reducer';
|
||||||
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
|
|
||||||
export class AuthStatus implements CacheableObject {
|
export class AuthStatus implements CacheableObject, TypedObject {
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@@ -20,4 +21,7 @@ export class AuthStatus implements CacheableObject {
|
|||||||
token?: AuthTokenInfo;
|
token?: AuthTokenInfo;
|
||||||
|
|
||||||
self: string;
|
self: string;
|
||||||
|
|
||||||
|
type: ResourceType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -31,4 +31,8 @@ export class NormalizedAuthStatus extends NormalizedObject<AuthStatus> {
|
|||||||
@relationship(ResourceType.EPerson, false)
|
@relationship(ResourceType.EPerson, false)
|
||||||
@autoserialize
|
@autoserialize
|
||||||
eperson: string;
|
eperson: string;
|
||||||
|
|
||||||
|
|
||||||
|
@autoserialize
|
||||||
|
type: ResourceType;
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NormalizedObject } from '../models/normalized-object.model';
|
import { NormalizedObject } from '../models/normalized-object.model';
|
||||||
import { CacheableObject } from '../object-cache.reducer';
|
|
||||||
import { getRelationships } from './build-decorators';
|
import { getRelationships } from './build-decorators';
|
||||||
import { NormalizedObjectFactory } from '../models/normalized-object-factory';
|
|
||||||
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
|
||||||
|
import { TypedObject } from '../object-cache.reducer';
|
||||||
|
import { getNormalizedConstructorByType } from '../../shared/resource-type.decorator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if halObj has a value for `_links.self`
|
* Return true if halObj has a value for `_links.self`
|
||||||
@@ -35,8 +35,8 @@ export class NormalizedObjectBuildService {
|
|||||||
*
|
*
|
||||||
* @param {TDomain} domainModel a domain model
|
* @param {TDomain} domainModel a domain model
|
||||||
*/
|
*/
|
||||||
normalize<T extends CacheableObject>(domainModel: T): NormalizedObject<T> {
|
normalize<T extends TypedObject>(domainModel: T): NormalizedObject<T> {
|
||||||
const normalizedConstructor = NormalizedObjectFactory.getConstructor(domainModel.type);
|
const normalizedConstructor = getNormalizedConstructorByType(domainModel.type);
|
||||||
const relationships = getRelationships(normalizedConstructor) || [];
|
const relationships = getRelationships(normalizedConstructor) || [];
|
||||||
|
|
||||||
const normalizedModel = Object.assign({}, domainModel) as any;
|
const normalizedModel = Object.assign({}, domainModel) as any;
|
||||||
|
@@ -21,7 +21,7 @@ import {
|
|||||||
getRequestFromRequestUUID,
|
getRequestFromRequestUUID,
|
||||||
getResourceLinksFromResponse
|
getResourceLinksFromResponse
|
||||||
} from '../../shared/operators';
|
} from '../../shared/operators';
|
||||||
import { CacheableObject } from '../object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../object-cache.reducer';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RemoteDataBuildService {
|
export class RemoteDataBuildService {
|
||||||
@@ -29,7 +29,7 @@ export class RemoteDataBuildService {
|
|||||||
protected requestService: RequestService) {
|
protected requestService: RequestService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSingle<T extends CacheableObject>(href$: string | Observable<string>): Observable<RemoteData<T>> {
|
buildSingle<T extends TypedObject & CacheableObject>(href$: string | Observable<string>): Observable<RemoteData<T>> {
|
||||||
if (typeof href$ === 'string') {
|
if (typeof href$ === 'string') {
|
||||||
href$ = observableOf(href$);
|
href$ = observableOf(href$);
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ export class RemoteDataBuildService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildList<T extends CacheableObject>(href$: string | Observable<string>): Observable<RemoteData<PaginatedList<T>>> {
|
buildList<T extends TypedObject & CacheableObject>(href$: string | Observable<string>): Observable<RemoteData<PaginatedList<T>>> {
|
||||||
if (typeof href$ === 'string') {
|
if (typeof href$ === 'string') {
|
||||||
href$ = observableOf(href$);
|
href$ = observableOf(href$);
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ export class RemoteDataBuildService {
|
|||||||
return this.toRemoteDataObservable(requestEntry$, payload$);
|
return this.toRemoteDataObservable(requestEntry$, payload$);
|
||||||
}
|
}
|
||||||
|
|
||||||
build<T extends CacheableObject>(normalized: NormalizedObject<T>): T {
|
build<T extends TypedObject & CacheableObject>(normalized: NormalizedObject<T>): T {
|
||||||
const links: any = {};
|
const links: any = {};
|
||||||
const relationships = getRelationships(normalized.constructor) || [];
|
const relationships = getRelationships(normalized.constructor) || [];
|
||||||
|
|
||||||
|
@@ -5,13 +5,14 @@ import { ResourceType } from '../../shared/resource-type';
|
|||||||
import { mapsTo } from '../builders/build-decorators';
|
import { mapsTo } from '../builders/build-decorators';
|
||||||
import { NormalizedObject } from './normalized-object.model';
|
import { NormalizedObject } from './normalized-object.model';
|
||||||
import { resourceType } from '../../shared/resource-type.decorator';
|
import { resourceType } from '../../shared/resource-type.decorator';
|
||||||
|
import { TypedObject } from '../object-cache.reducer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An model class for a DSpaceObject.
|
* An model class for a DSpaceObject.
|
||||||
*/
|
*/
|
||||||
@mapsTo(DSpaceObject)
|
@mapsTo(DSpaceObject)
|
||||||
@resourceType(ResourceType.DSpaceObject)
|
@resourceType(ResourceType.DSpaceObject)
|
||||||
export class NormalizedDSpaceObject<T extends DSpaceObject> extends NormalizedObject<T> {
|
export class NormalizedDSpaceObject<T extends DSpaceObject> extends NormalizedObject<T> implements TypedObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The link to the rest endpoint where this object can be found
|
* The link to the rest endpoint where this object can be found
|
||||||
@@ -40,7 +41,7 @@ export class NormalizedDSpaceObject<T extends DSpaceObject> extends NormalizedOb
|
|||||||
/**
|
/**
|
||||||
* A string representing the kind of DSpaceObject, e.g. community, item, …
|
* A string representing the kind of DSpaceObject, e.g. community, item, …
|
||||||
*/
|
*/
|
||||||
@autoserializeAs(String)
|
@autoserializeAs(ResourceType)
|
||||||
type: ResourceType;
|
type: ResourceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { CacheableObject } from '../object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../object-cache.reducer';
|
||||||
import { autoserialize } from 'cerialize';
|
import { autoserialize } from 'cerialize';
|
||||||
import { ResourceType } from '../../shared/resource-type';
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
/**
|
/**
|
||||||
* An abstract model class for a NormalizedObject.
|
* An abstract model class for a NormalizedObject.
|
||||||
*/
|
*/
|
||||||
export abstract class NormalizedObject<T extends CacheableObject> implements CacheableObject {
|
export abstract class NormalizedObject<T extends TypedObject> implements CacheableObject, TypedObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The link to the rest endpoint where this object can be found
|
* The link to the rest endpoint where this object can be found
|
||||||
|
6
src/app/core/cache/object-cache.reducer.ts
vendored
6
src/app/core/cache/object-cache.reducer.ts
vendored
@@ -32,6 +32,9 @@ export interface Patch {
|
|||||||
operations: Operation[];
|
operations: Operation[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TypedObject {
|
||||||
|
type: ResourceType;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* An interface to represent objects that can be cached
|
* An interface to represent objects that can be cached
|
||||||
*
|
*
|
||||||
@@ -40,7 +43,6 @@ export interface Patch {
|
|||||||
export interface CacheableObject {
|
export interface CacheableObject {
|
||||||
uuid?: string;
|
uuid?: string;
|
||||||
self: string;
|
self: string;
|
||||||
type?: ResourceType;
|
|
||||||
// isNew: boolean;
|
// isNew: boolean;
|
||||||
// dirtyType: DirtyType;
|
// dirtyType: DirtyType;
|
||||||
// hasDirtyAttributes: boolean;
|
// hasDirtyAttributes: boolean;
|
||||||
@@ -48,6 +50,8 @@ export interface CacheableObject {
|
|||||||
// save(): void;
|
// save(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export type TypedCacheableObject = TypedObject & CacheableObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An entry in the ObjectCache
|
* An entry in the ObjectCache
|
||||||
*/
|
*/
|
||||||
|
@@ -16,8 +16,6 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class ConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = ConfigObjectFactory;
|
|
||||||
protected toCache = false;
|
protected toCache = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { CacheableObject } from '../../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../../cache/object-cache.reducer';
|
||||||
import { ResourceType } from '../../shared/resource-type';
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
|
|
||||||
export abstract class ConfigObject implements CacheableObject {
|
export abstract class ConfigObject implements CacheableObject, TypedObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name for this configuration
|
* The name for this configuration
|
||||||
|
@@ -2,7 +2,10 @@ import { autoserialize, inheritSerialization } from 'cerialize';
|
|||||||
import { SectionsType } from '../../../submission/sections/sections-type';
|
import { SectionsType } from '../../../submission/sections/sections-type';
|
||||||
import { NormalizedConfigObject } from './normalized-config.model';
|
import { NormalizedConfigObject } from './normalized-config.model';
|
||||||
import { SubmissionFormsModel } from './config-submission-forms.model';
|
import { SubmissionFormsModel } from './config-submission-forms.model';
|
||||||
import { SubmissionSectionVisibility } from './config-submission-section.model';
|
import {
|
||||||
|
SubmissionSectionModel,
|
||||||
|
SubmissionSectionVisibility
|
||||||
|
} from './config-submission-section.model';
|
||||||
import { mapsTo } from '../../cache/builders/build-decorators';
|
import { mapsTo } from '../../cache/builders/build-decorators';
|
||||||
import { resourceType } from '../../shared/resource-type.decorator';
|
import { resourceType } from '../../shared/resource-type.decorator';
|
||||||
import { ResourceType } from '../../shared/resource-type';
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
@@ -10,10 +13,10 @@ import { ResourceType } from '../../shared/resource-type';
|
|||||||
/**
|
/**
|
||||||
* Normalized class for the configuration describing the submission section
|
* Normalized class for the configuration describing the submission section
|
||||||
*/
|
*/
|
||||||
@mapsTo(SubmissionFormsModel)
|
@mapsTo(SubmissionSectionModel)
|
||||||
@inheritSerialization(NormalizedConfigObject)
|
@inheritSerialization(NormalizedConfigObject)
|
||||||
@resourceType(ResourceType.SubmissionForm, ResourceType.SubmissionForms)
|
@resourceType(ResourceType.SubmissionSection, ResourceType.SubmissionSections)
|
||||||
export class NormalizedSubmissionSectionModel extends NormalizedConfigObject<SubmissionFormsModel> {
|
export class NormalizedSubmissionSectionModel extends NormalizedConfigObject<SubmissionSectionModel> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The header for this section
|
* The header for this section
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import { autoserialize, inheritSerialization } from 'cerialize';
|
import { autoserialize, inheritSerialization } from 'cerialize';
|
||||||
import { NormalizedObject } from '../../cache/models/normalized-object.model';
|
import { NormalizedObject } from '../../cache/models/normalized-object.model';
|
||||||
import { CacheableObject } from '../../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../../cache/object-cache.reducer';
|
||||||
import { ResourceType } from '../../shared/resource-type';
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalized abstract class for a configuration object
|
* Normalized abstract class for a configuration object
|
||||||
*/
|
*/
|
||||||
@inheritSerialization(NormalizedObject)
|
@inheritSerialization(NormalizedObject)
|
||||||
export abstract class NormalizedConfigObject<T extends CacheableObject> implements CacheableObject {
|
export abstract class NormalizedConfigObject<T extends CacheableObject> implements CacheableObject, TypedObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name for this configuration
|
* The name for this configuration
|
||||||
|
@@ -18,9 +18,6 @@ import { RestRequest } from './request.models';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class BrowseEntriesResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class BrowseEntriesResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = {
|
|
||||||
getConstructor: () => BrowseEntry
|
|
||||||
};
|
|
||||||
protected toCache = false;
|
protected toCache = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@@ -18,10 +18,6 @@ import { NormalizedDSpaceObject } from '../cache/models/normalized-dspace-object
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BrowseItemsResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class BrowseItemsResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = {
|
|
||||||
getConstructor: () => DSpaceObject
|
|
||||||
};
|
|
||||||
protected toCache = false;
|
protected toCache = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@@ -4,8 +4,6 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
|||||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||||
import { GLOBAL_CONFIG } from '../../../config';
|
import { GLOBAL_CONFIG } from '../../../config';
|
||||||
import { NormalizedObject } from '../cache/models/normalized-object.model';
|
import { NormalizedObject } from '../cache/models/normalized-object.model';
|
||||||
import { ResourceType } from '../shared/resource-type';
|
|
||||||
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
|
||||||
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';
|
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';
|
||||||
import { RestResponse, DSOSuccessResponse } from '../cache/response.models';
|
import { RestResponse, DSOSuccessResponse } from '../cache/response.models';
|
||||||
import { RestRequest } from './request.models';
|
import { RestRequest } from './request.models';
|
||||||
@@ -17,8 +15,6 @@ import { DSpaceObject } from '../shared/dspace-object.model';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DSOResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class DSOResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = NormalizedObjectFactory;
|
|
||||||
protected toCache = true;
|
protected toCache = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -34,7 +30,7 @@ export class DSOResponseParsingService extends BaseResponseParsingService implem
|
|||||||
if (hasValue(data.payload) && hasValue(data.payload.page) && data.payload.page.totalElements === 0) {
|
if (hasValue(data.payload) && hasValue(data.payload.page) && data.payload.page.totalElements === 0) {
|
||||||
processRequestDTO = { page: [] };
|
processRequestDTO = { page: [] };
|
||||||
} else {
|
} else {
|
||||||
processRequestDTO = this.process<NormalizedObject<DSpaceObject>, ResourceType>(data.payload, request.uuid);
|
processRequestDTO = this.process<NormalizedObject<DSpaceObject>>(data.payload, request.uuid);
|
||||||
}
|
}
|
||||||
let objectList = processRequestDTO;
|
let objectList = processRequestDTO;
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@ import { GLOBAL_CONFIG } from '../../../config';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FacetConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class FacetConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
objectFactory = {};
|
|
||||||
toCache = false;
|
toCache = false;
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||||
|
@@ -17,7 +17,6 @@ import { GLOBAL_CONFIG } from '../../../config';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FacetValueMapResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class FacetValueMapResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
objectFactory = {};
|
|
||||||
toCache = false;
|
toCache = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@@ -12,7 +12,6 @@ import { GlobalConfig } from '../../../config/global-config.interface';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FacetValueResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class FacetValueResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
objectFactory = {};
|
|
||||||
toCache = false;
|
toCache = false;
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||||
|
@@ -9,8 +9,6 @@ import { BaseResponseParsingService } from '../data/base-response-parsing.servic
|
|||||||
import { GLOBAL_CONFIG } from '../../../config';
|
import { GLOBAL_CONFIG } from '../../../config';
|
||||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
|
||||||
import { ResourceType } from '../shared/resource-type';
|
|
||||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +17,6 @@ import { DSpaceObject } from '../shared/dspace-object.model';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class EpersonResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class EpersonResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = NormalizedObjectFactory;
|
|
||||||
protected toCache = false;
|
protected toCache = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -31,7 +28,7 @@ export class EpersonResponseParsingService extends BaseResponseParsingService im
|
|||||||
|
|
||||||
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
||||||
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) {
|
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) {
|
||||||
const epersonDefinition = this.process<DSpaceObject,ResourceType>(data.payload, request.href);
|
const epersonDefinition = this.process<DSpaceObject>(data.payload, request.href);
|
||||||
return new EpersonSuccessResponse(epersonDefinition[Object.keys(epersonDefinition)[0]], data.statusCode, data.statusText, this.processPageInfo(data.payload));
|
return new EpersonSuccessResponse(epersonDefinition[Object.keys(epersonDefinition)[0]], data.statusCode, data.statusText, this.processPageInfo(data.payload));
|
||||||
} else {
|
} else {
|
||||||
return new ErrorResponse(
|
return new ErrorResponse(
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
import { GenericConstructor } from '../shared/generic-constructor';
|
|
||||||
import { IntegrationType } from './intergration-type';
|
|
||||||
import { IntegrationModel } from './models/integration.model';
|
|
||||||
import { NormalizedAuthorityValue } from './models/normalized-authority-value.model';
|
|
||||||
|
|
||||||
export class IntegrationObjectFactory {
|
|
||||||
public static getConstructor(type): GenericConstructor<IntegrationModel> {
|
|
||||||
switch (type) {
|
|
||||||
case IntegrationType.Authority: {
|
|
||||||
return NormalizedAuthorityValue;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -8,21 +8,19 @@ import {
|
|||||||
RestResponse
|
RestResponse
|
||||||
} from '../cache/response.models';
|
} from '../cache/response.models';
|
||||||
import { isNotEmpty } from '../../shared/empty.util';
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
import { IntegrationObjectFactory } from './integration-object-factory';
|
|
||||||
|
|
||||||
import { BaseResponseParsingService } from '../data/base-response-parsing.service';
|
import { BaseResponseParsingService } from '../data/base-response-parsing.service';
|
||||||
import { GLOBAL_CONFIG } from '../../../config';
|
import { GLOBAL_CONFIG } from '../../../config';
|
||||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { IntegrationModel } from './models/integration.model';
|
import { IntegrationModel } from './models/integration.model';
|
||||||
import { IntegrationType } from './intergration-type';
|
|
||||||
import { AuthorityValue } from './models/authority.value';
|
import { AuthorityValue } from './models/authority.value';
|
||||||
import { PaginatedList } from '../data/paginated-list';
|
import { PaginatedList } from '../data/paginated-list';
|
||||||
|
import { ResourceType } from '../shared/resource-type';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IntegrationResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class IntegrationResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = IntegrationObjectFactory;
|
|
||||||
protected toCache = true;
|
protected toCache = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -34,7 +32,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic
|
|||||||
|
|
||||||
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
||||||
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) {
|
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) {
|
||||||
const dataDefinition = this.process<IntegrationModel,IntegrationType>(data.payload, request.uuid);
|
const dataDefinition = this.process<IntegrationModel>(data.payload, request.uuid);
|
||||||
return new IntegrationSuccessResponse(this.processResponse(dataDefinition), data.statusCode, data.statusText, this.processPageInfo(data.payload));
|
return new IntegrationSuccessResponse(this.processResponse(dataDefinition), data.statusCode, data.statusText, this.processPageInfo(data.payload));
|
||||||
} else {
|
} else {
|
||||||
return new ErrorResponse(
|
return new ErrorResponse(
|
||||||
@@ -49,7 +47,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic
|
|||||||
protected processResponse(data: PaginatedList<IntegrationModel>): any {
|
protected processResponse(data: PaginatedList<IntegrationModel>): any {
|
||||||
const returnList = Array.of();
|
const returnList = Array.of();
|
||||||
data.page.forEach((item, index) => {
|
data.page.forEach((item, index) => {
|
||||||
if (item.type === IntegrationType.Authority) {
|
if (item.type === ResourceType.Authority) {
|
||||||
data.page[index] = Object.assign(new AuthorityValue(), item);
|
data.page[index] = Object.assign(new AuthorityValue(), item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
export enum IntegrationType {
|
|
||||||
Authority = 'authority'
|
|
||||||
}
|
|
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../cache/object-cache.reducer';
|
||||||
import { ResourceType } from './resource-type';
|
import { ResourceType } from './resource-type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model class for a Bitstream Format
|
* Model class for a Bitstream Format
|
||||||
*/
|
*/
|
||||||
export class BitstreamFormat implements CacheableObject {
|
export class BitstreamFormat implements CacheableObject, TypedObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description of this Bitstream Format
|
* Short description of this Bitstream Format
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
import { autoserialize, autoserializeAs } from 'cerialize';
|
import { autoserialize, autoserializeAs } from 'cerialize';
|
||||||
import { SortOption } from './sort-option.model';
|
import { SortOption } from './sort-option.model';
|
||||||
|
import { ResourceType } from './resource-type';
|
||||||
|
import { TypedObject } from '../cache/object-cache.reducer';
|
||||||
|
|
||||||
export class BrowseDefinition {
|
export class BrowseDefinition implements TypedObject {
|
||||||
@autoserialize
|
@autoserialize
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ export class BrowseDefinition {
|
|||||||
defaultSortOrder: string;
|
defaultSortOrder: string;
|
||||||
|
|
||||||
@autoserialize
|
@autoserialize
|
||||||
type: string;
|
type: ResourceType;
|
||||||
|
|
||||||
@autoserializeAs('metadata')
|
@autoserializeAs('metadata')
|
||||||
metadataKeys: string[];
|
metadataKeys: string[];
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
import { autoserialize, autoserializeAs } from 'cerialize';
|
import { autoserialize, autoserializeAs } from 'cerialize';
|
||||||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
||||||
|
import { ResourceType } from './resource-type';
|
||||||
|
import { resourceType } from './resource-type.decorator';
|
||||||
|
import { CacheableObject, TypedObject } from '../cache/object-cache.reducer';
|
||||||
|
|
||||||
export class BrowseEntry implements ListableObject {
|
@resourceType(ResourceType.BrowseEntry)
|
||||||
|
export class BrowseEntry implements ListableObject, TypedObject {
|
||||||
|
|
||||||
@autoserialize
|
@autoserialize
|
||||||
type: string;
|
type: ResourceType;
|
||||||
|
|
||||||
@autoserialize
|
@autoserialize
|
||||||
authority: string;
|
authority: string;
|
||||||
|
@@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
|
|||||||
import { MetadataMap, MetadataValue, MetadataValueFilter, MetadatumViewModel } from './metadata.models';
|
import { MetadataMap, MetadataValue, MetadataValueFilter, MetadatumViewModel } from './metadata.models';
|
||||||
import { Metadata } from './metadata.utils';
|
import { Metadata } from './metadata.utils';
|
||||||
import { isUndefined } from '../../shared/empty.util';
|
import { isUndefined } from '../../shared/empty.util';
|
||||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../cache/object-cache.reducer';
|
||||||
import { RemoteData } from '../data/remote-data';
|
import { RemoteData } from '../data/remote-data';
|
||||||
import { ResourceType } from './resource-type';
|
import { ResourceType } from './resource-type';
|
||||||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
|
||||||
@@ -11,7 +11,7 @@ import { ListableObject } from '../../shared/object-collection/shared/listable-o
|
|||||||
/**
|
/**
|
||||||
* An abstract model class for a DSpaceObject.
|
* An abstract model class for a DSpaceObject.
|
||||||
*/
|
*/
|
||||||
export class DSpaceObject implements CacheableObject, ListableObject {
|
export class DSpaceObject implements CacheableObject, ListableObject, TypedObject {
|
||||||
|
|
||||||
private _name: string;
|
private _name: string;
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../cache/object-cache.reducer';
|
||||||
import { ResourceType } from './resource-type';
|
import { ResourceType } from './resource-type';
|
||||||
import { Group } from '../eperson/models/group.model';
|
import { Group } from '../eperson/models/group.model';
|
||||||
import { ActionType } from '../cache/models/action-type.model';
|
import { ActionType } from '../cache/models/action-type.model';
|
||||||
@@ -6,7 +6,7 @@ import { ActionType } from '../cache/models/action-type.model';
|
|||||||
/**
|
/**
|
||||||
* Model class for a Resource Policy
|
* Model class for a Resource Policy
|
||||||
*/
|
*/
|
||||||
export class ResourcePolicy implements CacheableObject {
|
export class ResourcePolicy implements CacheableObject, TypedObject {
|
||||||
/**
|
/**
|
||||||
* The action that is allowed by this Resource Policy
|
* The action that is allowed by this Resource Policy
|
||||||
*/
|
*/
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { CacheableObject } from '../cache/object-cache.reducer';
|
import { CacheableObject, TypedObject } from '../cache/object-cache.reducer';
|
||||||
import { GenericConstructor } from './generic-constructor';
|
import { GenericConstructor } from './generic-constructor';
|
||||||
|
import { ResourceType } from './resource-type';
|
||||||
|
|
||||||
const resourceTypeForObjectMap = new Map();
|
const resourceTypeForObjectMap = new Map();
|
||||||
|
|
||||||
export function resourceType(...resourceType: string[]) {
|
export function resourceType(...resourceType: ResourceType[]) {
|
||||||
return function decorator(objectConstructor: GenericConstructor<CacheableObject>) {
|
return function decorator(objectConstructor: GenericConstructor<TypedObject>) {
|
||||||
if (!objectConstructor) {
|
if (!objectConstructor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -13,6 +14,6 @@ export function resourceType(...resourceType: string[]) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNormalizedConstructorByType(resourceType: string) {
|
export function getNormalizedConstructorByType(resourceType: ResourceType) {
|
||||||
return resourceTypeForObjectMap.get(resourceType);
|
return resourceTypeForObjectMap.get(resourceType);
|
||||||
}
|
}
|
||||||
|
@@ -21,5 +21,6 @@ export enum ResourceType {
|
|||||||
SubmissionSections = 'submissionsections',
|
SubmissionSections = 'submissionsections',
|
||||||
SubmissionSection = 'submissionsection',
|
SubmissionSection = 'submissionsection',
|
||||||
AuthStatus = 'status',
|
AuthStatus = 'status',
|
||||||
Authority = 'authority'
|
Authority = 'authority',
|
||||||
|
BrowseEntry = 'browseEntry',
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,6 @@ import { NormalizedWorkspaceItem } from './models/normalized-workspaceitem.model
|
|||||||
import { NormalizedWorkflowItem } from './models/normalized-workflowitem.model';
|
import { NormalizedWorkflowItem } from './models/normalized-workflowitem.model';
|
||||||
import { FormFieldMetadataValueObject } from '../../shared/form/builder/models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../../shared/form/builder/models/form-field-metadata-value.model';
|
||||||
import { SubmissionObject } from './models/submission-object.model';
|
import { SubmissionObject } from './models/submission-object.model';
|
||||||
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export a function to check if object has same properties of FormFieldMetadataValueObject
|
* Export a function to check if object has same properties of FormFieldMetadataValueObject
|
||||||
@@ -75,7 +74,6 @@ export function normalizeSectionData(obj: any) {
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SubmissionResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
export class SubmissionResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||||
|
|
||||||
protected objectFactory = NormalizedObjectFactory;
|
|
||||||
protected toCache = false;
|
protected toCache = false;
|
||||||
|
|
||||||
constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||||
@@ -94,7 +92,7 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
|||||||
if (isNotEmpty(data.payload)
|
if (isNotEmpty(data.payload)
|
||||||
&& isNotEmpty(data.payload._links)
|
&& isNotEmpty(data.payload._links)
|
||||||
&& (data.statusCode === 201 || data.statusCode === 200)) {
|
&& (data.statusCode === 201 || data.statusCode === 200)) {
|
||||||
const dataDefinition = this.processResponse<SubmissionObject | ConfigObject, SubmissionResourceType>(data.payload, request.href);
|
const dataDefinition = this.processResponse<SubmissionObject | ConfigObject>(data.payload, request.href);
|
||||||
return new SubmissionSuccessResponse(dataDefinition, data.statusCode, data.statusText, this.processPageInfo(data.payload));
|
return new SubmissionSuccessResponse(dataDefinition, data.statusCode, data.statusText, this.processPageInfo(data.payload));
|
||||||
} else if (isEmpty(data.payload) && data.statusCode === 204) {
|
} else if (isEmpty(data.payload) && data.statusCode === 204) {
|
||||||
// Response from a DELETE request
|
// Response from a DELETE request
|
||||||
@@ -116,8 +114,8 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
|||||||
* @param {string} requestHref
|
* @param {string} requestHref
|
||||||
* @returns {any[]}
|
* @returns {any[]}
|
||||||
*/
|
*/
|
||||||
protected processResponse<ObjectDomain, ObjectType>(data: any, requestHref: string): any[] {
|
protected processResponse<ObjectDomain>(data: any, requestHref: string): any[] {
|
||||||
const dataDefinition = this.process<ObjectDomain, ObjectType>(data, requestHref);
|
const dataDefinition = this.process<ObjectDomain>(data, requestHref);
|
||||||
const normalizedDefinition = Array.of();
|
const normalizedDefinition = Array.of();
|
||||||
const processedList = Array.isArray(dataDefinition) ? dataDefinition : Array.of(dataDefinition);
|
const processedList = Array.isArray(dataDefinition) ? dataDefinition : Array.of(dataDefinition);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user