From f980b55c1cc7977f92121c65811f12e50a19bf12 Mon Sep 17 00:00:00 2001 From: lotte Date: Mon, 24 Jun 2019 16:29:54 +0200 Subject: [PATCH] refactored resource type and type mapping --- .../collection-form.component.ts | 11 ++--- .../community-form.component.ts | 4 +- .../search-results.component.spec.ts | 4 +- .../search-service/search.service.ts | 6 +-- src/app/core/auth/models/auth-status.model.ts | 8 +--- .../models/normalized-auth-status.model.ts | 5 +-- .../core/cache/builders/build-decorators.ts | 33 ++++++++++++--- .../normalized-object-build.service.ts | 5 +-- .../items/normalized-item-type.model.ts | 6 +-- .../normalized-relationship-type.model.ts | 11 +++-- .../items/normalized-relationship.model.ts | 8 ++-- .../normalized-bitstream-format.model.ts | 4 -- .../models/normalized-bitstream.model.ts | 14 +++---- .../cache/models/normalized-bundle.model.ts | 8 ++-- .../models/normalized-collection.model.ts | 24 +++++++---- .../models/normalized-community.model.ts | 19 +++++---- .../models/normalized-dspace-object.model.ts | 9 ++-- .../cache/models/normalized-item.model.ts | 16 ++++--- .../cache/models/normalized-license.model.ts | 2 - .../cache/models/normalized-object.model.ts | 7 ---- .../normalized-resource-policy.model.ts | 3 -- .../core/cache/models/support-level.model.ts | 2 +- .../core/cache/object-cache.reducer.spec.ts | 12 +++--- src/app/core/cache/object-cache.reducer.ts | 6 +-- .../core/cache/object-cache.service.spec.ts | 6 +-- src/app/core/cache/object-cache.service.ts | 4 +- .../config-submission-definition.model.ts | 19 +++++++++ .../config-submission-definitions.model.ts | 18 ++------ .../models/config-submission-form.model.ts | 22 ++++++++++ .../models/config-submission-forms.model.ts | 19 ++------- .../models/config-submission-section.model.ts | 2 + .../config-submission-sections.model.ts | 6 +++ ...ized-config-submission-definition.model.ts | 28 +++++++++++++ ...zed-config-submission-definitions.model.ts | 23 ++-------- ...normalized-config-submission-form.model.ts | 18 ++++++++ ...ormalized-config-submission-forms.model.ts | 19 +++------ ...malized-config-submission-section.model.ts | 4 -- ...alized-config-submission-sections.model.ts | 18 ++++++++ .../data/base-response-parsing.service.ts | 6 +-- src/app/core/data/data.service.ts | 4 +- src/app/core/data/request.effects.ts | 4 +- src/app/core/eperson/models/eperson.model.ts | 2 + src/app/core/eperson/models/group.model.ts | 2 + .../models/normalized-eperson.model.ts | 7 +--- .../eperson/models/normalized-group.model.ts | 5 +-- .../integration-response-parsing.service.ts | 9 +--- .../integration/models/authority.value.ts | 2 + .../normalized-authority-value.model.ts | 3 -- src/app/core/metadata/metadata-field.model.ts | 1 + .../core/metadata/metadata-schema.model.ts | 2 + .../normalized-metadata-field.model.ts | 5 +-- .../normalized-metadata-schema.model.ts | 2 - .../registry-metadatafields-response.model.ts | 8 ++-- .../core/registry/registry.service.spec.ts | 12 +++--- src/app/core/registry/registry.service.ts | 4 +- src/app/core/shared/bitstream-format.model.ts | 2 + src/app/core/shared/bitstream.model.ts | 3 +- src/app/core/shared/browse-entry.model.ts | 15 +------ src/app/core/shared/bundle.model.ts | 3 ++ src/app/core/shared/collection.model.ts | 3 +- src/app/core/shared/community.model.ts | 2 + src/app/core/shared/dspace-object.model.ts | 23 +++++----- .../item-relationships/item-type.model.ts | 2 + .../relationship-type.model.ts | 2 + .../item-relationships/relationship.model.ts | 2 + src/app/core/shared/item.model.ts | 2 + src/app/core/shared/license.model.ts | 2 + .../shared/normalized-browse-entry.model.ts | 42 +++++++++++++++++++ src/app/core/shared/resource-policy.model.ts | 2 + .../core/shared/resource-type.decorator.ts | 27 ------------ src/app/core/shared/resource-type.ts | 39 ++++------------- .../models/normalized-workflowitem.model.ts | 19 ++++++--- .../models/normalized-workspaceitem.model.ts | 15 +++---- .../submission/models/workflowitem.model.ts | 2 + .../submission/models/workspaceitem.model.ts | 2 + .../submission/submission-resource-type.ts | 21 ---------- .../tasks/models/claimed-task-object.model.ts | 3 +- .../normalized-claimed-task-object.model.ts | 13 +++--- .../normalized-pool-task-object.model.ts | 10 ++--- .../models/normalized-task-object.model.ts | 12 +++--- .../tasks/models/pool-task-object.model.ts | 3 +- .../core/tasks/models/task-object.model.ts | 2 + src/app/shared/alert/alert.component.spec.ts | 2 +- .../comcol-form/comcol-form.component.spec.ts | 2 +- .../comcol-form/comcol-form.component.ts | 4 +- .../delete-comcol-page.component.ts | 4 +- .../dso-selector.component.spec.ts | 2 +- .../dynamic-relation-group.model.ts | 2 +- .../form/builder/models/form-field.model.ts | 2 +- .../parsers/relation-group-field-parser.ts | 2 +- src/app/shared/mocks/mock-form-models.ts | 2 +- .../claimed-task-actions.component.spec.ts | 2 +- .../claimed-task-actions.component.ts | 2 +- .../item/item-actions.component.ts | 3 +- .../mydspace-actions-service.factory.ts | 36 ---------------- .../mydspace-actions/mydspace-actions.ts | 5 +-- .../pool-task/pool-task-actions.component.ts | 2 +- .../workflowitem-actions.component.ts | 3 +- .../workspaceitem-actions.component.ts | 2 +- .../notifications.reducers.spec.ts | 2 +- .../search-form/search-form.component.spec.ts | 4 +- 101 files changed, 440 insertions(+), 427 deletions(-) create mode 100644 src/app/core/config/models/config-submission-definition.model.ts create mode 100644 src/app/core/config/models/config-submission-form.model.ts create mode 100644 src/app/core/config/models/config-submission-sections.model.ts create mode 100644 src/app/core/config/models/normalized-config-submission-definition.model.ts create mode 100644 src/app/core/config/models/normalized-config-submission-form.model.ts create mode 100644 src/app/core/config/models/normalized-config-submission-sections.model.ts create mode 100644 src/app/core/shared/normalized-browse-entry.model.ts delete mode 100644 src/app/core/shared/resource-type.decorator.ts delete mode 100644 src/app/core/submission/submission-resource-type.ts delete mode 100644 src/app/shared/mydspace-actions/mydspace-actions-service.factory.ts diff --git a/src/app/+collection-page/collection-form/collection-form.component.ts b/src/app/+collection-page/collection-form/collection-form.component.ts index 22f2f1271d..21b494f41f 100644 --- a/src/app/+collection-page/collection-form/collection-form.component.ts +++ b/src/app/+collection-page/collection-form/collection-form.component.ts @@ -1,12 +1,9 @@ import { Component, Input } from '@angular/core'; -import { - DynamicInputModel, - DynamicTextAreaModel -} from '@ng-dynamic-forms/core'; +import { DynamicInputModel, DynamicTextAreaModel } from '@ng-dynamic-forms/core'; import { DynamicFormControlModel } from '@ng-dynamic-forms/core/src/model/dynamic-form-control.model'; -import { ResourceType } from '../../core/shared/resource-type'; import { Collection } from '../../core/shared/collection.model'; import { ComColFormComponent } from '../../shared/comcol-forms/comcol-form/comcol-form.component'; +import { NormalizedCollection } from '../../core/cache/models/normalized-collection.model'; /** * Form used for creating and editing collections @@ -23,9 +20,9 @@ export class CollectionFormComponent extends ComColFormComponent { @Input() dso: Collection = new Collection(); /** - * @type {ResourceType.Collection} This is a collection-type form + * @type {Collection.type} This is a collection-type form */ - protected type = ResourceType.Collection; + protected type = Collection.type; /** * The dynamic form fields used for creating/editing a collection diff --git a/src/app/+community-page/community-form/community-form.component.ts b/src/app/+community-page/community-form/community-form.component.ts index 9ae6f0955d..17d601e251 100644 --- a/src/app/+community-page/community-form/community-form.component.ts +++ b/src/app/+community-page/community-form/community-form.component.ts @@ -20,9 +20,9 @@ export class CommunityFormComponent extends ComColFormComponent { @Input() dso: Community = new Community(); /** - * @type {ResourceType.Community} This is a community-type form + * @type {Community.type} This is a community-type form */ - protected type = ResourceType.Community; + protected type = Community.type; /** * The dynamic form fields used for creating/editing a community diff --git a/src/app/+search-page/search-results/search-results.component.spec.ts b/src/app/+search-page/search-results/search-results.component.spec.ts index 518829e69f..6eb48bb037 100644 --- a/src/app/+search-page/search-results/search-results.component.spec.ts +++ b/src/app/+search-page/search-results/search-results.component.spec.ts @@ -114,7 +114,7 @@ export const objects = [ self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/communities/7669c72a-3f2a-451f-a3b9-9210e7a4c02f', id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', - type: ResourceType.Community, + type: Community.type, metadata: { 'dc.description': [ { @@ -168,7 +168,7 @@ export const objects = [ self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/communities/9076bd16-e69a-48d6-9e41-0238cb40d863', id: '9076bd16-e69a-48d6-9e41-0238cb40d863', uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', - type: ResourceType.Community, + type: Community.type, metadata: { 'dc.description': [ { diff --git a/src/app/+search-page/search-service/search.service.ts b/src/app/+search-page/search-service/search.service.ts index 598657a1b2..0646c2c089 100644 --- a/src/app/+search-page/search-service/search.service.ts +++ b/src/app/+search-page/search-service/search.service.ts @@ -1,6 +1,6 @@ import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs'; import { Injectable, OnDestroy } from '@angular/core'; -import { NavigationExtras, PRIMARY_OUTLET, Router, UrlSegmentGroup } from '@angular/router'; +import { NavigationExtras, Router } from '@angular/router'; import { first, map, switchMap } from 'rxjs/operators'; import { RemoteDataBuildService } from '../../core/cache/builders/remote-data-build.service'; import { @@ -40,7 +40,6 @@ import { PaginatedSearchOptions } from '../paginated-search-options.model'; import { Community } from '../../core/shared/community.model'; import { CommunityDataService } from '../../core/data/community-data.service'; import { ViewMode } from '../../core/shared/view-mode.model'; -import { ResourceType } from '../../core/shared/resource-type'; import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; import { RouteService } from '../../shared/services/route.service'; @@ -296,7 +295,8 @@ export class SearchService implements OnDestroy { const scopeObject: Observable> = this.dspaceObjectService.findById(scopeId).pipe(getSucceededRemoteData()); const scopeList: Observable = scopeObject.pipe( switchMap((dsoRD: RemoteData) => { - if (dsoRD.payload.type === ResourceType.Community) { + console.log((dsoRD.payload as any).type); + if ((dsoRD.payload as any).type === Community.type) { const community: Community = dsoRD.payload as Community; return observableCombineLatest(community.subcommunities, community.collections).pipe( map(([subCommunities, collections]) => { diff --git a/src/app/core/auth/models/auth-status.model.ts b/src/app/core/auth/models/auth-status.model.ts index 5349a574af..e0d568397a 100644 --- a/src/app/core/auth/models/auth-status.model.ts +++ b/src/app/core/auth/models/auth-status.model.ts @@ -10,6 +10,8 @@ import { ResourceType } from '../../shared/resource-type'; * Object that represents the authenticated status of a user */ export class AuthStatus implements CacheableObject { + static type = new ResourceType('status'); + /** * The unique identifier of this auth status */ @@ -49,10 +51,4 @@ export class AuthStatus implements CacheableObject { * The self link of this auth status' REST object */ self: string; - - /** - * The resource object of this auth status - */ - type: ResourceType; - } diff --git a/src/app/core/auth/models/normalized-auth-status.model.ts b/src/app/core/auth/models/normalized-auth-status.model.ts index 7693e330a2..3dc723f97b 100644 --- a/src/app/core/auth/models/normalized-auth-status.model.ts +++ b/src/app/core/auth/models/normalized-auth-status.model.ts @@ -4,11 +4,10 @@ import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; import { NormalizedObject } from '../../cache/models/normalized-object.model'; import { IDToUUIDSerializer } from '../../cache/id-to-uuid-serializer'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { EPerson } from '../../eperson/models/eperson.model'; @mapsTo(AuthStatus) @inheritSerialization(NormalizedObject) -@resourceType(ResourceType.AuthStatus) export class NormalizedAuthStatus extends NormalizedObject { /** * The unique identifier of this auth status @@ -37,7 +36,7 @@ export class NormalizedAuthStatus extends NormalizedObject { /** * The self link to the eperson of this auth status */ - @relationship(ResourceType.EPerson, false) + @relationship(EPerson, false) @autoserialize eperson: string; diff --git a/src/app/core/cache/builders/build-decorators.ts b/src/app/core/cache/builders/build-decorators.ts index 937fb37cd3..27d299c528 100644 --- a/src/app/core/cache/builders/build-decorators.ts +++ b/src/app/core/cache/builders/build-decorators.ts @@ -1,23 +1,42 @@ import 'reflect-metadata'; import { GenericConstructor } from '../../shared/generic-constructor'; -import { CacheableObject } from '../object-cache.reducer'; +import { CacheableObject, TypedObject } from '../object-cache.reducer'; import { ResourceType } from '../../shared/resource-type'; const mapsToMetadataKey = Symbol('mapsTo'); const relationshipKey = Symbol('relationship'); const relationshipMap = new Map(); +const typeMap = new Map(); -export function mapsTo(value: GenericConstructor) { - return Reflect.metadata(mapsToMetadataKey, value); + +export function mapsTo(value: GenericConstructor) { + return function decorator(objectConstructor: GenericConstructor) { + Reflect.defineMetadata(mapsToMetadataKey, value, objectConstructor); + mapsToType((value as any).type, objectConstructor); + } +} + +function mapsToType(value: ResourceType, objectConstructor: GenericConstructor) { + if (!objectConstructor || !value) { + return; + } + typeMap.set(value.value, objectConstructor); } export function getMapsTo(target: any) { return Reflect.getOwnMetadata(mapsToMetadataKey, target); } -export function relationship(value: ResourceType, isList: boolean = false): any { +export function getMapsToType(type: string | ResourceType) { + if (typeof(type) === 'object') { + type = (type as ResourceType).value; + } + return typeMap.get(type); +} + +export function relationship(value: GenericConstructor, isList: boolean = false): any { return function r(target: any, propertyKey: string, descriptor: PropertyDescriptor) { if (!target || !propertyKey) { return; @@ -28,8 +47,10 @@ export function relationship(value: ResourceType, isList: boolean = false): any metaDataList.push(propertyKey); } relationshipMap.set(target.constructor, metaDataList); - - return Reflect.metadata(relationshipKey, { resourceType: value, isList }).apply(this, arguments); + return Reflect.metadata(relationshipKey, { + resourceType: (value as any).type.value, + isList + }).apply(this, arguments); }; } diff --git a/src/app/core/cache/builders/normalized-object-build.service.ts b/src/app/core/cache/builders/normalized-object-build.service.ts index 357ae71872..936548cdd4 100644 --- a/src/app/core/cache/builders/normalized-object-build.service.ts +++ b/src/app/core/cache/builders/normalized-object-build.service.ts @@ -1,9 +1,8 @@ import { Injectable } from '@angular/core'; import { NormalizedObject } from '../models/normalized-object.model'; -import { getRelationships } from './build-decorators'; +import { getMapsToType, getRelationships } from './build-decorators'; 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` @@ -36,7 +35,7 @@ export class NormalizedObjectBuildService { * @param {TDomain} domainModel a domain model */ normalize(domainModel: T): NormalizedObject { - const normalizedConstructor = getNormalizedConstructorByType(domainModel.type); + const normalizedConstructor = getMapsToType((domainModel as any).type); const relationships = getRelationships(normalizedConstructor) || []; const normalizedModel = Object.assign({}, domainModel) as any; diff --git a/src/app/core/cache/models/items/normalized-item-type.model.ts b/src/app/core/cache/models/items/normalized-item-type.model.ts index ffc1e0fa1f..fdb3b9e455 100644 --- a/src/app/core/cache/models/items/normalized-item-type.model.ts +++ b/src/app/core/cache/models/items/normalized-item-type.model.ts @@ -1,19 +1,15 @@ import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; import { ItemType } from '../../../shared/item-relationships/item-type.model'; -import { ResourceType } from '../../../shared/resource-type'; import { mapsTo } from '../../builders/build-decorators'; import { NormalizedObject } from '../normalized-object.model'; import { IDToUUIDSerializer } from '../../id-to-uuid-serializer'; -import { resourceType } from '../../../shared/resource-type.decorator'; /** * Normalized model class for a DSpace ItemType */ @mapsTo(ItemType) -@resourceType(ResourceType.ItemType) @inheritSerialization(NormalizedObject) export class NormalizedItemType extends NormalizedObject { - /** * The label that describes the ResourceType of the Item */ @@ -29,6 +25,6 @@ export class NormalizedItemType extends NormalizedObject { /** * The universally unique identifier of this ItemType */ - @autoserializeAs(new IDToUUIDSerializer(ResourceType.ItemType), 'id') + @autoserializeAs(new IDToUUIDSerializer(ItemType.type.value), 'id') uuid: string; } diff --git a/src/app/core/cache/models/items/normalized-relationship-type.model.ts b/src/app/core/cache/models/items/normalized-relationship-type.model.ts index 326527aaf4..f0f75a03c2 100644 --- a/src/app/core/cache/models/items/normalized-relationship-type.model.ts +++ b/src/app/core/cache/models/items/normalized-relationship-type.model.ts @@ -5,16 +5,15 @@ import { mapsTo, relationship } from '../../builders/build-decorators'; import { NormalizedDSpaceObject } from '../normalized-dspace-object.model'; import { NormalizedObject } from '../normalized-object.model'; import { IDToUUIDSerializer } from '../../id-to-uuid-serializer'; -import { resourceType } from '../../../shared/resource-type.decorator'; +import { NormalizedItemType } from './normalized-item-type.model'; +import { ItemType } from '../../../shared/item-relationships/item-type.model'; /** * Normalized model class for a DSpace RelationshipType */ @mapsTo(RelationshipType) -@resourceType(ResourceType.RelationshipType) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedRelationshipType extends NormalizedObject { - /** * The identifier of this RelationshipType */ @@ -61,19 +60,19 @@ export class NormalizedRelationshipType extends NormalizedObject { @@ -48,12 +48,12 @@ export class NormalizedRelationship extends NormalizedObject { * The type of Relationship */ @autoserialize - @relationship(ResourceType.RelationshipType, false) + @relationship(RelationshipType, false) relationshipType: string; /** * The universally unique identifier of this Relationship */ - @autoserializeAs(new IDToUUIDSerializer(ResourceType.Relationship), 'id') + @autoserializeAs(new IDToUUIDSerializer(Relationship.type.value), 'id') uuid: string; } diff --git a/src/app/core/cache/models/normalized-bitstream-format.model.ts b/src/app/core/cache/models/normalized-bitstream-format.model.ts index 66fbd84176..5ee135b530 100644 --- a/src/app/core/cache/models/normalized-bitstream-format.model.ts +++ b/src/app/core/cache/models/normalized-bitstream-format.model.ts @@ -5,17 +5,13 @@ import { mapsTo } from '../builders/build-decorators'; import { IDToUUIDSerializer } from '../id-to-uuid-serializer'; import { NormalizedObject } from './normalized-object.model'; import { SupportLevel } from './support-level.model'; -import { resourceType } from '../../shared/resource-type.decorator'; -import { ResourceType } from '../../shared/resource-type'; /** * Normalized model class for a Bitstream Format */ @mapsTo(BitstreamFormat) @inheritSerialization(NormalizedObject) -@resourceType(ResourceType.BitstreamFormat) export class NormalizedBitstreamFormat extends NormalizedObject { - /** * Short description of this Bitstream Format */ diff --git a/src/app/core/cache/models/normalized-bitstream.model.ts b/src/app/core/cache/models/normalized-bitstream.model.ts index c2042878da..a9e389fd41 100644 --- a/src/app/core/cache/models/normalized-bitstream.model.ts +++ b/src/app/core/cache/models/normalized-bitstream.model.ts @@ -1,19 +1,17 @@ -import { inheritSerialization, autoserialize } from 'cerialize'; +import { autoserialize, inheritSerialization } from 'cerialize'; import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { Bitstream } from '../../shared/bitstream.model'; import { mapsTo, relationship } from '../builders/build-decorators'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { Item } from '../../shared/item.model'; +import { BitstreamFormat } from '../../shared/bitstream-format.model'; /** * Normalized model class for a DSpace Bitstream */ @mapsTo(Bitstream) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.Bitstream) export class NormalizedBitstream extends NormalizedDSpaceObject { - /** * The size of this bitstream in bytes */ @@ -30,7 +28,7 @@ export class NormalizedBitstream extends NormalizedDSpaceObject { * The format of this Bitstream */ @autoserialize - @relationship(ResourceType.BitstreamFormat, false) + @relationship(BitstreamFormat, false) format: string; /** @@ -43,14 +41,14 @@ export class NormalizedBitstream extends NormalizedDSpaceObject { * An array of Bundles that are direct parents of this Bitstream */ @autoserialize - @relationship(ResourceType.Item, true) + @relationship(Item, true) parents: string[]; /** * The Bundle that owns this Bitstream */ @autoserialize - @relationship(ResourceType.Item, false) + @relationship(Item, false) owner: string; /** diff --git a/src/app/core/cache/models/normalized-bundle.model.ts b/src/app/core/cache/models/normalized-bundle.model.ts index c77a1d027f..3f4e28bca5 100644 --- a/src/app/core/cache/models/normalized-bundle.model.ts +++ b/src/app/core/cache/models/normalized-bundle.model.ts @@ -3,21 +3,19 @@ import { autoserialize, inheritSerialization } from 'cerialize'; import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { Bundle } from '../../shared/bundle.model'; import { mapsTo, relationship } from '../builders/build-decorators'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { Bitstream } from '../../shared/bitstream.model'; /** * Normalized model class for a DSpace Bundle */ @mapsTo(Bundle) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.Bundle) export class NormalizedBundle extends NormalizedDSpaceObject { /** * The primary bitstream of this Bundle */ @autoserialize - @relationship(ResourceType.Bitstream, false) + @relationship(Bitstream, false) primaryBitstream: string; /** @@ -34,7 +32,7 @@ export class NormalizedBundle extends NormalizedDSpaceObject { * List of Bitstreams that are part of this Bundle */ @autoserialize - @relationship(ResourceType.Bitstream, true) + @relationship(Bitstream, true) bitstreams: string[]; } diff --git a/src/app/core/cache/models/normalized-collection.model.ts b/src/app/core/cache/models/normalized-collection.model.ts index e726a967e7..9b3419675a 100644 --- a/src/app/core/cache/models/normalized-collection.model.ts +++ b/src/app/core/cache/models/normalized-collection.model.ts @@ -3,15 +3,21 @@ import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { Collection } from '../../shared/collection.model'; import { mapsTo, relationship } from '../builders/build-decorators'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { NormalizedResourcePolicy } from './normalized-resource-policy.model'; +import { NormalizedBitstream } from './normalized-bitstream.model'; +import { NormalizedCommunity } from './normalized-community.model'; +import { NormalizedItem } from './normalized-item.model'; +import { License } from '../../shared/license.model'; +import { ResourcePolicy } from '../../shared/resource-policy.model'; +import { Bitstream } from '../../shared/bitstream.model'; +import { Community } from '../../shared/community.model'; +import { Item } from '../../shared/item.model'; /** * Normalized model class for a DSpace Collection */ @mapsTo(Collection) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.Collection) export class NormalizedCollection extends NormalizedDSpaceObject { /** @@ -24,42 +30,42 @@ export class NormalizedCollection extends NormalizedDSpaceObject { * The Bitstream that represents the license of this Collection */ @autoserialize - @relationship(ResourceType.License, false) + @relationship(License, false) license: string; /** * The Bitstream that represents the default Access Conditions of this Collection */ @autoserialize - @relationship(ResourceType.ResourcePolicy, false) + @relationship(ResourcePolicy, false) defaultAccessConditions: string; /** * The Bitstream that represents the logo of this Collection */ @deserialize - @relationship(ResourceType.Bitstream, false) + @relationship(Bitstream, false) logo: string; /** * An array of Communities that are direct parents of this Collection */ @deserialize - @relationship(ResourceType.Community, true) + @relationship(Community, true) parents: string[]; /** * The Community that owns this Collection */ @deserialize - @relationship(ResourceType.Community, false) + @relationship(Community, false) owner: string; /** * List of Items that are part of (not necessarily owned by) this Collection */ @deserialize - @relationship(ResourceType.Item, true) + @relationship(Item, true) items: string[]; } diff --git a/src/app/core/cache/models/normalized-community.model.ts b/src/app/core/cache/models/normalized-community.model.ts index 85dce37e82..173760ca72 100644 --- a/src/app/core/cache/models/normalized-community.model.ts +++ b/src/app/core/cache/models/normalized-community.model.ts @@ -1,19 +1,20 @@ -import { autoserialize, deserialize, inheritSerialization, serialize } from 'cerialize'; +import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { Community } from '../../shared/community.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { NormalizedBitstream } from './normalized-bitstream.model'; +import { NormalizedCollection } from './normalized-collection.model'; +import { Bitstream } from '../../shared/bitstream.model'; +import { Collection } from '../../shared/collection.model'; /** * Normalized model class for a DSpace Community */ @mapsTo(Community) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.Community) export class NormalizedCommunity extends NormalizedDSpaceObject { - /** * A string representing the unique handle of this Community */ @@ -24,32 +25,32 @@ export class NormalizedCommunity extends NormalizedDSpaceObject { * The Bitstream that represents the logo of this Community */ @deserialize - @relationship(ResourceType.Bitstream, false) + @relationship(Bitstream, false) logo: string; /** * An array of Communities that are direct parents of this Community */ @deserialize - @relationship(ResourceType.Community, true) + @relationship(Community, true) parents: string[]; /** * The Community that owns this Community */ @deserialize - @relationship(ResourceType.Community, false) + @relationship(Community, false) owner: string; /** * List of Collections that are owned by this Community */ @deserialize - @relationship(ResourceType.Collection, true) + @relationship(Collection, true) collections: string[]; @deserialize - @relationship(ResourceType.Community, true) + @relationship(Community, true) subcommunities: string[]; } diff --git a/src/app/core/cache/models/normalized-dspace-object.model.ts b/src/app/core/cache/models/normalized-dspace-object.model.ts index 65da89a4eb..3c43dd85dc 100644 --- a/src/app/core/cache/models/normalized-dspace-object.model.ts +++ b/src/app/core/cache/models/normalized-dspace-object.model.ts @@ -1,17 +1,14 @@ -import { autoserializeAs, deserializeAs } from 'cerialize'; +import { autoserializeAs, deserializeAs, autoserialize } from 'cerialize'; import { DSpaceObject } from '../../shared/dspace-object.model'; import { MetadataMap, MetadataMapSerializer } from '../../shared/metadata.models'; -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 extends NormalizedObject implements TypedObject { /** @@ -41,8 +38,8 @@ export class NormalizedDSpaceObject extends NormalizedOb /** * A string representing the kind of DSpaceObject, e.g. community, item, … */ - @autoserializeAs(ResourceType) - type: ResourceType; + @autoserialize + type: string; /** * All metadata of this DSpaceObject diff --git a/src/app/core/cache/models/normalized-item.model.ts b/src/app/core/cache/models/normalized-item.model.ts index 0ce2874f0b..4afceb7612 100644 --- a/src/app/core/cache/models/normalized-item.model.ts +++ b/src/app/core/cache/models/normalized-item.model.ts @@ -4,14 +4,18 @@ import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { Item } from '../../shared/item.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { NormalizedCollection } from './normalized-collection.model'; +import { NormalizedBitstream } from './normalized-bitstream.model'; +import { NormalizedRelationship } from './items/normalized-relationship.model'; +import { Collection } from '../../shared/collection.model'; +import { Bitstream } from '../../shared/bitstream.model'; +import { Relationship } from '../../shared/item-relationships/relationship.model'; /** * Normalized model class for a DSpace Item */ @mapsTo(Item) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.Item) export class NormalizedItem extends NormalizedDSpaceObject { /** @@ -48,25 +52,25 @@ export class NormalizedItem extends NormalizedDSpaceObject { * An array of Collections that are direct parents of this Item */ @deserialize - @relationship(ResourceType.Collection, true) + @relationship(Collection, true) parents: string[]; /** * The Collection that owns this Item */ @deserialize - @relationship(ResourceType.Collection, false) + @relationship(Collection, false) owningCollection: string; /** * List of Bitstreams that are owned by this Item */ @deserialize - @relationship(ResourceType.Bitstream, true) + @relationship(Bitstream, true) bitstreams: string[]; @autoserialize - @relationship(ResourceType.Relationship, true) + @relationship(Relationship, true) relationships: string[]; } diff --git a/src/app/core/cache/models/normalized-license.model.ts b/src/app/core/cache/models/normalized-license.model.ts index 105a0f288e..c86d43b961 100644 --- a/src/app/core/cache/models/normalized-license.model.ts +++ b/src/app/core/cache/models/normalized-license.model.ts @@ -2,7 +2,6 @@ import { autoserialize, inheritSerialization } from 'cerialize'; import { mapsTo } from '../builders/build-decorators'; import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { License } from '../../shared/license.model'; -import { resourceType } from '../../shared/resource-type.decorator'; import { ResourceType } from '../../shared/resource-type'; /** @@ -10,7 +9,6 @@ import { ResourceType } from '../../shared/resource-type'; */ @mapsTo(License) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.License) export class NormalizedLicense extends NormalizedDSpaceObject { /** diff --git a/src/app/core/cache/models/normalized-object.model.ts b/src/app/core/cache/models/normalized-object.model.ts index ee758d984d..28cb8494ef 100644 --- a/src/app/core/cache/models/normalized-object.model.ts +++ b/src/app/core/cache/models/normalized-object.model.ts @@ -5,19 +5,12 @@ import { ResourceType } from '../../shared/resource-type'; * An abstract model class for a NormalizedObject. */ export abstract class NormalizedObject implements CacheableObject { - /** * The link to the rest endpoint where this object can be found */ @autoserialize self: string; - /** - * A string representing the kind of DSpaceObject, e.g. community, item, … - */ - @autoserialize - type: ResourceType; - @autoserialize _links: { [name: string]: string diff --git a/src/app/core/cache/models/normalized-resource-policy.model.ts b/src/app/core/cache/models/normalized-resource-policy.model.ts index 2f779d0773..9a9841fe97 100644 --- a/src/app/core/cache/models/normalized-resource-policy.model.ts +++ b/src/app/core/cache/models/normalized-resource-policy.model.ts @@ -5,7 +5,6 @@ import { mapsTo } from '../builders/build-decorators'; import { NormalizedObject } from './normalized-object.model'; import { IDToUUIDSerializer } from '../id-to-uuid-serializer'; import { ActionType } from './action-type.model'; -import { resourceType } from '../../shared/resource-type.decorator'; import { ResourceType } from '../../shared/resource-type'; /** @@ -13,9 +12,7 @@ import { ResourceType } from '../../shared/resource-type'; */ @mapsTo(ResourcePolicy) @inheritSerialization(NormalizedObject) -@resourceType(ResourceType.ResourcePolicy) export class NormalizedResourcePolicy extends NormalizedObject { - /** * The action that is allowed by this Resource Policy */ diff --git a/src/app/core/cache/models/support-level.model.ts b/src/app/core/cache/models/support-level.model.ts index 30f759d55f..103ff2c626 100644 --- a/src/app/core/cache/models/support-level.model.ts +++ b/src/app/core/cache/models/support-level.model.ts @@ -8,7 +8,7 @@ export enum SupportLevel { Unknown = 0, /** - * Unknown for Bitstream Formats that are known to the system, but not fully supported + * Known for Bitstream Formats that are known to the system, but not fully supported */ Known = 1, diff --git a/src/app/core/cache/object-cache.reducer.spec.ts b/src/app/core/cache/object-cache.reducer.spec.ts index 4d4f5c745b..a65e63ab86 100644 --- a/src/app/core/cache/object-cache.reducer.spec.ts +++ b/src/app/core/cache/object-cache.reducer.spec.ts @@ -9,7 +9,7 @@ import { ResetObjectCacheTimestampsAction } from './object-cache.actions'; import { Operation } from 'fast-json-patch'; -import { ResourceType } from '../shared/resource-type'; +import { Item } from '../shared/item.model'; class NullAction extends RemoveFromObjectCacheAction { type = null; @@ -29,7 +29,7 @@ describe('objectCacheReducer', () => { const testState = { [selfLink1]: { data: { - type: ResourceType.Item, + type: Item.type, self: selfLink1, foo: 'bar' }, @@ -41,7 +41,7 @@ describe('objectCacheReducer', () => { }, [selfLink2]: { data: { - type: ResourceType.Item, + type: Item.type, self: requestUUID2, foo: 'baz' }, @@ -70,7 +70,7 @@ describe('objectCacheReducer', () => { it('should add the payload to the cache in response to an ADD action', () => { const state = Object.create(null); - const objectToCache = { self: selfLink1, type: ResourceType.Item }; + const objectToCache = { self: selfLink1, type: Item.type }; const timeAdded = new Date().getTime(); const msToLive = 900000; const requestUUID = requestUUID1; @@ -87,7 +87,7 @@ describe('objectCacheReducer', () => { self: selfLink1, foo: 'baz', somethingElse: true, - type: ResourceType.Item + type: Item.type }; const timeAdded = new Date().getTime(); const msToLive = 900000; @@ -103,7 +103,7 @@ describe('objectCacheReducer', () => { it('should perform the ADD action without affecting the previous state', () => { const state = Object.create(null); - const objectToCache = { self: selfLink1, type: ResourceType.Item }; + const objectToCache = { self: selfLink1, type: Item.type }; const timeAdded = new Date().getTime(); const msToLive = 900000; const requestUUID = requestUUID1; diff --git a/src/app/core/cache/object-cache.reducer.ts b/src/app/core/cache/object-cache.reducer.ts index 9529fb2890..012d12b5f5 100644 --- a/src/app/core/cache/object-cache.reducer.ts +++ b/src/app/core/cache/object-cache.reducer.ts @@ -32,8 +32,8 @@ export interface Patch { operations: Operation[]; } -export interface TypedObject { - type: ResourceType; +export abstract class TypedObject { + static type: ResourceType; } /** @@ -41,7 +41,7 @@ export interface TypedObject { * * A cacheable object should have a self link */ -export interface CacheableObject extends TypedObject { +export class CacheableObject extends TypedObject { uuid?: string; self: string; // isNew: boolean; diff --git a/src/app/core/cache/object-cache.service.spec.ts b/src/app/core/cache/object-cache.service.spec.ts index 20e12108ad..39dc10de2c 100644 --- a/src/app/core/cache/object-cache.service.spec.ts +++ b/src/app/core/cache/object-cache.service.spec.ts @@ -10,13 +10,13 @@ import { RemoveFromObjectCacheAction } from './object-cache.actions'; import { CoreState } from '../core.reducers'; -import { ResourceType } from '../shared/resource-type'; import { NormalizedItem } from './models/normalized-item.model'; import { first } from 'rxjs/operators'; import { Operation } from 'fast-json-patch'; import { RestRequestMethod } from '../data/rest-request-method'; import { AddToSSBAction } from './server-sync-buffer.actions'; import { Patch } from './object-cache.reducer'; +import { Item } from '../shared/item.model'; describe('ObjectCacheService', () => { let service: ObjectCacheService; @@ -28,7 +28,7 @@ describe('ObjectCacheService', () => { const msToLive = 900000; let objectToCache = { self: selfLink, - type: ResourceType.Item + type: Item.type }; let cacheEntry; let invalidCacheEntry; @@ -37,7 +37,7 @@ describe('ObjectCacheService', () => { function init() { objectToCache = { self: selfLink, - type: ResourceType.Item + type: Item.type }; cacheEntry = { data: objectToCache, diff --git a/src/app/core/cache/object-cache.service.ts b/src/app/core/cache/object-cache.service.ts index 4b4eaca196..e18ff3b3a4 100644 --- a/src/app/core/cache/object-cache.service.ts +++ b/src/app/core/cache/object-cache.service.ts @@ -20,7 +20,7 @@ import { import { CacheableObject, ObjectCacheEntry, ObjectCacheState } from './object-cache.reducer'; import { AddToSSBAction } from './server-sync-buffer.actions'; -import { getNormalizedConstructorByType } from '../shared/resource-type.decorator'; +import { getMapsToType } from './builders/build-decorators'; /** * The base selector function to select the object cache in the store @@ -109,7 +109,7 @@ export class ObjectCacheService { } ), map((entry: ObjectCacheEntry) => { - const type: GenericConstructor> = getNormalizedConstructorByType(entry.data.type); + const type: GenericConstructor> = getMapsToType((entry.data as any).type); return Object.assign(new type(), entry.data) as NormalizedObject }) ); diff --git a/src/app/core/config/models/config-submission-definition.model.ts b/src/app/core/config/models/config-submission-definition.model.ts new file mode 100644 index 0000000000..f1799ebb63 --- /dev/null +++ b/src/app/core/config/models/config-submission-definition.model.ts @@ -0,0 +1,19 @@ +import { ConfigObject } from './config.model'; +import { SubmissionSectionModel } from './config-submission-section.model'; +import { PaginatedList } from '../../data/paginated-list'; +import { ResourceType } from '../../shared/resource-type'; + +export class SubmissionDefinitionModel extends ConfigObject { + static type = new ResourceType('submissiondefinition'); + + /** + * A boolean representing if this submission definition is the default or not + */ + isDefault: boolean; + + /** + * A list of SubmissionSectionModel that are present in this submission definition + */ + sections: PaginatedList; + +} diff --git a/src/app/core/config/models/config-submission-definitions.model.ts b/src/app/core/config/models/config-submission-definitions.model.ts index 8bbbc90056..d9892f542f 100644 --- a/src/app/core/config/models/config-submission-definitions.model.ts +++ b/src/app/core/config/models/config-submission-definitions.model.ts @@ -1,17 +1,7 @@ -import { ConfigObject } from './config.model'; -import { SubmissionSectionModel } from './config-submission-section.model'; -import { PaginatedList } from '../../data/paginated-list'; +import { SubmissionDefinitionModel } from './config-submission-definition.model'; +import { ResourceType } from '../../shared/resource-type'; -export class SubmissionDefinitionsModel extends ConfigObject { - - /** - * A boolean representing if this submission definition is the default or not - */ - isDefault: boolean; - - /** - * A list of SubmissionSectionModel that are present in this submission definition - */ - sections: PaginatedList; +export class SubmissionDefinitionsModel extends SubmissionDefinitionModel { + static type = new ResourceType('submissiondefinitions'); } diff --git a/src/app/core/config/models/config-submission-form.model.ts b/src/app/core/config/models/config-submission-form.model.ts new file mode 100644 index 0000000000..a65d285c95 --- /dev/null +++ b/src/app/core/config/models/config-submission-form.model.ts @@ -0,0 +1,22 @@ +import { ConfigObject } from './config.model'; +import { FormFieldModel } from '../../../shared/form/builder/models/form-field.model'; +import { ResourceType } from '../../shared/resource-type'; + +/** + * An interface that define a form row and its properties. + */ +export interface FormRowModel { + fields: FormFieldModel[]; +} + +/** + * A model class for a NormalizedObject. + */ +export class SubmissionFormModel extends ConfigObject { + static type = new ResourceType('submissionform'); + + /** + * An array of [FormRowModel] that are present in this form + */ + rows: FormRowModel[]; +} diff --git a/src/app/core/config/models/config-submission-forms.model.ts b/src/app/core/config/models/config-submission-forms.model.ts index ee0962f0e9..017d7d68cc 100644 --- a/src/app/core/config/models/config-submission-forms.model.ts +++ b/src/app/core/config/models/config-submission-forms.model.ts @@ -1,20 +1,9 @@ -import { ConfigObject } from './config.model'; -import { FormFieldModel } from '../../../shared/form/builder/models/form-field.model'; - -/** - * An interface that define a form row and its properties. - */ -export interface FormRowModel { - fields: FormFieldModel[]; -} +import { SubmissionFormModel } from './config-submission-form.model'; +import { ResourceType } from '../../shared/resource-type'; /** * A model class for a NormalizedObject. */ -export class SubmissionFormsModel extends ConfigObject { - - /** - * An array of [FormRowModel] that are present in this form - */ - rows: FormRowModel[]; +export class SubmissionFormsModel extends SubmissionFormModel { + static type = new ResourceType('submissionforms'); } diff --git a/src/app/core/config/models/config-submission-section.model.ts b/src/app/core/config/models/config-submission-section.model.ts index 377a8869e1..4c560fa631 100644 --- a/src/app/core/config/models/config-submission-section.model.ts +++ b/src/app/core/config/models/config-submission-section.model.ts @@ -1,5 +1,6 @@ import { ConfigObject } from './config.model'; import { SectionsType } from '../../../submission/sections/sections-type'; +import { ResourceType } from '../../shared/resource-type'; /** * An interface that define section visibility and its properties. @@ -10,6 +11,7 @@ export interface SubmissionSectionVisibility { } export class SubmissionSectionModel extends ConfigObject { + static type = new ResourceType('submissionsection'); /** * The header for this section diff --git a/src/app/core/config/models/config-submission-sections.model.ts b/src/app/core/config/models/config-submission-sections.model.ts new file mode 100644 index 0000000000..ae7b133391 --- /dev/null +++ b/src/app/core/config/models/config-submission-sections.model.ts @@ -0,0 +1,6 @@ +import { SubmissionSectionModel } from './config-submission-section.model'; +import { ResourceType } from '../../shared/resource-type'; + +export class SubmissionSectionsModel extends SubmissionSectionModel { + static type = new ResourceType('submissionsections'); +} diff --git a/src/app/core/config/models/normalized-config-submission-definition.model.ts b/src/app/core/config/models/normalized-config-submission-definition.model.ts new file mode 100644 index 0000000000..cb56e01acf --- /dev/null +++ b/src/app/core/config/models/normalized-config-submission-definition.model.ts @@ -0,0 +1,28 @@ +import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; +import { SubmissionSectionModel } from './config-submission-section.model'; +import { PaginatedList } from '../../data/paginated-list'; +import { NormalizedConfigObject } from './normalized-config.model'; +import { SubmissionDefinitionsModel } from './config-submission-definitions.model'; +import { mapsTo } from '../../cache/builders/build-decorators'; +import { SubmissionDefinitionModel } from './config-submission-definition.model'; + +/** + * Normalized class for the configuration describing the submission + */ +@mapsTo(SubmissionDefinitionModel) +@inheritSerialization(NormalizedConfigObject) +export class NormalizedSubmissionDefinitionModel extends NormalizedConfigObject { + + /** + * A boolean representing if this submission definition is the default or not + */ + @autoserialize + isDefault: boolean; + + /** + * A list of SubmissionSectionModel that are present in this submission definition + */ + @autoserializeAs(SubmissionSectionModel) + sections: PaginatedList; + +} diff --git a/src/app/core/config/models/normalized-config-submission-definitions.model.ts b/src/app/core/config/models/normalized-config-submission-definitions.model.ts index 87df838378..4c52d96458 100644 --- a/src/app/core/config/models/normalized-config-submission-definitions.model.ts +++ b/src/app/core/config/models/normalized-config-submission-definitions.model.ts @@ -1,30 +1,13 @@ -import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; -import { SubmissionSectionModel } from './config-submission-section.model'; -import { PaginatedList } from '../../data/paginated-list'; +import { inheritSerialization } from 'cerialize'; import { NormalizedConfigObject } from './normalized-config.model'; import { SubmissionDefinitionsModel } from './config-submission-definitions.model'; -import { resourceType } from '../../shared/resource-type.decorator'; -import { ResourceType } from '../../shared/resource-type'; import { mapsTo } from '../../cache/builders/build-decorators'; +import { NormalizedSubmissionDefinitionModel } from './normalized-config-submission-definition.model'; /** * Normalized class for the configuration describing the submission */ @mapsTo(SubmissionDefinitionsModel) @inheritSerialization(NormalizedConfigObject) -@resourceType(ResourceType.SubmissionDefinitions, ResourceType.SubmissionDefinition) -export class NormalizedSubmissionDefinitionsModel extends NormalizedConfigObject { - - /** - * A boolean representing if this submission definition is the default or not - */ - @autoserialize - isDefault: boolean; - - /** - * A list of SubmissionSectionModel that are present in this submission definition - */ - @autoserializeAs(SubmissionSectionModel) - sections: PaginatedList; - +export class NormalizedSubmissionDefinitionsModel extends NormalizedSubmissionDefinitionModel { } diff --git a/src/app/core/config/models/normalized-config-submission-form.model.ts b/src/app/core/config/models/normalized-config-submission-form.model.ts new file mode 100644 index 0000000000..afdfef4818 --- /dev/null +++ b/src/app/core/config/models/normalized-config-submission-form.model.ts @@ -0,0 +1,18 @@ +import { autoserialize, inheritSerialization } from 'cerialize'; +import { NormalizedConfigObject } from './normalized-config.model'; +import { mapsTo } from '../../cache/builders/build-decorators'; +import { FormRowModel, SubmissionFormModel } from './config-submission-form.model'; + +/** + * Normalized class for the configuration describing the submission form + */ +@mapsTo(SubmissionFormModel) +@inheritSerialization(NormalizedConfigObject) +export class NormalizedSubmissionFormModel extends NormalizedConfigObject { + + /** + * An array of [FormRowModel] that are present in this form + */ + @autoserialize + rows: FormRowModel[]; +} diff --git a/src/app/core/config/models/normalized-config-submission-forms.model.ts b/src/app/core/config/models/normalized-config-submission-forms.model.ts index 2856fe46fc..c040a94587 100644 --- a/src/app/core/config/models/normalized-config-submission-forms.model.ts +++ b/src/app/core/config/models/normalized-config-submission-forms.model.ts @@ -1,21 +1,12 @@ -import { autoserialize, inheritSerialization } from 'cerialize'; -import { NormalizedConfigObject } from './normalized-config.model'; -import { FormRowModel, SubmissionFormsModel } from './config-submission-forms.model'; -import { resourceType } from '../../shared/resource-type.decorator'; -import { ResourceType } from '../../shared/resource-type'; +import { inheritSerialization } from 'cerialize'; import { mapsTo } from '../../cache/builders/build-decorators'; +import { SubmissionFormsModel } from './config-submission-forms.model'; +import { NormalizedSubmissionFormModel } from './normalized-config-submission-form.model'; /** * Normalized class for the configuration describing the submission form */ @mapsTo(SubmissionFormsModel) -@inheritSerialization(NormalizedConfigObject) -@resourceType(ResourceType.SubmissionForm, ResourceType.SubmissionForms) -export class NormalizedSubmissionFormsModel extends NormalizedConfigObject { - - /** - * An array of [FormRowModel] that are present in this form - */ - @autoserialize - rows: FormRowModel[]; +@inheritSerialization(NormalizedSubmissionFormModel) +export class NormalizedSubmissionFormsModel extends NormalizedSubmissionFormModel { } diff --git a/src/app/core/config/models/normalized-config-submission-section.model.ts b/src/app/core/config/models/normalized-config-submission-section.model.ts index 3f9bca8b7b..364a981060 100644 --- a/src/app/core/config/models/normalized-config-submission-section.model.ts +++ b/src/app/core/config/models/normalized-config-submission-section.model.ts @@ -1,21 +1,17 @@ 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 { 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'; /** * Normalized class for the configuration describing the submission section */ @mapsTo(SubmissionSectionModel) @inheritSerialization(NormalizedConfigObject) -@resourceType(ResourceType.SubmissionSection, ResourceType.SubmissionSections) export class NormalizedSubmissionSectionModel extends NormalizedConfigObject { /** diff --git a/src/app/core/config/models/normalized-config-submission-sections.model.ts b/src/app/core/config/models/normalized-config-submission-sections.model.ts new file mode 100644 index 0000000000..fb1e4c671a --- /dev/null +++ b/src/app/core/config/models/normalized-config-submission-sections.model.ts @@ -0,0 +1,18 @@ +import { autoserialize, inheritSerialization } from 'cerialize'; +import { SectionsType } from '../../../submission/sections/sections-type'; +import { NormalizedConfigObject } from './normalized-config.model'; +import { + SubmissionSectionModel, + SubmissionSectionVisibility +} from './config-submission-section.model'; +import { mapsTo } from '../../cache/builders/build-decorators'; +import { SubmissionSectionsModel } from './config-submission-sections.model'; +import { NormalizedSubmissionSectionModel } from './normalized-config-submission-section.model'; + +/** + * Normalized class for the configuration describing the submission section + */ +@mapsTo(SubmissionSectionsModel) +@inheritSerialization(NormalizedSubmissionSectionModel) +export class NormalizedSubmissionSectionsModel extends NormalizedSubmissionSectionModel { +} diff --git a/src/app/core/data/base-response-parsing.service.ts b/src/app/core/data/base-response-parsing.service.ts index 8235790c0c..0ed5dc363c 100644 --- a/src/app/core/data/base-response-parsing.service.ts +++ b/src/app/core/data/base-response-parsing.service.ts @@ -7,8 +7,8 @@ import { GlobalConfig } from '../../../config/global-config.interface'; import { GenericConstructor } from '../shared/generic-constructor'; import { PaginatedList } from './paginated-list'; import { isRestDataObject, isRestPaginatedList } from '../cache/builders/normalized-object-build.service'; -import { getNormalizedConstructorByType } from '../shared/resource-type.decorator'; import { ResourceType } from '../shared/resource-type'; +import { getMapsToType } from '../cache/builders/build-decorators'; /* tslint:disable:max-classes-per-file */ export abstract class BaseResponseParsingService { @@ -84,9 +84,9 @@ export abstract class BaseResponseParsingService { } protected deserialize(obj): any { - const type: ResourceType = obj.type; + const type: string = obj.type; if (hasValue(type)) { - const normObjConstructor = getNormalizedConstructorByType(type) as GenericConstructor; + const normObjConstructor = getMapsToType(type) as GenericConstructor; if (hasValue(normObjConstructor)) { const serializer = new DSpaceRESTv2Serializer(normObjConstructor); diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index 7176756ed9..ad0db51980 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -36,7 +36,7 @@ import { RequestEntry } from './request.reducer'; import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service'; import { ChangeAnalyzer } from './change-analyzer'; import { RestRequestMethod } from './rest-request-method'; -import { getNormalizedConstructorByType } from '../shared/resource-type.decorator'; +import { getMapsToType } from '../cache/builders/build-decorators'; export abstract class DataService { protected abstract requestService: RequestService; @@ -243,7 +243,7 @@ export abstract class DataService { ); const normalizedObject: NormalizedObject = this.dataBuildService.normalize(dso); - const serializedDso = new DSpaceRESTv2Serializer(getNormalizedConstructorByType(dso.type)).serialize(normalizedObject); + const serializedDso = new DSpaceRESTv2Serializer(getMapsToType((dso as any).type)).serialize(normalizedObject); const request$ = endpoint$.pipe( take(1), diff --git a/src/app/core/data/request.effects.ts b/src/app/core/data/request.effects.ts index c85c9a9ff1..9ef85bfe8b 100644 --- a/src/app/core/data/request.effects.ts +++ b/src/app/core/data/request.effects.ts @@ -20,7 +20,7 @@ import { DSpaceRESTv2Serializer } from '../dspace-rest-v2/dspace-rest-v2.seriali import { catchError, filter, flatMap, map, take, tap } from 'rxjs/operators'; import { ErrorResponse, RestResponse } from '../cache/response.models'; import { StoreActionTypes } from '../../store.actions'; -import { getNormalizedConstructorByType } from '../shared/resource-type.decorator'; +import { getMapsToType } from '../cache/builders/build-decorators'; export const addToResponseCacheAndCompleteAction = (request: RestRequest, envConfig: GlobalConfig) => (source: Observable): Observable => @@ -45,7 +45,7 @@ export class RequestEffects { flatMap((request: RestRequest) => { let body; if (isNotEmpty(request.body)) { - const serializer = new DSpaceRESTv2Serializer(getNormalizedConstructorByType(request.body.type)); + const serializer = new DSpaceRESTv2Serializer(getMapsToType(request.body.type)); body = serializer.serialize(request.body); } return this.restApi.request(request.method, request.href, body, request.options).pipe( diff --git a/src/app/core/eperson/models/eperson.model.ts b/src/app/core/eperson/models/eperson.model.ts index f8c11c1201..d99a059e8b 100644 --- a/src/app/core/eperson/models/eperson.model.ts +++ b/src/app/core/eperson/models/eperson.model.ts @@ -4,8 +4,10 @@ import { DSpaceObject } from '../../shared/dspace-object.model'; import { Group } from './group.model'; import { RemoteData } from '../../data/remote-data'; import { PaginatedList } from '../../data/paginated-list'; +import { ResourceType } from '../../shared/resource-type'; export class EPerson extends DSpaceObject { + static type = new ResourceType('eperson'); /** * A string representing the unique handle of this Collection diff --git a/src/app/core/eperson/models/group.model.ts b/src/app/core/eperson/models/group.model.ts index 91ce5d90f3..9c14c20de7 100644 --- a/src/app/core/eperson/models/group.model.ts +++ b/src/app/core/eperson/models/group.model.ts @@ -3,8 +3,10 @@ import { Observable } from 'rxjs'; import { DSpaceObject } from '../../shared/dspace-object.model'; import { PaginatedList } from '../../data/paginated-list'; import { RemoteData } from '../../data/remote-data'; +import { ResourceType } from '../../shared/resource-type'; export class Group extends DSpaceObject { + static type = new ResourceType('group'); /** * List of Groups that this Group belong to diff --git a/src/app/core/eperson/models/normalized-eperson.model.ts b/src/app/core/eperson/models/normalized-eperson.model.ts index 01d9ef3681..bf644a83ef 100644 --- a/src/app/core/eperson/models/normalized-eperson.model.ts +++ b/src/app/core/eperson/models/normalized-eperson.model.ts @@ -5,14 +5,11 @@ import { ListableObject } from '../../../shared/object-collection/shared/listabl import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { EPerson } from './eperson.model'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { Group } from './group.model'; @mapsTo(EPerson) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.EPerson) export class NormalizedEPerson extends NormalizedDSpaceObject implements CacheableObject, ListableObject { - /** * A string representing the unique handle of this EPerson */ @@ -23,7 +20,7 @@ export class NormalizedEPerson extends NormalizedDSpaceObject implement * List of Groups that this EPerson belong to */ @deserialize - @relationship(ResourceType.Group, true) + @relationship(Group, true) groups: string[]; /** diff --git a/src/app/core/eperson/models/normalized-group.model.ts b/src/app/core/eperson/models/normalized-group.model.ts index 776f248127..329ffb8adf 100644 --- a/src/app/core/eperson/models/normalized-group.model.ts +++ b/src/app/core/eperson/models/normalized-group.model.ts @@ -5,19 +5,16 @@ import { ListableObject } from '../../../shared/object-collection/shared/listabl import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { Group } from './group.model'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; @mapsTo(Group) @inheritSerialization(NormalizedDSpaceObject) -@resourceType(ResourceType.Group) export class NormalizedGroup extends NormalizedDSpaceObject implements CacheableObject, ListableObject { /** * List of Groups that this Group belong to */ @deserialize - @relationship(ResourceType.Group, true) + @relationship(Group, true) groups: string[]; /** diff --git a/src/app/core/integration/integration-response-parsing.service.ts b/src/app/core/integration/integration-response-parsing.service.ts index 9793a69218..a98d206402 100644 --- a/src/app/core/integration/integration-response-parsing.service.ts +++ b/src/app/core/integration/integration-response-parsing.service.ts @@ -2,11 +2,7 @@ import { Inject, Injectable } from '@angular/core'; import { RestRequest } from '../data/request.models'; import { ResponseParsingService } from '../data/parsing.service'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; -import { - ErrorResponse, - IntegrationSuccessResponse, - RestResponse -} from '../cache/response.models'; +import { ErrorResponse, IntegrationSuccessResponse, RestResponse } from '../cache/response.models'; import { isNotEmpty } from '../../shared/empty.util'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; @@ -16,7 +12,6 @@ import { ObjectCacheService } from '../cache/object-cache.service'; import { IntegrationModel } from './models/integration.model'; 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 { @@ -47,7 +42,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic protected processResponse(data: PaginatedList): any { const returnList = Array.of(); data.page.forEach((item, index) => { - if (item.type === ResourceType.Authority) { + if (item.type === AuthorityValue.type) { data.page[index] = Object.assign(new AuthorityValue(), item); } }); diff --git a/src/app/core/integration/models/authority.value.ts b/src/app/core/integration/models/authority.value.ts index 31cb0a5787..4c6a7c01cb 100644 --- a/src/app/core/integration/models/authority.value.ts +++ b/src/app/core/integration/models/authority.value.ts @@ -3,11 +3,13 @@ import { isNotEmpty } from '../../../shared/empty.util'; import { PLACEHOLDER_PARENT_METADATA } from '../../../shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model'; import { OtherInformation } from '../../../shared/form/builder/models/form-field-metadata-value.model'; import { MetadataValueInterface } from '../../shared/metadata.models'; +import { ResourceType } from '../../shared/resource-type'; /** * Class representing an authority object */ export class AuthorityValue extends IntegrationModel implements MetadataValueInterface { + static type = new ResourceType('authority'); /** * The identifier of this authority diff --git a/src/app/core/integration/models/normalized-authority-value.model.ts b/src/app/core/integration/models/normalized-authority-value.model.ts index 6e6c7ee798..5ebb61281d 100644 --- a/src/app/core/integration/models/normalized-authority-value.model.ts +++ b/src/app/core/integration/models/normalized-authority-value.model.ts @@ -2,15 +2,12 @@ import { autoserialize, inheritSerialization } from 'cerialize'; import { IntegrationModel } from './integration.model'; import { mapsTo } from '../../cache/builders/build-decorators'; import { AuthorityValue } from './authority.value'; -import { resourceType } from '../../shared/resource-type.decorator'; -import { ResourceType } from '../../shared/resource-type'; /** * Normalized model class for an Authority Value */ @mapsTo(AuthorityValue) @inheritSerialization(IntegrationModel) -@resourceType(ResourceType.Authority) export class NormalizedAuthorityValue extends IntegrationModel { @autoserialize diff --git a/src/app/core/metadata/metadata-field.model.ts b/src/app/core/metadata/metadata-field.model.ts index a79e63cd14..5e20d3f40e 100644 --- a/src/app/core/metadata/metadata-field.model.ts +++ b/src/app/core/metadata/metadata-field.model.ts @@ -7,6 +7,7 @@ import { ResourceType } from '../shared/resource-type'; * Class the represents a metadata field */ export class MetadataField implements ListableObject { + static type = new ResourceType('metadatafield'); /** * The identifier of this metadata field diff --git a/src/app/core/metadata/metadata-schema.model.ts b/src/app/core/metadata/metadata-schema.model.ts index 5d3ce4988b..206cf081ba 100644 --- a/src/app/core/metadata/metadata-schema.model.ts +++ b/src/app/core/metadata/metadata-schema.model.ts @@ -5,6 +5,8 @@ import { ResourceType } from '../shared/resource-type'; * Class that represents a metadata schema */ export class MetadataSchema implements ListableObject { + static type = new ResourceType('metadataschema'); + /** * The unique identifier for this metadata schema */ diff --git a/src/app/core/metadata/normalized-metadata-field.model.ts b/src/app/core/metadata/normalized-metadata-field.model.ts index ba9e5b3b2a..484cbe5066 100644 --- a/src/app/core/metadata/normalized-metadata-field.model.ts +++ b/src/app/core/metadata/normalized-metadata-field.model.ts @@ -1,16 +1,15 @@ import { autoserialize, deserialize } from 'cerialize'; import { mapsTo, relationship } from '../cache/builders/build-decorators'; import { ResourceType } from '../shared/resource-type'; -import { resourceType } from '../shared/resource-type.decorator'; import { MetadataField } from './metadata-field.model'; import { NormalizedObject } from '../cache/models/normalized-object.model'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; +import { MetadataSchema } from './metadata-schema.model'; /** * Class the represents a normalized metadata field */ @mapsTo(MetadataField) -@resourceType(ResourceType.MetadataField) export class NormalizedMetadataField extends NormalizedObject implements ListableObject { /** @@ -47,7 +46,7 @@ export class NormalizedMetadataField extends NormalizedObject imp * The link to the metadata schema of this normalized metadata field */ @deserialize - @relationship(ResourceType.MetadataSchema) + @relationship(MetadataSchema) schema: string; /** diff --git a/src/app/core/metadata/normalized-metadata-schema.model.ts b/src/app/core/metadata/normalized-metadata-schema.model.ts index b1ea78b225..d846b828b9 100644 --- a/src/app/core/metadata/normalized-metadata-schema.model.ts +++ b/src/app/core/metadata/normalized-metadata-schema.model.ts @@ -2,7 +2,6 @@ import { autoserialize } from 'cerialize'; import { NormalizedObject } from '../cache/models/normalized-object.model'; import { mapsTo } from '../cache/builders/build-decorators'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; -import { resourceType } from '../shared/resource-type.decorator'; import { ResourceType } from '../shared/resource-type'; import { MetadataSchema } from './metadata-schema.model'; @@ -10,7 +9,6 @@ import { MetadataSchema } from './metadata-schema.model'; * Normalized class for a DSpace MetadataSchema */ @mapsTo(MetadataSchema) -@resourceType(ResourceType.MetadataSchema) export class NormalizedMetadataSchema extends NormalizedObject implements ListableObject { /** * The unique identifier for this schema diff --git a/src/app/core/registry/registry-metadatafields-response.model.ts b/src/app/core/registry/registry-metadatafields-response.model.ts index 9f0b836ba2..984603e42e 100644 --- a/src/app/core/registry/registry-metadatafields-response.model.ts +++ b/src/app/core/registry/registry-metadatafields-response.model.ts @@ -1,18 +1,20 @@ import { PageInfo } from '../shared/page-info.model'; import { autoserialize, deserialize } from 'cerialize'; -import { MetadataField } from '../metadata/metadata-field.model'; -import { relationship } from '../cache/builders/build-decorators'; import { ResourceType } from '../shared/resource-type'; +import { relationship } from '../cache/builders/build-decorators'; +import { NormalizedMetadataField } from '../metadata/normalized-metadata-field.model'; +import { MetadataField } from '../metadata/metadata-field.model'; /** * Class that represents a response with a registry's metadata fields */ export class RegistryMetadatafieldsResponse { + static type = new ResourceType('metadatafield'); /** * List of metadata fields in the response */ @deserialize - @relationship(ResourceType.MetadataField, true) + @relationship(MetadataField, true) metadatafields: MetadataField[]; /** diff --git a/src/app/core/registry/registry.service.spec.ts b/src/app/core/registry/registry.service.spec.ts index d044633e85..47e306d624 100644 --- a/src/app/core/registry/registry.service.spec.ts +++ b/src/app/core/registry/registry.service.spec.ts @@ -62,14 +62,14 @@ describe('RegistryService', () => { self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1', prefix: 'dc', namespace: 'http://dublincore.org/documents/dcmi-terms/', - type: ResourceType.MetadataSchema + type: MetadataSchema.type }, { id: 2, self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/2', prefix: 'mock', namespace: 'http://dspace.org/mockschema', - type: ResourceType.MetadataSchema + type: MetadataSchema.type } ]; const mockFieldsList = [ @@ -80,7 +80,7 @@ describe('RegistryService', () => { qualifier: 'advisor', scopeNote: null, schema: mockSchemasList[0], - type: ResourceType.MetadataField + type: MetadataField.type }, { id: 2, @@ -89,7 +89,7 @@ describe('RegistryService', () => { qualifier: 'author', scopeNote: null, schema: mockSchemasList[0], - type: ResourceType.MetadataField + type: MetadataField.type }, { id: 3, @@ -98,7 +98,7 @@ describe('RegistryService', () => { qualifier: 'editor', scopeNote: 'test scope note', schema: mockSchemasList[1], - type: ResourceType.MetadataField + type: MetadataField.type }, { id: 4, @@ -107,7 +107,7 @@ describe('RegistryService', () => { qualifier: 'illustrator', scopeNote: null, schema: mockSchemasList[1], - type: ResourceType.MetadataField + type: MetadataField.type } ]; diff --git a/src/app/core/registry/registry.service.ts b/src/app/core/registry/registry.service.ts index eb556f1db3..d816c5eab8 100644 --- a/src/app/core/registry/registry.service.ts +++ b/src/app/core/registry/registry.service.ts @@ -63,7 +63,7 @@ import { HttpHeaders } from '@angular/common/http'; import { TranslateService } from '@ngx-translate/core'; import { MetadataSchema } from '../metadata/metadata-schema.model'; import { MetadataField } from '../metadata/metadata-field.model'; -import { getNormalizedConstructorByType } from '../shared/resource-type.decorator'; +import { getMapsToType } from '../cache/builders/build-decorators'; const metadataRegistryStateSelector = (state: AppState) => state.metadataRegistry; const editMetadataSchemaSelector = createSelector(metadataRegistryStateSelector, (metadataState: MetadataRegistryState) => metadataState.editSchema); @@ -463,7 +463,7 @@ export class RegistryService { distinctUntilChanged() ); - const serializedSchema = new DSpaceRESTv2Serializer(getNormalizedConstructorByType(ResourceType.MetadataSchema)).serialize(schema as NormalizedMetadataSchema); + const serializedSchema = new DSpaceRESTv2Serializer(getMapsToType(MetadataSchema.type)).serialize(schema as NormalizedMetadataSchema); const request$ = endpoint$.pipe( take(1), diff --git a/src/app/core/shared/bitstream-format.model.ts b/src/app/core/shared/bitstream-format.model.ts index a532ea9e75..5509b37041 100644 --- a/src/app/core/shared/bitstream-format.model.ts +++ b/src/app/core/shared/bitstream-format.model.ts @@ -6,7 +6,9 @@ import { ResourceType } from './resource-type'; * Model class for a Bitstream Format */ export class BitstreamFormat implements CacheableObject { + static type = new ResourceType('bitstreamformat'); + bitstreamformat /** * Short description of this Bitstream Format */ diff --git a/src/app/core/shared/bitstream.model.ts b/src/app/core/shared/bitstream.model.ts index 794282e867..887f7d0843 100644 --- a/src/app/core/shared/bitstream.model.ts +++ b/src/app/core/shared/bitstream.model.ts @@ -3,8 +3,10 @@ import { RemoteData } from '../data/remote-data'; import { Item } from './item.model'; import { BitstreamFormat } from './bitstream-format.model'; import { Observable } from 'rxjs'; +import { ResourceType } from './resource-type'; export class Bitstream extends DSpaceObject { + static type = new ResourceType('bitstream'); /** * The size of this bitstream in bytes @@ -40,5 +42,4 @@ export class Bitstream extends DSpaceObject { * The URL to retrieve this Bitstream's file */ content: string; - } diff --git a/src/app/core/shared/browse-entry.model.ts b/src/app/core/shared/browse-entry.model.ts index 3dbba0cdb8..d5d4093c81 100644 --- a/src/app/core/shared/browse-entry.model.ts +++ b/src/app/core/shared/browse-entry.model.ts @@ -1,42 +1,31 @@ -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 { TypedObject } from '../cache/object-cache.reducer'; +import { ResourceType } from './resource-type'; /** * Class object representing a browse entry * This class is not normalized because browse entries do not have self links */ -@resourceType(ResourceType.BrowseEntry) export class BrowseEntry implements ListableObject, TypedObject { - /** - * The resource type of this browse entry - */ - @autoserialize - type: ResourceType; + static type = new ResourceType('browseEntry'); /** * The authority string of this browse entry */ - @autoserialize authority: string; /** * The value of this browse entry */ - @autoserialize value: string; /** * The language of the value of this browse entry */ - @autoserializeAs('valueLang') language: string; /** * The count of this browse entry */ - @autoserialize count: number; } diff --git a/src/app/core/shared/bundle.model.ts b/src/app/core/shared/bundle.model.ts index 3f5b5df877..9b00f6efa0 100644 --- a/src/app/core/shared/bundle.model.ts +++ b/src/app/core/shared/bundle.model.ts @@ -3,8 +3,11 @@ import { Bitstream } from './bitstream.model'; import { Item } from './item.model'; import { RemoteData } from '../data/remote-data'; import { Observable } from 'rxjs'; +import { ResourceType } from './resource-type'; export class Bundle extends DSpaceObject { + static type = new ResourceType('bundle'); + /** * The primary bitstream of this Bundle */ diff --git a/src/app/core/shared/collection.model.ts b/src/app/core/shared/collection.model.ts index 0471d1fbbb..642fe50736 100644 --- a/src/app/core/shared/collection.model.ts +++ b/src/app/core/shared/collection.model.ts @@ -6,8 +6,10 @@ import { Observable } from 'rxjs'; import { License } from './license.model'; import { ResourcePolicy } from './resource-policy.model'; import { PaginatedList } from '../data/paginated-list'; +import { ResourceType } from './resource-type'; export class Collection extends DSpaceObject { + static type = new ResourceType('collection'); /** * A string representing the unique handle of this Collection @@ -80,5 +82,4 @@ export class Collection extends DSpaceObject { owner: Observable>; items: Observable>; - } diff --git a/src/app/core/shared/community.model.ts b/src/app/core/shared/community.model.ts index c4e703fd7f..b61ddfd7f9 100644 --- a/src/app/core/shared/community.model.ts +++ b/src/app/core/shared/community.model.ts @@ -4,8 +4,10 @@ import { Collection } from './collection.model'; import { RemoteData } from '../data/remote-data'; import { Observable } from 'rxjs'; import { PaginatedList } from '../data/paginated-list'; +import { ResourceType } from './resource-type'; export class Community extends DSpaceObject { + static type = new ResourceType('community'); /** * A string representing the unique handle of this Community diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index fb42edd126..26f76c5ce2 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -1,18 +1,26 @@ 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 { isUndefined } from '../../shared/empty.util'; -import { CacheableObject, TypedObject } from '../cache/object-cache.reducer'; +import { hasNoValue, isUndefined } from '../../shared/empty.util'; +import { CacheableObject } 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'; -import { hasNoValue } from '../../shared/empty.util'; +import { ResourceType } from './resource-type'; /** * An abstract model class for a DSpaceObject. */ export class DSpaceObject implements CacheableObject, ListableObject { + /** + * A string representing the kind of DSpaceObject, e.g. community, item, … + */ + static type = new ResourceType('dspaceobject'); private _name: string; @@ -28,11 +36,6 @@ export class DSpaceObject implements CacheableObject, ListableObject { */ uuid: string; - /** - * A string representing the kind of DSpaceObject, e.g. community, item, … - */ - type: ResourceType; - /** * The name for this DSpaceObject */ diff --git a/src/app/core/shared/item-relationships/item-type.model.ts b/src/app/core/shared/item-relationships/item-type.model.ts index e4f98ab653..a0e5adda91 100644 --- a/src/app/core/shared/item-relationships/item-type.model.ts +++ b/src/app/core/shared/item-relationships/item-type.model.ts @@ -5,6 +5,8 @@ import { ResourceType } from '../resource-type'; * Describes a type of Item */ export class ItemType implements CacheableObject { + static type = new ResourceType('entitytype'); + /** * The identifier of this ItemType */ diff --git a/src/app/core/shared/item-relationships/relationship-type.model.ts b/src/app/core/shared/item-relationships/relationship-type.model.ts index 404d8cdb4b..a8e24cc012 100644 --- a/src/app/core/shared/item-relationships/relationship-type.model.ts +++ b/src/app/core/shared/item-relationships/relationship-type.model.ts @@ -8,6 +8,8 @@ import { ItemType } from './item-type.model'; * Describes a type of Relationship between multiple possible Items */ export class RelationshipType implements CacheableObject { + static type = new ResourceType('relationshiptype'); + /** * The link to the rest endpoint where this object can be found */ diff --git a/src/app/core/shared/item-relationships/relationship.model.ts b/src/app/core/shared/item-relationships/relationship.model.ts index df8f04cd8a..bd83c43029 100644 --- a/src/app/core/shared/item-relationships/relationship.model.ts +++ b/src/app/core/shared/item-relationships/relationship.model.ts @@ -8,6 +8,8 @@ import { RelationshipType } from './relationship-type.model'; * Describes a Relationship between two Items */ export class Relationship implements CacheableObject { + static type = new ResourceType('relationship'); + /** * The link to the rest endpoint where this object can be found */ diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index 839103b9f5..515ea3cd69 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -8,8 +8,10 @@ import { Bitstream } from './bitstream.model'; import { hasValue, isNotEmpty, isNotUndefined } from '../../shared/empty.util'; import { PaginatedList } from '../data/paginated-list'; import { Relationship } from './item-relationships/relationship.model'; +import { ResourceType } from './resource-type'; export class Item extends DSpaceObject { + static type = new ResourceType('item'); /** * A string representing the unique handle of this Item diff --git a/src/app/core/shared/license.model.ts b/src/app/core/shared/license.model.ts index a04422242a..fa49e1f430 100644 --- a/src/app/core/shared/license.model.ts +++ b/src/app/core/shared/license.model.ts @@ -1,6 +1,8 @@ import { DSpaceObject } from './dspace-object.model'; +import { ResourceType } from './resource-type'; export class License extends DSpaceObject { + static type = new ResourceType('license'); /** * Is the license custom? diff --git a/src/app/core/shared/normalized-browse-entry.model.ts b/src/app/core/shared/normalized-browse-entry.model.ts new file mode 100644 index 0000000000..42a8fc2178 --- /dev/null +++ b/src/app/core/shared/normalized-browse-entry.model.ts @@ -0,0 +1,42 @@ +import { autoserialize, autoserializeAs } from 'cerialize'; +import { ResourceType } from './resource-type'; +import { BrowseEntry } from './browse-entry.model'; +import { NormalizedObject } from '../cache/models/normalized-object.model'; +import { mapsTo } from '../cache/builders/build-decorators'; + +/** + * Class object representing a browse entry + * This class is not normalized because browse entries do not have self links + */ +@mapsTo(BrowseEntry) +export class NormalizedBrowseEntry extends NormalizedObject { + /** + * The resource type of this browse entry + */ + @autoserialize + type: ResourceType; + + /** + * The authority string of this browse entry + */ + @autoserialize + authority: string; + + /** + * The value of this browse entry + */ + @autoserialize + value: string; + + /** + * The language of the value of this browse entry + */ + @autoserializeAs('valueLang') + language: string; + + /** + * The count of this browse entry + */ + @autoserialize + count: number; +} diff --git a/src/app/core/shared/resource-policy.model.ts b/src/app/core/shared/resource-policy.model.ts index 950d7b92d7..7397076416 100644 --- a/src/app/core/shared/resource-policy.model.ts +++ b/src/app/core/shared/resource-policy.model.ts @@ -6,6 +6,8 @@ import { ActionType } from '../cache/models/action-type.model'; * Model class for a Resource Policy */ export class ResourcePolicy implements CacheableObject { + static type = new ResourceType('resourcePolicy'); + /** * The action that is allowed by this Resource Policy */ diff --git a/src/app/core/shared/resource-type.decorator.ts b/src/app/core/shared/resource-type.decorator.ts deleted file mode 100644 index 76c7f34057..0000000000 --- a/src/app/core/shared/resource-type.decorator.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TypedObject } from '../cache/object-cache.reducer'; -import { GenericConstructor } from './generic-constructor'; -import { ResourceType } from './resource-type'; - -const resourceTypeForObjectMap = new Map(); - -/** - * Decorator function to map resource types to their matching normalized model class constructor - * @param type The resource type used as a key in the map - */ -export function resourceType(...type: ResourceType[]) { - return function decorator(objectConstructor: GenericConstructor) { - if (!objectConstructor) { - return; - } - type.forEach((rt: string) => resourceTypeForObjectMap.set(rt, objectConstructor) - ) - }; -} - -/** - * Method to retrieve the normalized model class constructor based on a resource type - * @param type The resource type to look for - */ -export function getNormalizedConstructorByType(type: ResourceType) { - return resourceTypeForObjectMap.get(type); -} diff --git a/src/app/core/shared/resource-type.ts b/src/app/core/shared/resource-type.ts index 5839e14084..5cdc6e57df 100644 --- a/src/app/core/shared/resource-type.ts +++ b/src/app/core/shared/resource-type.ts @@ -1,31 +1,10 @@ -export enum ResourceType { - DSpaceObject = 'dspaceobject', - Bundle = 'bundle', - Bitstream = 'bitstream', - BitstreamFormat = 'bitstreamformat', - Item = 'item', - Collection = 'collection', - Community = 'community', - EPerson = 'eperson', - Group = 'group', - ResourcePolicy = 'resourcePolicy', - MetadataSchema = 'metadataschema', - MetadataField = 'metadatafield', - Relationship = 'relationship', - RelationshipType = 'relationshiptype', - ItemType = 'entitytype', - License = 'license', - WorkflowItem = 'workflowitem', - WorkspaceItem = 'workspaceitem', - SubmissionDefinitions = 'submissiondefinitions', - SubmissionDefinition = 'submissiondefinition', - SubmissionForm = 'submissionform', - SubmissionForms = 'submissionforms', - SubmissionSections = 'submissionsections', - SubmissionSection = 'submissionsection', - AuthStatus = 'status', - Authority = 'authority', - BrowseEntry = 'browseEntry', - ClaimedTask = 'claimedtask', - PoolTask = 'pooltask' +export class ResourceType { + constructor(public value: string) { + } + // SubmissionDefinitions = 'submissiondefinitions', + // SubmissionDefinition = 'submissiondefinition', + // SubmissionForm = 'submissionform', + // SubmissionForms = 'submissionforms', + // SubmissionSections = 'submissionsections', + // SubmissionSection = 'submissionsection', } diff --git a/src/app/core/submission/models/normalized-workflowitem.model.ts b/src/app/core/submission/models/normalized-workflowitem.model.ts index 354b8e7c06..1f984f29d4 100644 --- a/src/app/core/submission/models/normalized-workflowitem.model.ts +++ b/src/app/core/submission/models/normalized-workflowitem.model.ts @@ -4,42 +4,49 @@ import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { WorkflowItem } from './workflowitem.model'; import { NormalizedSubmissionObject } from './normalized-submission-object.model'; import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { NormalizedItem } from '../../cache/models/normalized-item.model'; +import { NormalizedCollection } from '../../cache/models/normalized-collection.model'; +import { NormalizedEPerson } from '../../eperson/models/normalized-eperson.model'; +import { NormalizedSubmissionDefinitionsModel } from '../../config/models/normalized-config-submission-definitions.model'; +import { Collection } from '../../shared/collection.model'; +import { Item } from '../../shared/item.model'; +import { SubmissionDefinitionsModel } from '../../config/models/config-submission-definitions.model'; +import { EPerson } from '../../eperson/models/eperson.model'; /** * An model class for a NormalizedWorkflowItem. */ @mapsTo(WorkflowItem) @inheritSerialization(NormalizedSubmissionObject) -@resourceType(ResourceType.WorkflowItem) export class NormalizedWorkflowItem extends NormalizedSubmissionObject { + static type = new ResourceType('workflowitem'); /** * The collection this workflowitem belonging to */ @autoserialize - @relationship(ResourceType.Collection, false) + @relationship(Collection, false) collection: string; /** * The item created with this workflowitem */ @autoserialize - @relationship(ResourceType.Item, false) + @relationship(Item, false) item: string; /** * The configuration object that define this workflowitem */ @autoserialize - @relationship(ResourceType.SubmissionDefinition, false) + @relationship(SubmissionDefinitionsModel, false) submissionDefinition: string; /** * The EPerson who submit this workflowitem */ @autoserialize - @relationship(ResourceType.EPerson, false) + @relationship(EPerson, false) submitter: string; } diff --git a/src/app/core/submission/models/normalized-workspaceitem.model.ts b/src/app/core/submission/models/normalized-workspaceitem.model.ts index a381aac00b..6fac3401e2 100644 --- a/src/app/core/submission/models/normalized-workspaceitem.model.ts +++ b/src/app/core/submission/models/normalized-workspaceitem.model.ts @@ -4,9 +4,11 @@ import { WorkspaceItem } from './workspaceitem.model'; import { NormalizedSubmissionObject } from './normalized-submission-object.model'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; -import { ResourceType } from '../../shared/resource-type'; import { WorkflowItem } from './workflowitem.model'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { Item } from '../../shared/item.model'; +import { Collection } from '../../shared/collection.model'; +import { SubmissionDefinitionModel } from '../../config/models/config-submission-definition.model'; +import { EPerson } from '../../eperson/models/eperson.model'; /** * An model class for a NormalizedWorkspaceItem. @@ -14,34 +16,33 @@ import { resourceType } from '../../shared/resource-type.decorator'; @mapsTo(WorkspaceItem) @inheritSerialization(NormalizedDSpaceObject) @inheritSerialization(NormalizedSubmissionObject) -@resourceType(ResourceType.WorkspaceItem) export class NormalizedWorkspaceItem extends NormalizedSubmissionObject { /** * The collection this workspaceitem belonging to */ @autoserialize - @relationship(ResourceType.Collection, false) + @relationship(Collection, false) collection: string; /** * The item created with this workspaceitem */ @autoserialize - @relationship(ResourceType.Item, false) + @relationship(Item, false) item: string; /** * The configuration object that define this workspaceitem */ @autoserialize - @relationship(ResourceType.SubmissionDefinition, false) + @relationship(SubmissionDefinitionModel, false) submissionDefinition: string; /** * The EPerson who submit this workspaceitem */ @autoserialize - @relationship(ResourceType.EPerson, false) + @relationship(EPerson, false) submitter: string; } diff --git a/src/app/core/submission/models/workflowitem.model.ts b/src/app/core/submission/models/workflowitem.model.ts index 4a1666fdef..4cfc4d7fa1 100644 --- a/src/app/core/submission/models/workflowitem.model.ts +++ b/src/app/core/submission/models/workflowitem.model.ts @@ -1,7 +1,9 @@ import { WorkspaceItem } from './workspaceitem.model'; +import { ResourceType } from '../../shared/resource-type'; /** * A model class for a WorkflowItem. */ export class WorkflowItem extends WorkspaceItem { + static type = new ResourceType('workflowitem'); } diff --git a/src/app/core/submission/models/workspaceitem.model.ts b/src/app/core/submission/models/workspaceitem.model.ts index 136ca346c1..c4bb5b7520 100644 --- a/src/app/core/submission/models/workspaceitem.model.ts +++ b/src/app/core/submission/models/workspaceitem.model.ts @@ -1,8 +1,10 @@ import { SubmissionObject } from './submission-object.model'; +import { ResourceType } from '../../shared/resource-type'; /** * A model class for a WorkspaceItem. */ export class WorkspaceItem extends SubmissionObject { + static type = new ResourceType('workspaceitem'); } diff --git a/src/app/core/submission/submission-resource-type.ts b/src/app/core/submission/submission-resource-type.ts deleted file mode 100644 index f5b8e2c423..0000000000 --- a/src/app/core/submission/submission-resource-type.ts +++ /dev/null @@ -1,21 +0,0 @@ -export enum SubmissionResourceType { - Bundle = 'bundle', - Bitstream = 'bitstream', - BitstreamFormat = 'bitstreamformat', - Item = 'item', - Collection = 'collection', - Community = 'community', - ResourcePolicy = 'resourcePolicy', - License = 'license', - EPerson = 'eperson', - Group = 'group', - WorkspaceItem = 'workspaceitem', - WorkflowItem = 'workflowitem', - SubmissionDefinitions = 'submissiondefinitions', - SubmissionDefinition = 'submissiondefinition', - SubmissionForm = 'submissionform', - SubmissionForms = 'submissionforms', - SubmissionSections = 'submissionsections', - SubmissionSection = 'submissionsection', - Authority = 'authority' -} diff --git a/src/app/core/tasks/models/claimed-task-object.model.ts b/src/app/core/tasks/models/claimed-task-object.model.ts index 212e75ed95..2f427f586f 100644 --- a/src/app/core/tasks/models/claimed-task-object.model.ts +++ b/src/app/core/tasks/models/claimed-task-object.model.ts @@ -1,8 +1,9 @@ import { TaskObject } from './task-object.model'; +import { ResourceType } from '../../shared/resource-type'; /** * A model class for a ClaimedTask. */ export class ClaimedTask extends TaskObject { - + static type = new ResourceType('claimedtask'); } diff --git a/src/app/core/tasks/models/normalized-claimed-task-object.model.ts b/src/app/core/tasks/models/normalized-claimed-task-object.model.ts index 8f9283277e..d43a277f02 100644 --- a/src/app/core/tasks/models/normalized-claimed-task-object.model.ts +++ b/src/app/core/tasks/models/normalized-claimed-task-object.model.ts @@ -2,17 +2,16 @@ import { NormalizedTaskObject } from './normalized-task-object.model'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { autoserialize, inheritSerialization } from 'cerialize'; import { ClaimedTask } from './claimed-task-object.model'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { EPerson } from '../../eperson/models/eperson.model'; +import { Group } from '../../eperson/models/group.model'; +import { WorkflowItem } from '../../submission/models/workflowitem.model'; /** * A normalized model class for a ClaimedTask. */ @mapsTo(ClaimedTask) -@resourceType(ResourceType.ClaimedTask) @inheritSerialization(NormalizedTaskObject) export class NormalizedClaimedTask extends NormalizedTaskObject { - /** * The task identifier */ @@ -35,21 +34,21 @@ export class NormalizedClaimedTask extends NormalizedTaskObject { * The eperson object for this task */ @autoserialize - @relationship(ResourceType.EPerson, false) + @relationship(EPerson, false) eperson: string; /** * The group object for this task */ @autoserialize - @relationship(ResourceType.Group, false) + @relationship(Group, false) group: string; /** * The workflowitem object whom this task is related */ @autoserialize - @relationship(ResourceType.WorkflowItem, false) + @relationship(WorkflowItem, false) workflowitem: string; } diff --git a/src/app/core/tasks/models/normalized-pool-task-object.model.ts b/src/app/core/tasks/models/normalized-pool-task-object.model.ts index 06a2b3cacb..bfc782f182 100644 --- a/src/app/core/tasks/models/normalized-pool-task-object.model.ts +++ b/src/app/core/tasks/models/normalized-pool-task-object.model.ts @@ -2,17 +2,15 @@ import { NormalizedTaskObject } from './normalized-task-object.model'; import { PoolTask } from './pool-task-object.model'; import { autoserialize, inheritSerialization } from 'cerialize'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; -import { ResourceType } from '../../shared/resource-type'; -import { resourceType } from '../../shared/resource-type.decorator'; +import { Group } from '../../eperson/models/group.model'; +import { WorkflowItem } from '../../submission/models/workflowitem.model'; /** * A normalized model class for a PoolTask. */ @mapsTo(PoolTask) -@resourceType(ResourceType.PoolTask) @inheritSerialization(NormalizedTaskObject) export class NormalizedPoolTask extends NormalizedTaskObject { - /** * The task identifier */ @@ -35,13 +33,13 @@ export class NormalizedPoolTask extends NormalizedTaskObject { * The group object for this task */ @autoserialize - @relationship(ResourceType.Group, false) + @relationship(Group, false) group: string; /** * The workflowitem object whom this task is related */ @autoserialize - @relationship(ResourceType.WorkflowItem, false) + @relationship(WorkflowItem, false) workflowitem: string; } diff --git a/src/app/core/tasks/models/normalized-task-object.model.ts b/src/app/core/tasks/models/normalized-task-object.model.ts index f45d8305b8..2c96b95393 100644 --- a/src/app/core/tasks/models/normalized-task-object.model.ts +++ b/src/app/core/tasks/models/normalized-task-object.model.ts @@ -1,16 +1,18 @@ import { autoserialize, inheritSerialization } from 'cerialize'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; -import { ResourceType } from '../../shared/resource-type'; import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { TaskObject } from './task-object.model'; import { DSpaceObject } from '../../shared/dspace-object.model'; +import { Group } from '../../eperson/models/group.model'; +import { EPerson } from '../../eperson/models/eperson.model'; +import { WorkflowItem } from '../../submission/models/workflowitem.model'; /** * An abstract normalized model class for a TaskObject. */ @mapsTo(TaskObject) @inheritSerialization(NormalizedDSpaceObject) -export abstract class NormalizedTaskObject extends NormalizedDSpaceObject { +export class NormalizedTaskObject extends NormalizedDSpaceObject { /** * The task identifier @@ -34,20 +36,20 @@ export abstract class NormalizedTaskObject extends Norma * The eperson object for this task */ @autoserialize - @relationship(ResourceType.EPerson, false) + @relationship(EPerson, false) eperson: string; /** * The group object for this task */ @autoserialize - @relationship(ResourceType.Group, false) + @relationship(Group, false) group: string; /** * The workflowitem object whom this task is related */ @autoserialize - @relationship(ResourceType.WorkflowItem, false) + @relationship(WorkflowItem, false) workflowitem: string; } diff --git a/src/app/core/tasks/models/pool-task-object.model.ts b/src/app/core/tasks/models/pool-task-object.model.ts index 8d98d3e1a5..876b62373d 100644 --- a/src/app/core/tasks/models/pool-task-object.model.ts +++ b/src/app/core/tasks/models/pool-task-object.model.ts @@ -1,8 +1,9 @@ import { TaskObject } from './task-object.model'; +import { ResourceType } from '../../shared/resource-type'; /** * A model class for a PoolTask. */ export class PoolTask extends TaskObject { - + static type = new ResourceType('pooltask'); } diff --git a/src/app/core/tasks/models/task-object.model.ts b/src/app/core/tasks/models/task-object.model.ts index de86874e0d..14dbbd7301 100644 --- a/src/app/core/tasks/models/task-object.model.ts +++ b/src/app/core/tasks/models/task-object.model.ts @@ -7,11 +7,13 @@ import { RemoteData } from '../../data/remote-data'; import { WorkflowItem } from '../../submission/models/workflowitem.model'; import { Group } from '../../eperson/models/group.model'; import { EPerson } from '../../eperson/models/eperson.model'; +import { ResourceType } from '../../shared/resource-type'; /** * An abstract model class for a TaskObject. */ export class TaskObject extends DSpaceObject implements CacheableObject, ListableObject { + static type = new ResourceType('taskobject'); /** * The task identifier diff --git a/src/app/shared/alert/alert.component.spec.ts b/src/app/shared/alert/alert.component.spec.ts index e235e27b28..33f48c08ee 100644 --- a/src/app/shared/alert/alert.component.spec.ts +++ b/src/app/shared/alert/alert.component.spec.ts @@ -66,7 +66,7 @@ describe('AlertComponent test suite', () => { compAsAny = comp; comp.content = 'test alert'; comp.dismissible = true; - comp.type = AlertType.Info; + comp.value = AlertType.Info; fixture.detectChanges(); }); diff --git a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts index 3f52f0e46a..1b44970402 100644 --- a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts +++ b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts @@ -103,7 +103,7 @@ describe('ComColFormComponent', () => { ...randomMD, ...abstractMD }, - type: ResourceType.Community + type: Community.type }, ) ); diff --git a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.ts b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.ts index e24676a646..6a96892b06 100644 --- a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.ts +++ b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.ts @@ -10,7 +10,7 @@ import { TranslateService } from '@ngx-translate/core'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { MetadataMap, MetadataValue } from '../../../core/shared/metadata.models'; import { isNotEmpty } from '../../empty.util'; -import { ResourceType } from '../../../core/shared/resource-type'; +import { Community } from '../../../core/shared/community.model'; /** * A form for creating and editing Communities or Collections @@ -99,7 +99,7 @@ export class ComColFormComponent implements OnInit { ...this.dso.metadata, ...formMetadata }, - type: ResourceType.Community + type: Community.type }); this.submitForm.emit(updatedDSO); } diff --git a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts index e2e73bae14..57c860e04f 100644 --- a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts +++ b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts @@ -47,10 +47,10 @@ export class DeleteComColPageComponent implements .pipe(first()) .subscribe((success: boolean) => { if (success) { - const successMessage = this.translate.instant(dso.type + '.delete.notification.success'); + const successMessage = this.translate.instant((dso as any).type + '.delete.notification.success'); this.notifications.success(successMessage) } else { - const errorMessage = this.translate.instant(dso.type + '.delete.notification.fail'); + const errorMessage = this.translate.instant((dso as any).type + '.delete.notification.fail'); this.notifications.error(errorMessage) } this.router.navigate(['/']); diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts index 54568a98d5..e33d5d9ba1 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts @@ -51,7 +51,7 @@ describe('DSOSelectorComponent', () => { component = fixture.componentInstance; debugElement = fixture.debugElement; component.currentDSOId = currentDSOId; - component.type = type; + component.value = type; fixture.detectChanges(); }); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model.ts index 7a357dfc31..e6d2b95afc 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model.ts @@ -1,7 +1,7 @@ import { DynamicFormControlLayout, serializable } from '@ng-dynamic-forms/core'; -import { FormRowModel } from '../../../../../../core/config/models/config-submission-forms.model'; import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-input.model'; import { isEmpty, isNull } from '../../../../../empty.util'; +import { FormRowModel } from '../../../../../../core/config/models/config-submission-form.model'; export const DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP = 'RELATION'; export const PLACEHOLDER_PARENT_METADATA = '#PLACEHOLDER_PARENT_METADATA_VALUE#'; diff --git a/src/app/shared/form/builder/models/form-field.model.ts b/src/app/shared/form/builder/models/form-field.model.ts index 439bf89f8f..39f2d6b9f8 100644 --- a/src/app/shared/form/builder/models/form-field.model.ts +++ b/src/app/shared/form/builder/models/form-field.model.ts @@ -1,7 +1,7 @@ import { autoserialize } from 'cerialize'; -import { FormRowModel } from '../../../../core/config/models/config-submission-forms.model'; import { LanguageCode } from './form-field-language-value.model'; import { FormFieldMetadataValueObject } from './form-field-metadata-value.model'; +import { FormRowModel } from '../../../../core/config/models/config-submission-form.model'; export class FormFieldModel { diff --git a/src/app/shared/form/builder/parsers/relation-group-field-parser.ts b/src/app/shared/form/builder/parsers/relation-group-field-parser.ts index ca0469ef1a..b3f6e749f3 100644 --- a/src/app/shared/form/builder/parsers/relation-group-field-parser.ts +++ b/src/app/shared/form/builder/parsers/relation-group-field-parser.ts @@ -3,12 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu import { FormFieldModel } from '../models/form-field.model'; import { isNotEmpty } from '../../../empty.util'; -import { FormRowModel } from '../../../../core/config/models/config-submission-forms.model'; import { DynamicRelationGroupModel, DynamicRelationGroupModelConfig, PLACEHOLDER_PARENT_METADATA } from '../ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model'; +import { FormRowModel } from '../../../../core/config/models/config-submission-form.model'; export class RelationGroupFieldParser extends FieldParser { diff --git a/src/app/shared/mocks/mock-form-models.ts b/src/app/shared/mocks/mock-form-models.ts index 5851da94be..f2fc38c420 100644 --- a/src/app/shared/mocks/mock-form-models.ts +++ b/src/app/shared/mocks/mock-form-models.ts @@ -5,7 +5,6 @@ import { DynamicRowArrayModelConfig } from '../form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-array-model'; import { DynamicSelectModel } from '@ng-dynamic-forms/core'; -import { FormRowModel } from '../../core/config/models/config-submission-forms.model'; import { SubmissionScopeType } from '../../core/submission/submission-scope-type'; import { DynamicRelationGroupModel } from '../form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model'; import { FormFieldModel } from '../form/builder/models/form-field.model'; @@ -13,6 +12,7 @@ import { AuthorityOptions } from '../../core/integration/models/authority-option import { AuthorityValue } from '../../core/integration/models/authority.value'; import { FormFieldMetadataValueObject } from '../form/builder/models/form-field-metadata-value.model'; import { DynamicRowGroupModel } from '../form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-group-model'; +import { FormRowModel } from '../../core/config/models/config-submission-form.model'; export const qualdropSelectConfig = { name: 'dc.identifier_QUALDROP_METADATA', diff --git a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts index ef083cfab9..30f1d7775f 100644 --- a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts @@ -66,7 +66,7 @@ const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdIt const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); mockObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem), id: '1234' }); -describe('ClaimedTaskActionsComponent', () => { +fdescribe('ClaimedTaskActionsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ diff --git a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts index 5aa0cd72b5..c37a7eb4db 100644 --- a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts +++ b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.ts @@ -62,7 +62,7 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent> { - public getConstructor(type: ResourceType): TService { - switch (type) { - case ResourceType.Item: { - return ItemDataService as any; - } - case ResourceType.WorkspaceItem: { - return WorkspaceitemDataService as any; - } - case ResourceType.WorkflowItem: { - return WorkflowItemDataService as any; - } - case ResourceType.ClaimedTask: { - return ClaimedTaskDataService as any; - } - case ResourceType.PoolTask: { - return PoolTaskDataService as any; - } - default: { - return undefined; - } - } - } -} diff --git a/src/app/shared/mydspace-actions/mydspace-actions.ts b/src/app/shared/mydspace-actions/mydspace-actions.ts index 8e465644c3..2e86726be7 100644 --- a/src/app/shared/mydspace-actions/mydspace-actions.ts +++ b/src/app/shared/mydspace-actions/mydspace-actions.ts @@ -3,7 +3,6 @@ import { Injector, Input } from '@angular/core'; import { find } from 'rxjs/operators'; -import { MydspaceActionsServiceFactory } from './mydspace-actions-service.factory'; import { RemoteData } from '../../core/data/remote-data'; import { DataService } from '../../core/data/data.service'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; @@ -11,6 +10,7 @@ import { ResourceType } from '../../core/shared/resource-type'; import { NotificationOptions } from '../notifications/models/notification-options.model'; import { NotificationsService } from '../notifications/notifications.service'; import { TranslateService } from '@ngx-translate/core'; +import { getMapsToType } from '../../core/cache/builders/build-decorators'; /** * Abstract class for all different representations of mydspace actions @@ -42,8 +42,7 @@ export abstract class MyDSpaceActionsComponent(); - this.objectDataService = injector.get(factory.getConstructor(objectType)); + this.objectDataService = injector.get(getMapsToType(objectType)); } /** diff --git a/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.ts b/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.ts index a143045334..2e32541e09 100644 --- a/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.ts +++ b/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.ts @@ -53,7 +53,7 @@ export class PoolTaskActionsComponent extends MyDSpaceActionsComponent { cdr.detectChanges(); const action = new NewNotificationAction(notification); - action.type = 'NothingToDo, return only the state'; + action.value = 'NothingToDo, return only the state'; const lastState = notificationsReducer(stateBis, action); expect(lastState.length).toEqual(1); diff --git a/src/app/shared/search-form/search-form.component.spec.ts b/src/app/shared/search-form/search-form.component.spec.ts index a60aeb8054..fb632c533a 100644 --- a/src/app/shared/search-form/search-form.component.spec.ts +++ b/src/app/shared/search-form/search-form.component.spec.ts @@ -128,7 +128,7 @@ export const objects: DSpaceObject[] = [ self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/communities/7669c72a-3f2a-451f-a3b9-9210e7a4c02f', id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', - type: ResourceType.Community, + type: Community.type, metadata: { 'dc.description': [ { @@ -182,7 +182,7 @@ export const objects: DSpaceObject[] = [ self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/communities/9076bd16-e69a-48d6-9e41-0238cb40d863', id: '9076bd16-e69a-48d6-9e41-0238cb40d863', uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', - type: ResourceType.Community, + type: Community.type, metadata: { 'dc.description': [ {