mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[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:
@@ -5,11 +5,9 @@ describe('Collection', () => {
|
||||
describe('Collection handle value', () => {
|
||||
|
||||
let metadataValue;
|
||||
let handleValue;
|
||||
|
||||
beforeEach(() => {
|
||||
metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]};
|
||||
handleValue = '11111111111/1';
|
||||
})
|
||||
|
||||
it('should return the handle value from metadata', () => {
|
||||
@@ -17,13 +15,8 @@ describe('Collection', () => {
|
||||
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', () => {
|
||||
const community = Object.assign(new Collection(), { handle: handleValue });
|
||||
const community = Object.assign(new Collection(), { });
|
||||
expect(community.handle).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { deserialize, deserializeAs, inheritSerialization } from 'cerialize';
|
||||
import { deserialize, inheritSerialization } from 'cerialize';
|
||||
import { Observable } from 'rxjs';
|
||||
import { link, typedObject } from '../cache/builders/build-decorators';
|
||||
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.model';
|
||||
import { ChildHALResource } from './child-hal-resource.model';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
|
||||
@typedObject
|
||||
@inheritSerialization(DSpaceObject)
|
||||
export class Collection extends DSpaceObject implements ChildHALResource {
|
||||
static type = COLLECTION;
|
||||
|
||||
@excludeFromEquals
|
||||
@deserializeAs('handle')
|
||||
private _handle: string;
|
||||
|
||||
/**
|
||||
* The {@link HALLink}s for this Collection
|
||||
*/
|
||||
@@ -81,10 +76,6 @@ export class Collection extends DSpaceObject implements ChildHALResource {
|
||||
return this.firstMetadataValue('dc.identifier.uri');
|
||||
}
|
||||
|
||||
set handle(value: string) {
|
||||
this._handle = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The introductory text of this Collection
|
||||
* Corresponds to the metadata field dc.description
|
||||
|
@@ -5,11 +5,9 @@ describe('Community', () => {
|
||||
describe('Community handle value', () => {
|
||||
|
||||
let metadataValue;
|
||||
let handleValue;
|
||||
|
||||
beforeEach(() => {
|
||||
metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]};
|
||||
handleValue = '11111111111/1';
|
||||
})
|
||||
|
||||
it('should return the handle value from metadata', () => {
|
||||
@@ -17,13 +15,8 @@ describe('Community', () => {
|
||||
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', () => {
|
||||
const community = Object.assign(new Community(), { handle: handleValue });
|
||||
const community = Object.assign(new Community(), { });
|
||||
expect(community.handle).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { deserialize, deserializeAs, inheritSerialization } from 'cerialize';
|
||||
import { deserialize, inheritSerialization } from 'cerialize';
|
||||
import { Observable } from 'rxjs';
|
||||
import { link, typedObject } from '../cache/builders/build-decorators';
|
||||
import { PaginatedList } from '../data/paginated-list';
|
||||
@@ -11,17 +11,12 @@ import { COMMUNITY } from './community.resource-type';
|
||||
import { DSpaceObject } from './dspace-object.model';
|
||||
import { HALLink } from './hal-link.model';
|
||||
import { ChildHALResource } from './child-hal-resource.model';
|
||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
||||
|
||||
@typedObject
|
||||
@inheritSerialization(DSpaceObject)
|
||||
export class Community extends DSpaceObject implements ChildHALResource {
|
||||
static type = COMMUNITY;
|
||||
|
||||
@excludeFromEquals
|
||||
@deserializeAs('handle')
|
||||
private _handle: string;
|
||||
|
||||
/**
|
||||
* The {@link HALLink}s for this Community
|
||||
*/
|
||||
@@ -70,10 +65,6 @@ export class Community extends DSpaceObject implements ChildHALResource {
|
||||
return this.firstMetadataValue('dc.identifier.uri');
|
||||
}
|
||||
|
||||
set handle(value: string) {
|
||||
this._handle = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The introductory text of this Community
|
||||
* Corresponds to the metadata field dc.description
|
||||
|
@@ -5,7 +5,7 @@ import { ComcolPageHandleComponent } from './comcol-page-handle.component';
|
||||
|
||||
const handle = 'http://localhost:4000/handle/123456789/2';
|
||||
|
||||
fdescribe('ComcolPageHandleComponent', () => {
|
||||
describe('ComcolPageHandleComponent', () => {
|
||||
let component: ComcolPageHandleComponent;
|
||||
let fixture: ComponentFixture<ComcolPageHandleComponent>;
|
||||
|
||||
|
@@ -53,12 +53,26 @@ describe('ExportMetadataSelectorComponent', () => {
|
||||
const mockCollection: Collection = Object.assign(new Collection(), {
|
||||
id: 'test-collection-1-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(), {
|
||||
id: 'test-uuid',
|
||||
handle: 'fake/test-community-1',
|
||||
metadata: {
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
language: null,
|
||||
value: 'fake/test-community-1'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const itemRD = createSuccessfulRemoteDataObject(mockItem);
|
||||
|
@@ -109,7 +109,6 @@ describe('SearchFormComponent', () => {
|
||||
|
||||
export const objects: DSpaceObject[] = [
|
||||
Object.assign(new Community(), {
|
||||
handle: '10673/11',
|
||||
logo: {
|
||||
self: {
|
||||
_isScalar: true,
|
||||
@@ -162,12 +161,17 @@ export const objects: DSpaceObject[] = [
|
||||
language: null,
|
||||
value: 'OR2017 - Demonstration'
|
||||
}
|
||||
]
|
||||
],
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
language: null,
|
||||
value: 'http://localhost:4000/handle/10673/11'
|
||||
}
|
||||
],
|
||||
}
|
||||
}),
|
||||
Object.assign(new Community(),
|
||||
{
|
||||
handle: '10673/1',
|
||||
logo: {
|
||||
self: {
|
||||
_isScalar: true,
|
||||
@@ -220,7 +224,13 @@ export const objects: DSpaceObject[] = [
|
||||
language: null,
|
||||
value: 'Sample Community'
|
||||
}
|
||||
]
|
||||
],
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
language: null,
|
||||
value: 'http://localhost:4000/handle/10673/1'
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@@ -96,7 +96,6 @@ describe('SearchResultsComponent', () => {
|
||||
|
||||
export const objects = [
|
||||
Object.assign(new Community(), {
|
||||
handle: '10673/11',
|
||||
logo: {
|
||||
self: {
|
||||
_isScalar: true,
|
||||
@@ -149,12 +148,17 @@ export const objects = [
|
||||
language: null,
|
||||
value: 'OR2017 - Demonstration'
|
||||
}
|
||||
],
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
language: null,
|
||||
value: 'http://localhost:4000/handle/10673/11'
|
||||
}
|
||||
]
|
||||
}
|
||||
}),
|
||||
Object.assign(new Community(),
|
||||
{
|
||||
handle: '10673/1',
|
||||
logo: {
|
||||
self: {
|
||||
_isScalar: true,
|
||||
@@ -207,6 +211,12 @@ export const objects = [
|
||||
language: null,
|
||||
value: 'Sample Community'
|
||||
}
|
||||
],
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
language: null,
|
||||
value: 'http://localhost:4000/handle/10673/1'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user