Skip to content

Commit

Permalink
document: improve check for document import
Browse files Browse the repository at this point in the history
Previously the control was done on a fixed list of types.
Now all identifiers are searched.

* Closes rero/rero-ils#3031.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Sep 22, 2022
1 parent a5354fb commit b4506e1
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,20 @@ export class DocumentDetailViewComponent implements DetailRecord, OnInit, OnDest
const keysTypes = Object.keys(this.mappingtypes);
const rec = record.metadata;
const route = ['/records', 'documents', 'new'];
if (rec.identifiedBy) {
const queryParams = [];
rec.identifiedBy.forEach((identifier: any) => {
if (['bf:Isbn', 'bf:Issn', 'bf:Doi', 'bf:Lccn', 'bf:IssnL', 'bf:Ean'].includes(identifier.type)) {
queryParams.push(this._extractAndFormatQueryParams(identifier));
if (keysTypes.indexOf(identifier.type) > -1) {
const cidentifier = cloneDeep(identifier);
cidentifier.type = this.mappingtypes[cidentifier.type];
queryParams.push(this._extractAndFormatQueryParams(cidentifier));
}
let query = null;
const queryParams = [];
rec.identifiedBy.forEach((identifier: any) => {
queryParams.push(this._extractAndFormatQueryParams(identifier));
if (keysTypes.indexOf(identifier.type) > -1) {
const cidentifier = cloneDeep(identifier);
cidentifier.type = this.mappingtypes[cidentifier.type];
queryParams.push(this._extractAndFormatQueryParams(cidentifier));
}
});
const query = queryParams.join(' OR ');
});
if (queryParams.length > 0) {
query = queryParams.join(' OR ');
this._recordService.getRecords(
'documents', query, 1, undefined, undefined, undefined, { accept: 'application/rero+json' }
'documents', query, 1, undefined, undefined, { simple: 0 }, { accept: 'application/rero+json' }
).subscribe((response: Record) => {
if (this._recordService.totalHits(response.hits.total) === 0) {
this._router.navigate(route, { queryParams: data });
Expand Down

0 comments on commit b4506e1

Please sign in to comment.