mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +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 { TranslateService } from '@ngx-translate/core';
|
||||
import { RegistryService } from '../../../core/registry/registry.service';
|
||||
import { MetadataField } from '../../../core/metadata/metadatafield.model';
|
||||
import { MetadatumViewModel } from '../../../core/shared/metadata.models';
|
||||
import { Metadata } from '../../../core/shared/metadata.utils';
|
||||
import { MetadataField } from '../../../core/metadata/metadata-field.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-metadata',
|
||||
|
@@ -3,9 +3,10 @@ import { AuthTokenInfo } from './auth-token-info.model';
|
||||
import { EPerson } from '../../eperson/models/eperson.model';
|
||||
import { RemoteData } from '../../data/remote-data';
|
||||
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;
|
||||
|
||||
@@ -20,4 +21,7 @@ export class AuthStatus implements CacheableObject {
|
||||
token?: AuthTokenInfo;
|
||||
|
||||
self: string;
|
||||
|
||||
type: ResourceType;
|
||||
|
||||
}
|
||||
|
@@ -31,4 +31,8 @@ export class NormalizedAuthStatus extends NormalizedObject<AuthStatus> {
|
||||
@relationship(ResourceType.EPerson, false)
|
||||
@autoserialize
|
||||
eperson: string;
|
||||
|
||||
|
||||
@autoserialize
|
||||
type: ResourceType;
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NormalizedObject } from '../models/normalized-object.model';
|
||||
import { CacheableObject } from '../object-cache.reducer';
|
||||
import { getRelationships } from './build-decorators';
|
||||
import { NormalizedObjectFactory } from '../models/normalized-object-factory';
|
||||
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`
|
||||
@@ -35,8 +35,8 @@ export class NormalizedObjectBuildService {
|
||||
*
|
||||
* @param {TDomain} domainModel a domain model
|
||||
*/
|
||||
normalize<T extends CacheableObject>(domainModel: T): NormalizedObject<T> {
|
||||
const normalizedConstructor = NormalizedObjectFactory.getConstructor(domainModel.type);
|
||||
normalize<T extends TypedObject>(domainModel: T): NormalizedObject<T> {
|
||||
const normalizedConstructor = getNormalizedConstructorByType(domainModel.type);
|
||||
const relationships = getRelationships(normalizedConstructor) || [];
|
||||
|
||||
const normalizedModel = Object.assign({}, domainModel) as any;
|
||||
|
@@ -21,7 +21,7 @@ import {
|
||||
getRequestFromRequestUUID,
|
||||
getResourceLinksFromResponse
|
||||
} from '../../shared/operators';
|
||||
import { CacheableObject } from '../object-cache.reducer';
|
||||
import { CacheableObject, TypedObject } from '../object-cache.reducer';
|
||||
|
||||
@Injectable()
|
||||
export class RemoteDataBuildService {
|
||||
@@ -29,7 +29,7 @@ export class RemoteDataBuildService {
|
||||
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') {
|
||||
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') {
|
||||
href$ = observableOf(href$);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class RemoteDataBuildService {
|
||||
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 relationships = getRelationships(normalized.constructor) || [];
|
||||
|
||||
|
@@ -5,13 +5,14 @@ import { ResourceType } from '../../shared/resource-type';
|
||||
import { mapsTo } from '../builders/build-decorators';
|
||||
import { NormalizedObject } from './normalized-object.model';
|
||||
import { resourceType } from '../../shared/resource-type.decorator';
|
||||
import { TypedObject } from '../object-cache.reducer';
|
||||
|
||||
/**
|
||||
* An model class for a DSpaceObject.
|
||||
*/
|
||||
@mapsTo(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
|
||||
@@ -40,7 +41,7 @@ export class NormalizedDSpaceObject<T extends DSpaceObject> extends NormalizedOb
|
||||
/**
|
||||
* A string representing the kind of DSpaceObject, e.g. community, item, …
|
||||
*/
|
||||
@autoserializeAs(String)
|
||||
@autoserializeAs(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 { ResourceType } from '../../shared/resource-type';
|
||||
/**
|
||||
* 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
|
||||
|
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[];
|
||||
}
|
||||
|
||||
export interface TypedObject {
|
||||
type: ResourceType;
|
||||
}
|
||||
/**
|
||||
* An interface to represent objects that can be cached
|
||||
*
|
||||
@@ -40,7 +43,6 @@ export interface Patch {
|
||||
export interface CacheableObject {
|
||||
uuid?: string;
|
||||
self: string;
|
||||
type?: ResourceType;
|
||||
// isNew: boolean;
|
||||
// dirtyType: DirtyType;
|
||||
// hasDirtyAttributes: boolean;
|
||||
@@ -48,6 +50,8 @@ export interface CacheableObject {
|
||||
// save(): void;
|
||||
}
|
||||
|
||||
// export type TypedCacheableObject = TypedObject & CacheableObject;
|
||||
|
||||
/**
|
||||
* An entry in the ObjectCache
|
||||
*/
|
||||
|
@@ -16,8 +16,6 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
|
||||
@Injectable()
|
||||
export class ConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = ConfigObjectFactory;
|
||||
protected toCache = false;
|
||||
|
||||
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';
|
||||
|
||||
export abstract class ConfigObject implements CacheableObject {
|
||||
export abstract class ConfigObject implements CacheableObject, TypedObject {
|
||||
|
||||
/**
|
||||
* The name for this configuration
|
||||
|
@@ -2,7 +2,10 @@ import { autoserialize, inheritSerialization } from 'cerialize';
|
||||
import { SectionsType } from '../../../submission/sections/sections-type';
|
||||
import { NormalizedConfigObject } from './normalized-config.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 { resourceType } from '../../shared/resource-type.decorator';
|
||||
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
|
||||
*/
|
||||
@mapsTo(SubmissionFormsModel)
|
||||
@mapsTo(SubmissionSectionModel)
|
||||
@inheritSerialization(NormalizedConfigObject)
|
||||
@resourceType(ResourceType.SubmissionForm, ResourceType.SubmissionForms)
|
||||
export class NormalizedSubmissionSectionModel extends NormalizedConfigObject<SubmissionFormsModel> {
|
||||
@resourceType(ResourceType.SubmissionSection, ResourceType.SubmissionSections)
|
||||
export class NormalizedSubmissionSectionModel extends NormalizedConfigObject<SubmissionSectionModel> {
|
||||
|
||||
/**
|
||||
* The header for this section
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import { autoserialize, inheritSerialization } from 'cerialize';
|
||||
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';
|
||||
|
||||
/**
|
||||
* Normalized abstract class for a configuration object
|
||||
*/
|
||||
@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
|
||||
|
@@ -18,9 +18,6 @@ import { RestRequest } from './request.models';
|
||||
@Injectable()
|
||||
export class BrowseEntriesResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = {
|
||||
getConstructor: () => BrowseEntry
|
||||
};
|
||||
protected toCache = false;
|
||||
|
||||
constructor(
|
||||
|
@@ -18,10 +18,6 @@ import { NormalizedDSpaceObject } from '../cache/models/normalized-dspace-object
|
||||
*/
|
||||
@Injectable()
|
||||
export class BrowseItemsResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = {
|
||||
getConstructor: () => DSpaceObject
|
||||
};
|
||||
protected toCache = false;
|
||||
|
||||
constructor(
|
||||
|
@@ -4,8 +4,6 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||
import { GLOBAL_CONFIG } from '../../../config';
|
||||
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 { RestResponse, DSOSuccessResponse } from '../cache/response.models';
|
||||
import { RestRequest } from './request.models';
|
||||
@@ -17,8 +15,6 @@ import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
|
||||
@Injectable()
|
||||
export class DSOResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = NormalizedObjectFactory;
|
||||
protected toCache = true;
|
||||
|
||||
constructor(
|
||||
@@ -34,7 +30,7 @@ export class DSOResponseParsingService extends BaseResponseParsingService implem
|
||||
if (hasValue(data.payload) && hasValue(data.payload.page) && data.payload.page.totalElements === 0) {
|
||||
processRequestDTO = { page: [] };
|
||||
} else {
|
||||
processRequestDTO = this.process<NormalizedObject<DSpaceObject>, ResourceType>(data.payload, request.uuid);
|
||||
processRequestDTO = this.process<NormalizedObject<DSpaceObject>>(data.payload, request.uuid);
|
||||
}
|
||||
let objectList = processRequestDTO;
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import { GLOBAL_CONFIG } from '../../../config';
|
||||
|
||||
@Injectable()
|
||||
export class FacetConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
objectFactory = {};
|
||||
toCache = false;
|
||||
constructor(
|
||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
|
@@ -17,7 +17,6 @@ import { GLOBAL_CONFIG } from '../../../config';
|
||||
|
||||
@Injectable()
|
||||
export class FacetValueMapResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
objectFactory = {};
|
||||
toCache = false;
|
||||
|
||||
constructor(
|
||||
|
@@ -12,7 +12,6 @@ import { GlobalConfig } from '../../../config/global-config.interface';
|
||||
|
||||
@Injectable()
|
||||
export class FacetValueResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
objectFactory = {};
|
||||
toCache = false;
|
||||
constructor(
|
||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
|
@@ -9,8 +9,6 @@ import { BaseResponseParsingService } from '../data/base-response-parsing.servic
|
||||
import { GLOBAL_CONFIG } from '../../../config';
|
||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||
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';
|
||||
|
||||
/**
|
||||
@@ -19,7 +17,6 @@ import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
@Injectable()
|
||||
export class EpersonResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = NormalizedObjectFactory;
|
||||
protected toCache = false;
|
||||
|
||||
constructor(
|
||||
@@ -31,7 +28,7 @@ export class EpersonResponseParsingService extends BaseResponseParsingService im
|
||||
|
||||
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
||||
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));
|
||||
} else {
|
||||
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
|
||||
} from '../cache/response.models';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { IntegrationObjectFactory } from './integration-object-factory';
|
||||
|
||||
import { BaseResponseParsingService } from '../data/base-response-parsing.service';
|
||||
import { GLOBAL_CONFIG } from '../../../config';
|
||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { IntegrationModel } from './models/integration.model';
|
||||
import { IntegrationType } from './intergration-type';
|
||||
import { AuthorityValue } from './models/authority.value';
|
||||
import { PaginatedList } from '../data/paginated-list';
|
||||
import { ResourceType } from '../shared/resource-type';
|
||||
|
||||
@Injectable()
|
||||
export class IntegrationResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = IntegrationObjectFactory;
|
||||
protected toCache = true;
|
||||
|
||||
constructor(
|
||||
@@ -34,7 +32,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic
|
||||
|
||||
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
||||
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));
|
||||
} else {
|
||||
return new ErrorResponse(
|
||||
@@ -49,7 +47,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic
|
||||
protected processResponse(data: PaginatedList<IntegrationModel>): any {
|
||||
const returnList = Array.of();
|
||||
data.page.forEach((item, index) => {
|
||||
if (item.type === IntegrationType.Authority) {
|
||||
if (item.type === ResourceType.Authority) {
|
||||
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';
|
||||
|
||||
/**
|
||||
* Model class for a Bitstream Format
|
||||
*/
|
||||
export class BitstreamFormat implements CacheableObject {
|
||||
export class BitstreamFormat implements CacheableObject, TypedObject {
|
||||
|
||||
/**
|
||||
* Short description of this Bitstream Format
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { autoserialize, autoserializeAs } from 'cerialize';
|
||||
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
|
||||
id: string;
|
||||
|
||||
@@ -15,7 +17,7 @@ export class BrowseDefinition {
|
||||
defaultSortOrder: string;
|
||||
|
||||
@autoserialize
|
||||
type: string;
|
||||
type: ResourceType;
|
||||
|
||||
@autoserializeAs('metadata')
|
||||
metadataKeys: string[];
|
||||
|
@@ -1,10 +1,14 @@
|
||||
import { autoserialize, autoserializeAs } from 'cerialize';
|
||||
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
|
||||
type: string;
|
||||
type: ResourceType;
|
||||
|
||||
@autoserialize
|
||||
authority: string;
|
||||
|
@@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
|
||||
import { MetadataMap, MetadataValue, MetadataValueFilter, MetadatumViewModel } from './metadata.models';
|
||||
import { Metadata } from './metadata.utils';
|
||||
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 { ResourceType } from './resource-type';
|
||||
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.
|
||||
*/
|
||||
export class DSpaceObject implements CacheableObject, ListableObject {
|
||||
export class DSpaceObject implements CacheableObject, ListableObject, TypedObject {
|
||||
|
||||
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 { Group } from '../eperson/models/group.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
|
||||
*/
|
||||
export class ResourcePolicy implements CacheableObject {
|
||||
export class ResourcePolicy implements CacheableObject, TypedObject {
|
||||
/**
|
||||
* 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 { ResourceType } from './resource-type';
|
||||
|
||||
const resourceTypeForObjectMap = new Map();
|
||||
|
||||
export function resourceType(...resourceType: string[]) {
|
||||
return function decorator(objectConstructor: GenericConstructor<CacheableObject>) {
|
||||
export function resourceType(...resourceType: ResourceType[]) {
|
||||
return function decorator(objectConstructor: GenericConstructor<TypedObject>) {
|
||||
if (!objectConstructor) {
|
||||
return;
|
||||
}
|
||||
@@ -13,6 +14,6 @@ export function resourceType(...resourceType: string[]) {
|
||||
};
|
||||
}
|
||||
|
||||
export function getNormalizedConstructorByType(resourceType: string) {
|
||||
export function getNormalizedConstructorByType(resourceType: ResourceType) {
|
||||
return resourceTypeForObjectMap.get(resourceType);
|
||||
}
|
||||
|
@@ -21,5 +21,6 @@ export enum ResourceType {
|
||||
SubmissionSections = 'submissionsections',
|
||||
SubmissionSection = 'submissionsection',
|
||||
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 { FormFieldMetadataValueObject } from '../../shared/form/builder/models/form-field-metadata-value.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
|
||||
@@ -75,7 +74,6 @@ export function normalizeSectionData(obj: any) {
|
||||
@Injectable()
|
||||
export class SubmissionResponseParsingService extends BaseResponseParsingService implements ResponseParsingService {
|
||||
|
||||
protected objectFactory = NormalizedObjectFactory;
|
||||
protected toCache = false;
|
||||
|
||||
constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
@@ -94,7 +92,7 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
||||
if (isNotEmpty(data.payload)
|
||||
&& isNotEmpty(data.payload._links)
|
||||
&& (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));
|
||||
} else if (isEmpty(data.payload) && data.statusCode === 204) {
|
||||
// Response from a DELETE request
|
||||
@@ -116,8 +114,8 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
||||
* @param {string} requestHref
|
||||
* @returns {any[]}
|
||||
*/
|
||||
protected processResponse<ObjectDomain, ObjectType>(data: any, requestHref: string): any[] {
|
||||
const dataDefinition = this.process<ObjectDomain, ObjectType>(data, requestHref);
|
||||
protected processResponse<ObjectDomain>(data: any, requestHref: string): any[] {
|
||||
const dataDefinition = this.process<ObjectDomain>(data, requestHref);
|
||||
const normalizedDefinition = Array.of();
|
||||
const processedList = Array.isArray(dataDefinition) ? dataDefinition : Array.of(dataDefinition);
|
||||
|
||||
|
Reference in New Issue
Block a user