[TLC-249] Addressing review feedback

Adding comments and tidying some comments, imports
Expect text for status not integer
Send a 'type' parameter with a DOI registration
Rename item-status.register to registerDOI

As per todonohue's feedback on 2022-01-18
This commit is contained in:
Kim Shepherd
2023-01-19 15:01:04 +13:00
parent d0b5fc257a
commit 838cde4841
6 changed files with 37 additions and 24 deletions

View File

@@ -20,6 +20,11 @@ import { map } from 'rxjs/operators';
import {ConfigurationProperty} from '../shared/configuration-property.model'; import {ConfigurationProperty} from '../shared/configuration-property.model';
import {ConfigurationDataService} from './configuration-data.service'; import {ConfigurationDataService} from './configuration-data.service';
/**
* The service handling all REST requests to get item identifiers like handles and DOIs
* from the /identifiers endpoint, as well as the backend configuration that controls whether a 'Register DOI'
* button appears for admins in the item status page
*/
@Injectable() @Injectable()
@dataService(IDENTIFIERS) @dataService(IDENTIFIERS)
export class IdentifierDataService extends BaseDataService<IdentifierData> { export class IdentifierDataService extends BaseDataService<IdentifierData> {
@@ -50,7 +55,7 @@ export class IdentifierDataService extends BaseDataService<IdentifierData> {
* Should we allow registration of new DOIs via the item status page? * Should we allow registration of new DOIs via the item status page?
*/ */
public getIdentifierRegistrationConfiguration(): Observable<string[]> { public getIdentifierRegistrationConfiguration(): Observable<string[]> {
return this.configurationService.findByPropertyName('identifiers.item-status.register').pipe( return this.configurationService.findByPropertyName('identifiers.item-status.registerDOI').pipe(
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),
map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : []) map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : [])
); );

View File

@@ -256,7 +256,9 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
let headers = new HttpHeaders(); let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json'); headers = headers.append('Content-Type', 'application/json');
options.headers = headers; options.headers = headers;
const request = new PostRequest(requestId, href, JSON.stringify({}), options); // Pass identifier type as a simple parameter, no need for full JSON data
let hrefWithParams: string = this.buildHrefWithParams(href, [new RequestParam("type", "doi")]);
const request = new PostRequest(requestId, hrefWithParams, JSON.stringify({}), options);
this.requestService.send(request); this.requestService.send(request);
}); });
return this.rdbService.buildFromRequestUUID(requestId); return this.rdbService.buildFromRequestUUID(requestId);

View File

