Merge pull request #938 from 4Science/CSTPER-222

Metadata identifier for Communities and Collections
This commit is contained in:
Tim Donohue
2020-11-23 09:21:37 -06:00
committed by GitHub
11 changed files with 157 additions and 26 deletions

View File

@@ -17,7 +17,7 @@ describe('CollectionCurateComponent', () => {
let dsoNameService;
const collection = Object.assign(new Collection(), {
handle: '123456789/1', metadata: {'dc.title': ['Collection Name']}
metadata: {'dc.title': ['Collection Name'], 'dc.identifier.uri': [ { value: '123456789/1'}]}
});
beforeEach(async(() => {

View File

@@ -17,7 +17,7 @@ describe('CommunityCurateComponent', () => {
let dsoNameService;
const community = Object.assign(new Community(), {
handle: '123456789/1', metadata: {'dc.title': ['Community Name']}
metadata: {'dc.title': ['Community Name'], 'dc.identifier.uri': [ { value: '123456789/1'}]}
});
beforeEach(async(() => {

View File

@@ -0,0 +1,24 @@
import {Collection} from './collection.model';
describe('Collection', () => {
describe('Collection handle value', () => {
let metadataValue;
beforeEach(() => {
metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]};
})
it('should return the handle value from metadata', () => {
const community = Object.assign(new Collection(), { 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(), { });
expect(community.handle).toEqual(undefined);
});
});
});

View File

@@ -1,4 +1,4 @@
import { autoserialize, deserialize, 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';
@@ -21,12 +21,6 @@ import { ChildHALResource } from './child-hal-resource.model';
export class Collection extends DSpaceObject implements ChildHALResource {
static type = COLLECTION;
/**
* A string representing the unique handle of this Collection
*/
@autoserialize
handle: string;
/**
* The {@link HALLink}s for this Collection
*/
@@ -75,6 +69,13 @@ export class Collection extends DSpaceObject implements ChildHALResource {
@link(COMMUNITY, false)
parentCommunity?: Observable<RemoteData<Community>>;
/**
* A string representing the unique handle of this Collection
*/
get handle(): string {
return this.firstMetadataValue('dc.identifier.uri');
}
/**
* The introductory text of this Collection
* Corresponds to the metadata field dc.description

View File

@@ -0,0 +1,24 @@
import {Community} from './community.model';
describe('Community', () => {
describe('Community handle value', () => {
let metadataValue;
beforeEach(() => {
metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]};
})
it('should return the handle value from metadata', () => {
const community = Object.assign(new Community(), { 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(), { });
expect(community.handle).toEqual(undefined);
});
});
});

View File

@@ -1,4 +1,4 @@
import { autoserialize, deserialize, 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';
@@ -17,12 +17,6 @@ import { ChildHALResource } from './child-hal-resource.model';
export class Community extends DSpaceObject implements ChildHALResource {
static type = COMMUNITY;
/**
* A string representing the unique handle of this Community
*/
@autoserialize
handle: string;
/**
* The {@link HALLink}s for this Community
*/
@@ -64,6 +58,13 @@ export class Community extends DSpaceObject implements ChildHALResource {
@link(COMMUNITY, false)
parentCommunity?: Observable<RemoteData<Community>>;
/**
* A string representing the unique handle of this Community
*/
get handle(): string {
return this.firstMetadataValue('dc.identifier.uri');
}
/**
* The introductory text of this Community
* Corresponds to the metadata field dc.description

View File

@@ -0,0 +1,48 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { By } from '@angular/platform-browser';
import { ComcolPageHandleComponent } from './comcol-page-handle.component';
const handle = 'http://localhost:4000/handle/123456789/2';
describe('ComcolPageHandleComponent', () => {
let component: ComcolPageHandleComponent;
let fixture: ComponentFixture<ComcolPageHandleComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
declarations: [ ComcolPageHandleComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ComcolPageHandleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should be empty if no content is passed', () => {
component.content = undefined;
fixture.detectChanges();
const div = fixture.debugElement.query(By.css('div'));
expect(div).toBeNull();
});
it('should create a link pointing the handle when present', () => {
component.content = handle;
fixture.detectChanges();
const link = fixture.debugElement.query(By.css('a'));
expect(link.nativeElement.getAttribute('href')).toBe(handle);
expect(link.nativeElement.innerHTML).toBe(handle);
});
});

View File

@@ -1,5 +1,4 @@
import { Component, Injectable, Input } from '@angular/core';
import { UIURLCombiner } from '../../core/url-combiner/ui-url-combiner';
/**
* This component builds a URL from the value of "handle"
@@ -21,6 +20,6 @@ export class ComcolPageHandleComponent {
@Input() content: string;
public getHandle(): string {
return new UIURLCombiner('/handle/', this.content).toString();
return this.content;
}
}

View File

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

View File

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

View File

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