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

This commit is contained in:
Alessandro Martelli
2020-11-10 12:37:38 +01:00
parent 65516b3880
commit 5c7a111a61
4 changed files with 9 additions and 21 deletions

View File

@@ -78,14 +78,13 @@ export class Collection extends DSpaceObject implements ChildHALResource {
* A string representing the unique handle of this Collection * A string representing the unique handle of this Collection
*/ */
get handle(): string { get handle(): string {
const metadataValue = this.firstMetadataValue('dc.identifier.uri'); return this.firstMetadataValue('dc.identifier.uri');
return metadataValue ? metadataValue : this._handle;
} }
set handle(value: string) { set handle(value: string) {
this._handle = value; 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

@@ -67,8 +67,7 @@ export class Community extends DSpaceObject implements ChildHALResource {
* A string representing the unique handle of this Community * A string representing the unique handle of this Community
*/ */
get handle(): string { get handle(): string {
const metadataValue = this.firstMetadataValue('dc.identifier.uri'); return this.firstMetadataValue('dc.identifier.uri');
return metadataValue ? metadataValue : this._handle;
} }
set handle(value: string) { set handle(value: string) {

View File

@@ -39,7 +39,7 @@ describe('ComcolPageHandleComponent', () => {
}); });
describe('should create a link pointing the handle', () => { describe('should create a link pointing the handle', () => {
it('should use the content if it includes the http protocol', () => { it('should use the content if it includes the http protocol', () => {
component.content = handleWithProtocol; component.content = handleWithProtocol;
fixture.detectChanges(); fixture.detectChanges();
@@ -48,15 +48,6 @@ describe('ComcolPageHandleComponent', () => {
expect(link.nativeElement.getAttribute('href')).toBe(handleWithProtocol); expect(link.nativeElement.getAttribute('href')).toBe(handleWithProtocol);
expect(link.nativeElement.innerHTML).toBe(handleWithProtocol); expect(link.nativeElement.innerHTML).toBe(handleWithProtocol);
}); });
it('should combine the base uri to the content if it doesnt include the http protocol', () => {
component.content = handleWithoutProtocol;
fixture.detectChanges();
const link = fixture.debugElement.query(By.css('a'));
expect(link.nativeElement.getAttribute('href')).toBe(handleWithoutProtocolUIURLCombined);
expect(link.nativeElement.innerHTML).toBe(handleWithoutProtocolUIURLCombined);
});
}); });
}); });

View File

@@ -21,7 +21,6 @@ export class ComcolPageHandleComponent {
@Input() content: string; @Input() content: string;
public getHandle(): string { public getHandle(): string {
return this.content.includes('http') ? this.content return this.content;
: new UIURLCombiner('/handle/', this.content).toString(); }
}} }