mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge pull request #938 from 4Science/CSTPER-222
Metadata identifier for Communities and Collections
This commit is contained in:
@@ -17,7 +17,7 @@ describe('CollectionCurateComponent', () => {
|
|||||||
let dsoNameService;
|
let dsoNameService;
|
||||||
|
|
||||||
const collection = Object.assign(new Collection(), {
|
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(() => {
|
beforeEach(async(() => {
|
||||||
|
@@ -17,7 +17,7 @@ describe('CommunityCurateComponent', () => {
|
|||||||
let dsoNameService;
|
let dsoNameService;
|
||||||
|
|
||||||
const community = Object.assign(new Community(), {
|
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(() => {
|
beforeEach(async(() => {
|
||||||
|
24
src/app/core/shared/collection.model.spec.ts
Normal file
24
src/app/core/shared/collection.model.spec.ts
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -1,4 +1,4 @@
|
|||||||
import { autoserialize, deserialize, 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';
|
||||||
@@ -21,12 +21,6 @@ import { ChildHALResource } from './child-hal-resource.model';
|
|||||||
export class Collection extends DSpaceObject implements ChildHALResource {
|
export class Collection extends DSpaceObject implements ChildHALResource {
|
||||||
static type = COLLECTION;
|
static type = COLLECTION;
|
||||||
|
|
||||||
/**
|
|
||||||
* A string representing the unique handle of this Collection
|
|
||||||
*/
|
|
||||||
@autoserialize
|
|
||||||
handle: string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link HALLink}s for this Collection
|
* The {@link HALLink}s for this Collection
|
||||||
*/
|
*/
|
||||||
@@ -75,6 +69,13 @@ export class Collection extends DSpaceObject implements ChildHALResource {
|
|||||||
@link(COMMUNITY, false)
|
@link(COMMUNITY, false)
|
||||||
parentCommunity?: Observable<RemoteData<Community>>;
|
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
|
* The introductory text of this Collection
|
||||||
* Corresponds to the metadata field dc.description
|
* Corresponds to the metadata field dc.description
|
||||||
|
24
src/app/core/shared/community.model.spec.ts
Normal file
24
src/app/core/shared/community.model.spec.ts
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -1,4 +1,4 @@
|
|||||||
import { autoserialize, deserialize, 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';
|
||||||
@@ -17,12 +17,6 @@ import { ChildHALResource } from './child-hal-resource.model';
|
|||||||
export class Community extends DSpaceObject implements ChildHALResource {
|
export class Community extends DSpaceObject implements ChildHALResource {
|
||||||
static type = COMMUNITY;
|
static type = COMMUNITY;
|
||||||
|
|
||||||
/**
|
|
||||||
* A string representing the unique handle of this Community
|
|
||||||
*/
|
|
||||||
@autoserialize
|
|
||||||
handle: string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link HALLink}s for this Community
|
* The {@link HALLink}s for this Community
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +58,13 @@ export class Community extends DSpaceObject implements ChildHALResource {
|
|||||||
@link(COMMUNITY, false)
|
@link(COMMUNITY, false)
|
||||||
parentCommunity?: Observable<RemoteData<Community>>;
|
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
|
* The introductory text of this Community
|
||||||
* Corresponds to the metadata field dc.description
|
* Corresponds to the metadata field dc.description
|
||||||
|
@@ -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);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@@ -1,5 +1,4 @@
|
|||||||
import { Component, Injectable, Input } from '@angular/core';
|
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"
|
* This component builds a URL from the value of "handle"
|
||||||
@@ -21,6 +20,6 @@ export class ComcolPageHandleComponent {
|
|||||||
@Input() content: string;
|
@Input() content: string;
|
||||||
|
|
||||||
public getHandle(): string {
|
public getHandle(): string {
|
||||||
return new UIURLCombiner('/handle/', this.content).toString();
|
return this.content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
||||||
|
@@ -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'
|
||||||
|
}
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@@ -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'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user