[CSTPER-222] handle metadata reading for communities and collections

Removed handle field and the setter from community and collection models.
This commit is contained in:
Alessandro Martelli
2020-11-18 12:08:57 +01:00
parent fa8ecd16a7
commit 2369892c3f
8 changed files with 47 additions and 45 deletions

View File

@@ -5,11 +5,9 @@ describe('Collection', () => {
describe('Collection handle value', () => { describe('Collection handle value', () => {
let metadataValue; let metadataValue;
let handleValue;
beforeEach(() => { beforeEach(() => {
metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]}; metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]};
handleValue = '11111111111/1';
}) })
it('should return the handle value from metadata', () => { it('should return the handle value from metadata', () => {
@@ -17,13 +15,8 @@ describe('Collection', () => {
expect(community.handle).toEqual('123456789/1'); expect(community.handle).toEqual('123456789/1');
}); });
it('should return the handle value from metadata even when the handle field is provided', () => {
const community = Object.assign(new Collection(), { handle: handleValue, metadata: metadataValue });
expect(community.handle).toEqual('123456789/1');
});
it('should return undefined if the handle value from metadata is not present', () => { it('should return undefined if the handle value from metadata is not present', () => {
const community = Object.assign(new Collection(), { handle: handleValue }); const community = Object.assign(new Collection(), { });
expect(community.handle).toEqual(undefined); expect(community.handle).toEqual(undefined);
}); });
}); });

View File

