refactored resource type and type mapping

This commit is contained in:
lotte
2019-06-24 16:29:54 +02:00
parent b846384ba7
commit f980b55c1c
101 changed files with 440 additions and 427 deletions

View File

@@ -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<Collection> {
@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

View File

@@ -20,9 +20,9 @@ export class CommunityFormComponent extends ComColFormComponent<Community> {
@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

View File

@@ -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': [
{

View File

@@ -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<RemoteData<DSpaceObject>> = this.dspaceObjectService.findById(scopeId).pipe(getSucceededRemoteData());
const scopeList: Observable<DSpaceObject[]> = scopeObject.pipe(
switchMap((dsoRD: RemoteData<DSpaceObject>) => {
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]) => {

View File

@@ -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;
}

View File

@@ -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<AuthStatus> {
/**
* The unique identifier of this auth status
@@ -37,7 +36,7 @@ export class NormalizedAuthStatus extends NormalizedObject<AuthStatus> {
/**
* The self link to the eperson of this auth status
*/
@relationship(ResourceType.EPerson, false)
@relationship(EPerson, false)
@autoserialize
eperson: string;

View File

@@ -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<CacheableObject>) {
return Reflect.metadata(mapsToMetadataKey, value);
export function mapsTo(value: GenericConstructor<TypedObject>) {
return function decorator(objectConstructor: GenericConstructor<TypedObject>) {
Reflect.defineMetadata(mapsToMetadataKey, value, objectConstructor);
mapsToType((value as any).type, objectConstructor);
}
}
function mapsToType(value: ResourceType, objectConstructor: GenericConstructor<TypedObject>) {
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<T extends CacheableObject>(value: GenericConstructor<T>, 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);
};
}

View File

@@ -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<T extends TypedObject>(domainModel: T): NormalizedObject<T> {
const normalizedConstructor = getNormalizedConstructorByType(domainModel.type);
const normalizedConstructor = getMapsToType((domainModel as any).type);
const relationships = getRelationships(normalizedConstructor) || [];
const normalizedModel = Object.assign({}, domainModel) as any;

View File

@@ -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<ItemType> {
/**
* The label that describes the ResourceType of the Item
*/
@@ -29,6 +25,6 @@ export class NormalizedItemType extends NormalizedObject<ItemType> {
/**
* The universally unique identifier of this ItemType
*/
@autoserializeAs(new IDToUUIDSerializer(ResourceType.ItemType), 'id')
@autoserializeAs(new IDToUUIDSerializer(ItemType.type.value), 'id')
uuid: string;
}

View File

@@ -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<RelationshipType> {
/**
* The identifier of this RelationshipType
*/
@@ -61,19 +60,19 @@ export class NormalizedRelationshipType extends NormalizedObject<RelationshipTyp
* The type of Item found to the left of this RelationshipType
*/
@autoserialize
@relationship(ResourceType.ItemType, false)
@relationship(ItemType, false)
leftType: string;
/**
* The type of Item found to the right of this RelationshipType
*/
@autoserialize
@relationship(ResourceType.ItemType, false)
@relationship(ItemType, false)
rightType: string;
/**
* The universally unique identifier of this RelationshipType
*/
@autoserializeAs(new IDToUUIDSerializer(ResourceType.RelationshipType), 'id')
@autoserializeAs(new IDToUUIDSerializer(RelationshipType.type.value), 'id')
uuid: string;
}

View File

@@ -4,13 +4,13 @@ import { ResourceType } from '../../../shared/resource-type';
import { mapsTo, relationship } from '../../builders/build-decorators';
import { NormalizedObject } from '../normalized-object.model';
import { IDToUUIDSerializer } from '../../id-to-uuid-serializer';
import { resourceType } from '../../../shared/resource-type.decorator';
import { NormalizedRelationshipType } from './normalized-relationship-type.model';
import { RelationshipType } from '../../../shared/item-relationships/relationship-type.model';
/**
* Normalized model class for a DSpace Relationship
*/
@mapsTo(Relationship)
@resourceType(ResourceType.Relationship)
@inheritSerialization(NormalizedObject)
export class NormalizedRelationship extends NormalizedObject<Relationship> {
@@ -48,12 +48,12 @@ export class NormalizedRelationship extends NormalizedObject<Relationship> {
* 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;
}

View File

@@ -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<BitstreamFormat> {
/**
* Short description of this Bitstream Format
*/

View File

@@ -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<Bitstream> {
/**
* The size of this bitstream in bytes
*/
@@ -30,7 +28,7 @@ export class NormalizedBitstream extends NormalizedDSpaceObject<Bitstream> {
* The format of this Bitstream
*/
@autoserialize
@relationship(ResourceType.BitstreamFormat, false)
@relationship(BitstreamFormat, false)
format: string;
/**
@@ -43,14 +41,14 @@ export class NormalizedBitstream extends NormalizedDSpaceObject<Bitstream> {
* 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;
/**

View File

@@ -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<Bundle> {
/**
* 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<Bundle> {
* List of Bitstreams that are part of this Bundle
*/
@autoserialize
@relationship(ResourceType.Bitstream, true)
@relationship(Bitstream, true)
bitstreams: string[];
}

View File

@@ -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<Collection> {
/**
@@ -24,42 +30,42 @@ export class NormalizedCollection extends NormalizedDSpaceObject<Collection> {
* 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[];
}

View File

@@ -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<Community> {
/**
* A string representing the unique handle of this Community
*/
@@ -24,32 +25,32 @@ export class NormalizedCommunity extends NormalizedDSpaceObject<Community> {
* 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[];
}

View File

@@ -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<T extends DSpaceObject> extends NormalizedObject<T> implements TypedObject {
/**
@@ -41,8 +38,8 @@ export class NormalizedDSpaceObject<T extends DSpaceObject> 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

View File

@@ -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<Item> {
/**
@@ -48,25 +52,25 @@ export class NormalizedItem extends NormalizedDSpaceObject<Item> {
* 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[];
}

View File

@@ -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<License> {
/**

View File

@@ -5,19 +5,12 @@ import { ResourceType } from '../../shared/resource-type';
* An abstract model class for a NormalizedObject.
*/
export abstract class NormalizedObject<T extends TypedObject> 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

View File

@@ -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<ResourcePolicy> {
/**
* The action that is allowed by this Resource Policy
*/

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<NormalizedObject<T>> = getNormalizedConstructorByType(entry.data.type);
const type: GenericConstructor<NormalizedObject<T>> = getMapsToType((entry.data as any).type);
return Object.assign(new type(), entry.data) as NormalizedObject<T>
})
);

View File

@@ -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<SubmissionSectionModel>;
}

View File

@@ -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<SubmissionSectionModel>;
export class SubmissionDefinitionsModel extends SubmissionDefinitionModel {
static type = new ResourceType('submissiondefinitions');
}

View File

@@ -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[];
}

View File

@@ -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');
}

View File

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

View File

@@ -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');
}

View File

@@ -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<SubmissionDefinitionModel> {
/**
* 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<SubmissionSectionModel>;
}

View File

@@ -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<SubmissionDefinitionsModel> {
/**
* 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<SubmissionSectionModel>;
export class NormalizedSubmissionDefinitionsModel extends NormalizedSubmissionDefinitionModel {
}

View File

@@ -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<SubmissionFormModel> {
/**
* An array of [FormRowModel] that are present in this form
*/
@autoserialize
rows: FormRowModel[];
}

View File

@@ -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<SubmissionFormsModel> {
/**
* An array of [FormRowModel] that are present in this form
*/
@autoserialize
rows: FormRowModel[];
@inheritSerialization(NormalizedSubmissionFormModel)
export class NormalizedSubmissionFormsModel extends NormalizedSubmissionFormModel {
}

View File

@@ -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<SubmissionSectionModel> {
/**

View File

@@ -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 {
}

View File

@@ -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<ObjectDomain>(obj): any {
const type: ResourceType = obj.type;
const type: string = obj.type;
if (hasValue(type)) {
const normObjConstructor = getNormalizedConstructorByType(type) as GenericConstructor<ObjectDomain>;
const normObjConstructor = getMapsToType(type) as GenericConstructor<ObjectDomain>;
if (hasValue(normObjConstructor)) {
const serializer = new DSpaceRESTv2Serializer(normObjConstructor);

View File

@@ -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<T extends CacheableObject> {
protected abstract requestService: RequestService;
@@ -243,7 +243,7 @@ export abstract class DataService<T extends CacheableObject> {
);
const normalizedObject: NormalizedObject<T> = this.dataBuildService.normalize<T>(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),

View File

@@ -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<RestResponse>): Observable<RequestCompleteAction> =>
@@ -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(

View File

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

View File

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

View File

@@ -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<EPerson> implements CacheableObject, ListableObject {
/**
* A string representing the unique handle of this EPerson
*/
@@ -23,7 +20,7 @@ export class NormalizedEPerson extends NormalizedDSpaceObject<EPerson> implement
* List of Groups that this EPerson belong to
*/
@deserialize
@relationship(ResourceType.Group, true)
@relationship(Group, true)
groups: string[];
/**

View File

@@ -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<Group> implements CacheableObject, ListableObject {
/**
* List of Groups that this Group belong to
*/
@deserialize
@relationship(ResourceType.Group, true)
@relationship(Group, true)
groups: string[];
/**

View File

@@ -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<IntegrationModel>): 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);
}
});

View File

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

View File

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

View File

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

View File

@@ -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
*/

View File

@@ -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<MetadataField> implements ListableObject {
/**
@@ -47,7 +46,7 @@ export class NormalizedMetadataField extends NormalizedObject<MetadataField> imp
* The link to the metadata schema of this normalized metadata field
*/
@deserialize
@relationship(ResourceType.MetadataSchema)
@relationship(MetadataSchema)
schema: string;
/**

View File

@@ -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<MetadataSchema> implements ListableObject {
/**
* The unique identifier for this schema

View File

@@ -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[];
/**

View File

@@ -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
}
];

View File

@@ -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),

View File

@@ -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
*/

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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
*/

View File

@@ -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<RemoteData<Collection>>;
items: Observable<RemoteData<Item[]>>;
}

View File

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

View File

@@ -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
*/

View File

@@ -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
*/

View File

@@ -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
*/

View File

@@ -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
*/

View File

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

View File

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

View File

@@ -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<BrowseEntry> {
/**
* 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;
}

View File

@@ -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
*/

View File

@@ -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<TypedObject>) {
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);
}

View File

@@ -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',
}

View File

@@ -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<WorkflowItem> {
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;
}

View File

@@ -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<WorkflowItem> {
/**
* 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;
}

View File

@@ -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');
}

View File

@@ -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');
}

View File

@@ -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'
}

View File

@@ -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');
}

View File

@@ -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<ClaimedTask> {
/**
* The task identifier
*/
@@ -35,21 +34,21 @@ export class NormalizedClaimedTask extends NormalizedTaskObject<ClaimedTask> {
* 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;
}

View File

@@ -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<PoolTask> {
/**
* The task identifier
*/
@@ -35,13 +33,13 @@ export class NormalizedPoolTask extends NormalizedTaskObject<PoolTask> {
* 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;
}

View File

@@ -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<T extends DSpaceObject> extends NormalizedDSpaceObject<T> {
export class NormalizedTaskObject<T extends DSpaceObject> extends NormalizedDSpaceObject<T> {
/**
* The task identifier
@@ -34,20 +36,20 @@ export abstract class NormalizedTaskObject<T extends DSpaceObject> 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;
}

View File

@@ -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');
}

View File

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

View File

@@ -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();
});

View File

@@ -103,7 +103,7 @@ describe('ComColFormComponent', () => {
...randomMD,
...abstractMD
},
type: ResourceType.Community
type: Community.type
},
)
);

View File

@@ -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<T extends DSpaceObject> implements OnInit {
...this.dso.metadata,
...formMetadata
},
type: ResourceType.Community
type: Community.type
});
this.submitForm.emit(updatedDSO);
}

View File

@@ -47,10 +47,10 @@ export class DeleteComColPageComponent<TDomain extends DSpaceObject> 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(['/']);

View File

@@ -51,7 +51,7 @@ describe('DSOSelectorComponent', () => {
component = fixture.componentInstance;
debugElement = fixture.debugElement;
component.currentDSOId = currentDSOId;
component.type = type;
component.value = type;
fixture.detectChanges();
});

View File

@@ -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#';

View File

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

View File

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

View File

@@ -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',

View File

@@ -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: [

View File

@@ -62,7 +62,7 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<Claime
protected router: Router,
protected notificationsService: NotificationsService,
protected translate: TranslateService) {
super(ResourceType.ClaimedTask, injector, router, notificationsService, translate);
super(ClaimedTask.type, injector, router, notificationsService, translate);
}
/**

View File

@@ -6,7 +6,6 @@ import { TranslateService } from '@ngx-translate/core';
import { MyDSpaceActionsComponent } from '../mydspace-actions';
import { ItemDataService } from '../../../core/data/item-data.service';
import { Item } from '../../../core/shared/item.model';
import { ResourceType } from '../../../core/shared/resource-type';
import { NotificationsService } from '../../notifications/notifications.service';
/**
@@ -37,7 +36,7 @@ export class ItemActionsComponent extends MyDSpaceActionsComponent<Item, ItemDat
protected router: Router,
protected notificationsService: NotificationsService,
protected translate: TranslateService) {
super(ResourceType.Item, injector, router, notificationsService, translate);
super(Item.type, injector, router, notificationsService, translate);
}
/**

View File

@@ -1,36 +0,0 @@
import { DataService } from '../../core/data/data.service';
import { ResourceType } from '../../core/shared/resource-type';
import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-data.service';
import { ClaimedTaskDataService } from '../../core/tasks/claimed-task-data.service';
import { PoolTaskDataService } from '../../core/tasks/pool-task-data.service';
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
import { CacheableObject } from '../../core/cache/object-cache.reducer';
import { ItemDataService } from '../../core/data/item-data.service';
/**
* Class to return DataService for given ResourceType
*/
export class MydspaceActionsServiceFactory<T extends CacheableObject, TService extends DataService<T>> {
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;
}
}
}
}

View File

@@ -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<T extends DSpaceObject, TService
protected router: Router,
protected notificationsService: NotificationsService,
protected translate: TranslateService) {
const factory = new MydspaceActionsServiceFactory<T, TService>();
this.objectDataService = injector.get(factory.getConstructor(objectType));
this.objectDataService = injector.get(getMapsToType(objectType));
}
/**

View File

@@ -53,7 +53,7 @@ export class PoolTaskActionsComponent extends MyDSpaceActionsComponent<PoolTask,
protected router: Router,
protected notificationsService: NotificationsService,
protected translate: TranslateService) {
super(ResourceType.PoolTask, injector, router, notificationsService, translate);
super(PoolTask.type, injector, router, notificationsService, translate);
}
/**

View File

@@ -6,7 +6,6 @@ import { TranslateService } from '@ngx-translate/core';
import { MyDSpaceActionsComponent } from '../mydspace-actions';
import { WorkflowItem } from '../../../core/submission/models/workflowitem.model';
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
import { ResourceType } from '../../../core/shared/resource-type';
import { NotificationsService } from '../../notifications/notifications.service';
/**
@@ -36,7 +35,7 @@ export class WorkflowitemActionsComponent extends MyDSpaceActionsComponent<Workf
protected router: Router,
protected notificationsService: NotificationsService,
protected translate: TranslateService) {
super(ResourceType.WorkflowItem, injector, router, notificationsService, translate);
super(WorkflowItem.type, injector, router, notificationsService, translate);
}
/**

View File

@@ -46,7 +46,7 @@ export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent<Work
protected modalService: NgbModal,
protected notificationsService: NotificationsService,
protected translate: TranslateService) {
super(ResourceType.WorkspaceItem, injector, router, notificationsService, translate);
super(WorkspaceItem.type, injector, router, notificationsService, translate);
}
/**

View File

@@ -123,7 +123,7 @@ describe('Notifications reducer', () => {
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);

Some files were not shown because too many files have changed in this diff Show More