11import { CloudAppRestService , HttpMethod } from "@exlibris/exl-cloudapp-angular-lib" ;
2- import { Observable } from "rxjs" ;
3- import { map } from "rxjs/operators" ;
42
53export interface Bib {
64 link : string ,
@@ -19,43 +17,46 @@ export class BibUtils {
1917 }
2018
2119 /** Retrieve a single BIB record */
22- getBib ( mmsId : string ) {
20+ getBib ( mmsId : string ) {
2321 return this . _restService . call < Bib > ( `/bibs/${ mmsId } ` ) ;
24- }
22+ }
2523
2624 /** Update a BIB record with the specified MARCXML */
27- updateBib ( bib : Bib ) {
28- return this . _restService . call < Bib > ( {
25+ updateBib ( bib : Bib ) {
26+ return this . _restService . call < Bib > ( {
2927 url : `/bibs/${ bib . mms_id } ` ,
30- headers : {
28+ headers : {
3129 "Content-Type" : "application/xml" ,
32- Accept : "application/json" } ,
30+ Accept : "application/json"
31+ } ,
3332 requestBody : `<bib>${ bib . anies } </bib>` ,
3433 method : HttpMethod . PUT
3534 } ) ;
36- }
35+ }
3736
3837 /** Adds a 500 note field to a MARC21 Bibliographic Record */
3938 addNoteToBib ( bib : Bib ) {
4039 const doc = new DOMParser ( ) . parseFromString ( bib . anies , "application/xml" ) ;
41- const datafield = dom ( "datafield" , {
42- parent : doc . documentElement ,
43- attributes : [ [ "tag" , "500" ] , [ "ind1" , " " ] , [ "ind2" , " " ] ]
40+ const datafield = dom ( "datafield" , {
41+ parent : doc . documentElement ,
42+ attributes : [ [ "tag" , "500" ] , [ "ind1" , " " ] , [ "ind2" , " " ] ]
4443 } ) ;
45- dom ( "subfield" , {
46- parent : datafield ,
47- text : `Record processed at ${ ( new Date ( ) ) . toLocaleString ( ) } ` ,
48- attributes : [ [ "code" , "a" ] ]
44+ dom ( "subfield" , {
45+ parent : datafield ,
46+ text : `Record processed at ${ ( new Date ( ) ) . toLocaleString ( ) } ` ,
47+ attributes : [ [ "code" , "a" ] ]
4948 } ) ;
5049 bib . anies = new XMLSerializer ( ) . serializeToString ( doc . documentElement ) ;
5150 return bib ;
52- }
51+ }
5352}
5453
5554/** Adds Element to dom and returns it */
56- const dom = ( name : string , options : { parent ?: Element | Node , text ?:
57- string , className ?: string , id ?: string , attributes ?: string [ ] [ ] } = { }
58- ) : Element => {
55+ const dom = ( name : string , options : {
56+ parent ?: Element , text ?:
57+ string , className ?: string , id ?: string , attributes ?: string [ ] [ ]
58+ } = { }
59+ ) : Element => {
5960
6061 let ns = options . parent ? options . parent . namespaceURI : '' ;
6162 let element = document . createElementNS ( ns , name ) ;
@@ -66,5 +67,5 @@ const dom = (name: string, options: {parent?: Element | Node, text?:
6667 if ( options . id ) element . id = options . id ;
6768 if ( options . attributes ) options . attributes . forEach ( ( [ att , val ] ) => element . setAttribute ( att , val ) ) ;
6869
69- return element ;
70+ return element ;
7071}
0 commit comments