@@ -1,4 +1,4 @@
import { deserialize, deserializeAs, inheritSerialization } from 'cerialize'; import { deserialize, inheritSerialization } from 'cerialize';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { link, typedObject } from '../cache/builders/build-decorators'; import { link, typedObject } from '../cache/builders/build-decorators';
import { PaginatedList } from '../data/paginated-list'; import { PaginatedList } from '../data/paginated-list';
@@ -15,17 +15,12 @@ import { RESOURCE_POLICY } from '../resource-policy/models/resource-policy.resou
import { COMMUNITY } from './community.resource-type'; import { COMMUNITY } from './community.resource-type';
import { Community } from './community.model'; import { Community } from './community.model';
import { ChildHALResource } from './child-hal-resource.model'; import { ChildHALResource } from './child-hal-resource.model';
import { excludeFromEquals } from '../utilities/equals.decorators';
@typedObject @typedObject
@inheritSerialization(DSpaceObject) @inheritSerialization(DSpaceObject)
export class Collection extends DSpaceObject implements ChildHALResource { export class Collection extends DSpaceObject implements ChildHALResource {
static type = COLLECTION; static type = COLLECTION;
@excludeFromEquals
@deserializeAs('handle')
private _handle: string;
/** /**
* The {@link HALLink}s for this Collection * The {@link HALLink}s for this Collection
*/ */
@@ -81,10 +76,6 @@ export class Collection extends DSpaceObject implements ChildHALResource {
return this.firstMetadataValue('dc.identifier.uri'); return this.firstMetadataValue('dc.identifier.uri');
} }
set handle(value: string) {
this._handle = value;
}
/** /**
* The introductory text of this Collection * The introductory text of this Collection
* Corresponds to the metadata field dc.description * Corresponds to the metadata field dc.description

View File

@@ -5,11 +5,9 @@ describe('Community', () => {
describe('Community handle value', () => { describe('Community handle value', () => {
let metadataValue; let metadataValue;
let handleValue;
beforeEach(() => { beforeEach(() => {
metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]}; metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]};
handleValue = '11111111111/1';
}) })
it('should return the handle value from metadata', () => { it('should return the handle value from metadata', () => {
@@ -17,13 +15,8 @@ describe('Community', () => {
expect(community.handle).toEqual('123456789/1'); expect(community.handle).toEqual('123456789/1');
}); });
it('should return the handle value from metadata even when the handle field is provided', () => {
const community = Object.assign(new Community(), { handle: handleValue, metadata: metadataValue });
expect(community.handle).toEqual('123456789/1');
});
it('should return undefined if the handle value from metadata is not present', () => { it('should return undefined if the handle value from metadata is not present', () => {
const community = Object.assign(new Community(), { handle: handleValue }); const community = Object.assign(new Community(), { });
expect(community.handle).toEqual(undefined); expect(community.handle).toEqual(undefined);
}); });
}); });

View File

@@ -1,4 +1,4 @@
import { deserialize, deserializeAs, inheritSerialization } from 'cerialize'; import { deserialize, inheritSerialization } from 'cerialize';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { link, typedObject } from '../cache/builders/build-decorators'; import { link, typedObject } from '../cache/builders/build-decorators';
import { PaginatedList } from '../data/paginated-list'; import { PaginatedList } from '../data/paginated-list';
@@ -11,17 +11,12 @@ import { COMMUNITY } from './community.resource-type';
import { DSpaceObject } from './dspace-object.model'; import { DSpaceObject } from './dspace-object.model';
import { HALLink } from './hal-link.model'; import { HALLink } from './hal-link.model';
import { ChildHALResource } from './child-hal-resource.model'; import { ChildHALResource } from './child-hal-resource.model';
import { excludeFromEquals } from '../utilities/equals.decorators';
@typedObject @typedObject
@inheritSerialization(DSpaceObject) @inheritSerialization(DSpaceObject)
export class Community extends DSpaceObject implements ChildHALResource { export class Community extends DSpaceObject implements ChildHALResource {
static type = COMMUNITY; static type = COMMUNITY;
@excludeFromEquals
@deserializeAs('handle')
private _handle: string;
/** /**
* The {@link HALLink}s for this Community * The {@link HALLink}s for this Community
*/ */
@@ -70,10 +65,6 @@ export class Community extends DSpaceObject implements ChildHALResource {
return this.firstMetadataValue('dc.identifier.uri'); return this.firstMetadataValue('dc.identifier.uri');
} }
set handle(value: string) {
this._handle = value;
}
/** /**
* The introductory text of this Community * The introductory text of this Community
* Corresponds to the metadata field dc.description * Corresponds to the metadata field dc.description

View File

@@ -5,7 +5,7 @@ import { ComcolPageHandleComponent } from './comcol-page-handle.component';
const handle = 'http://localhost:4000/handle/123456789/2'; const handle = 'http://localhost:4000/handle/123456789/2';
fdescribe('ComcolPageHandleComponent', () => { describe('ComcolPageHandleComponent', () => {
let component: ComcolPageHandleComponent; let component: ComcolPageHandleComponent;
let fixture: ComponentFixture<ComcolPageHandleComponent>; let fixture: ComponentFixture<ComcolPageHandleComponent>;

View File

@@ -53,12 +53,26 @@ describe('ExportMetadataSelectorComponent', () => {
const mockCollection: Collection = Object.assign(new Collection(), { const mockCollection: Collection = Object.assign(new Collection(), {
id: 'test-collection-1-1', id: 'test-collection-1-1',
name: 'test-collection-1', name: 'test-collection-1',
handle: 'fake/test-collection-1', metadata: {
'dc.identifier.uri': [
{
language: null,
value: 'fake/test-collection-1'
}
]
}
}); });
const mockCommunity = Object.assign(new Community(), { const mockCommunity = Object.assign(new Community(), {
id: 'test-uuid', id: 'test-uuid',
handle: 'fake/test-community-1', metadata: {
'dc.identifier.uri': [
{
language: null,
value: 'fake/test-community-1'
}
]
}
}); });
const itemRD = createSuccessfulRemoteDataObject(mockItem); const itemRD = createSuccessfulRemoteDataObject(mockItem);

View File

@@ -109,7 +109,6 @@ describe('SearchFormComponent', () => {
export const objects: DSpaceObject[] = [ export const objects: DSpaceObject[] = [
Object.assign(new Community(), { Object.assign(new Community(), {
handle: '10673/11',
logo: { logo: {
self: { self: {
_isScalar: true, _isScalar: true,
@@ -162,12 +161,17 @@ export const objects: DSpaceObject[] = [
language: null, language: null,
value: 'OR2017 - Demonstration' value: 'OR2017 - Demonstration'
} }
] ],
'dc.identifier.uri': [
{
language: null,
value: 'http://localhost:4000/handle/10673/11'
}
],
} }
}), }),
Object.assign(new Community(), Object.assign(new Community(),
{ {
handle: '10673/1',
logo: { logo: {
self: { self: {
_isScalar: true, _isScalar: true,
@@ -220,7 +224,13 @@ export const objects: DSpaceObject[] = [
language: null, language: null,
value: 'Sample Community' value: 'Sample Community'
} }
] ],
'dc.identifier.uri': [
{
language: null,
value: 'http://localhost:4000/handle/10673/1'
}
],
} }
} }
) )

View File

@@ -96,7 +96,6 @@ describe('SearchResultsComponent', () => {
export const objects = [ export const objects = [
Object.assign(new Community(), { Object.assign(new Community(), {
handle: '10673/11',
logo: { logo: {
self: { self: {
_isScalar: true, _isScalar: true,
@@ -149,12 +148,17 @@ export const objects = [
language: null, language: null,
value: 'OR2017 - Demonstration' value: 'OR2017 - Demonstration'
} }
],
'dc.identifier.uri': [
{
language: null,
value: 'http://localhost:4000/handle/10673/11'
}
] ]
} }
}), }),
Object.assign(new Community(), Object.assign(new Community(),
{ {
handle: '10673/1',
logo: { logo: {
self: { self: {
_isScalar: true, _isScalar: true,
@@ -207,6 +211,12 @@ export const objects = [
language: null, language: null,
value: 'Sample Community' value: 'Sample Community'
} }
],
'dc.identifier.uri': [
{
language: null,
value: 'http://localhost:4000/handle/10673/1'
}
] ]
} }
} }