@@ -41,7 +41,7 @@ describe('ItemStatusComponent', () => {
mockConfigurationDataService = jasmine.createSpyObj('configurationDataService', { mockConfigurationDataService = jasmine.createSpyObj('configurationDataService', {
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), { findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
name: 'identifiers.item-status.register', name: 'identifiers.item-status.registerDOI',
values: [ values: [
'true' 'true'
] ]

View File

@@ -3,7 +3,7 @@ import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { ItemOperation } from '../item-operation/itemOperation.model'; import { ItemOperation } from '../item-operation/itemOperation.model';
import {distinctUntilChanged, first, map, mergeMap, startWith, switchMap, toArray} from 'rxjs/operators'; import {distinctUntilChanged, first, map, mergeMap, toArray} from 'rxjs/operators';
import {BehaviorSubject, Observable, from as observableFrom, Subscription, combineLatest, of} from 'rxjs'; import {BehaviorSubject, Observable, from as observableFrom, Subscription, combineLatest, of} from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths'; import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
@@ -12,11 +12,8 @@ import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
import { hasValue } from '../../../shared/empty.util'; import { hasValue } from '../../../shared/empty.util';
import { import {
getAllSucceededRemoteDataPayload, getAllSucceededRemoteDataPayload,
getFirstCompletedRemoteData, getFirstSucceededRemoteData,
getFirstSucceededRemoteDataPayload
} from '../../../core/shared/operators'; } from '../../../core/shared/operators';
import {IdentifierDataService} from '../../../core/data/identifier-data.service'; import {IdentifierDataService} from '../../../core/data/identifier-data.service';
import {IdentifierData} from '../../../shared/object-list/identifier-data/identifier-data.model';
import {Identifier} from '../../../shared/object-list/identifier-data/identifier.model'; import {Identifier} from '../../../shared/object-list/identifier-data/identifier.model';
import {ConfigurationProperty} from '../../../core/shared/configuration-property.model'; import {ConfigurationProperty} from '../../../core/shared/configuration-property.model';
import {ConfigurationDataService} from '../../../core/data/configuration-data.service'; import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
@@ -111,7 +108,7 @@ export class ItemStatusComponent implements OnInit {
); );
// Observable for configuration determining whether the Register DOI feature is enabled // Observable for configuration determining whether the Register DOI feature is enabled
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register').pipe( let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.registerDOI').pipe(
map((enabled: RemoteData<ConfigurationProperty>) => { map((enabled: RemoteData<ConfigurationProperty>) => {
let show = false; let show = false;
if (enabled.hasSucceeded) { if (enabled.hasSucceeded) {
@@ -161,7 +158,7 @@ export class ItemStatusComponent implements OnInit {
if (hasValue(identifier) && identifier.identifierType === 'doi') { if (hasValue(identifier) && identifier.identifierType === 'doi') {
// The item has some kind of DOI // The item has some kind of DOI
no_doi = false; no_doi = false;
if (identifier.identifierStatus === '10' || identifier.identifierStatus === '11' if (identifier.identifierStatus === 'PENDING' || identifier.identifierStatus === 'MINTED'
|| identifier.identifierStatus == null) { || identifier.identifierStatus == null) {
// The item's DOI is pending, minted or null. // The item's DOI is pending, minted or null.
// It isn't registered, reserved, queued for registration or reservation or update, deleted // It isn't registered, reserved, queued for registration or reservation or update, deleted

View File

@@ -1,10 +1,8 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { catchError, map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { Observable, of as observableOf } from 'rxjs'; import { Observable } from 'rxjs';
import { hasValue } from '../../empty.util'; import { hasValue } from '../../empty.util';
import { environment } from 'src/environments/environment';
import { Item } from 'src/app/core/shared/item.model'; import { Item } from 'src/app/core/shared/item.model';
import { AccessStatusDataService } from 'src/app/core/data/access-status-data.service';
import {IdentifierData} from './identifier-data.model'; import {IdentifierData} from './identifier-data.model';
import {IdentifierDataService} from '../../../core/data/identifier-data.service'; import {IdentifierDataService} from '../../../core/data/identifier-data.service';
@@ -13,18 +11,13 @@ import {IdentifierDataService} from '../../../core/data/identifier-data.service'
templateUrl: './identifier-data.component.html' templateUrl: './identifier-data.component.html'
}) })
/** /**
* Component rendering the access status of an item as a badge * Component rendering an identifier, eg. DOI or handle
*/ */
export class IdentifierDataComponent { export class IdentifierDataComponent {
@Input() item: Item; @Input() item: Item;
identifiers$: Observable<IdentifierData>; identifiers$: Observable<IdentifierData>;
/**
* Whether to show the access status badge or not
*/
showAccessStatus: boolean;
/** /**
* Initialize instance variables * Initialize instance variables
* *
@@ -34,11 +27,11 @@ export class IdentifierDataComponent {
ngOnInit(): void { ngOnInit(): void {
if (this.item == null) { if (this.item == null) {
// Do not show the badge if the feature is inactive or if the item is null. // Do not show the identifier if the feature is inactive or if the item is null.
return; return;
} }
if (this.item.identifiers == null) { if (this.item.identifiers == null) {
// In case the access status has not been loaded, do it individually. // In case the identifier has not been loaded, do it individually.
this.item.identifiers = this.identifierDataService.getIdentifierDataFor(this.item); this.item.identifiers = this.identifierDataService.getIdentifierDataFor(this.item);
} }
this.identifiers$ = this.item.identifiers.pipe( this.identifiers$ = this.item.identifiers.pipe(
@@ -49,8 +42,6 @@ export class IdentifierDataComponent {
return null; return null;
} }
}), }),
// EMpty array if none
//map((identifiers: IdentifierData) => hasValue(identifiers.identifiers) ? identifiers.identifiers : [])
); );
} }
} }

View File

@@ -1,12 +1,30 @@
import {autoserialize} from 'cerialize'; import { autoserialize } from 'cerialize';
/**
* Identifier model. Identifiers using this model are returned in lists from the /item/{id}/identifiers endpoint
*
* @author Kim Shepherd
*/
export class Identifier { export class Identifier {
/**
* The value of the identifier, eg. http://hdl.handle.net/123456789/123 or https://doi.org/test/doi/1234
*/
@autoserialize @autoserialize
value: string; value: string;
/**
* The type of identiifer, eg. "doi", or "handle", or "other"
*/
@autoserialize @autoserialize
identifierType: string; identifierType: string;
/**
* The status of the identifier. Some schemes, like DOI, will have a different status based on whether it is
* queued for remote registration, reservation, or update, or has been registered, simply minted locally, etc.
*/
@autoserialize @autoserialize
identifierStatus: string; identifierStatus: string;
/**
* The type of resource, in this case Identifier
*/
@autoserialize @autoserialize
type: string; type: string;
} }