+ if(my $dupetcn = $U->simplereq("open-ils.search","open-ils.search.biblio.tcn",$tcn_value)){
+ if($dupetcn->{count} > 0){
+ my $newid = $dupetcn->{ids}[0];
+ if($overwritetcn){
+ $bib->id($newid);
+ $cstore->request("open-ils.cstore.transaction.begin")->gather(1);
+ my $req = $cstore->request("open-ils.cstore.direct.biblio.record_entry.update",$bib)->gather(1);
+ $cstore->request("open-ils.cstore.transaction.commit")->gather(1);
+ print STDERR "overwriting TCN: $tcn_value (id:$id/newid:$newid)\n" if $verbose;
+ } else {
+ print STDERR "duplicate TCN: $tcn_value - (id: $id) not imported \n" if $verbose;
+ }
+ next PROCESS;
+ }
+ }
+
+ if($directload){
+ my $req = $cstore->request("open-ils.cstore.direct.biblio.record_entry.retrieve",$id)->gather(1);
+ if($req){
+ if($req->tcn_value ne $tcn_value){
+ print STDERR "incoming record (id:$id/tcn:$tcn_value) does not match record (id:".$req->id."/tcn:".$rec->tcn_value.")!\n" if $verbose;
+ if($overwritetcn){
+
+ }
+ } elsif (($req->tcn_value eq $tcn_value) && $overwritetcn){
+ print STDERR "matching record overlaied with incoming record (id:$id/tcn:$tcn_value)\n" if $verbose;
+
+ $cstore->request("open-ils.cstore.transaction.begin")->gather(1);
+ $req = $cstore->request("open-ils.cstore.direct.biblio.record_entry.update",$bib)->gather(1);
+ $cstore->request("open-ils.cstore.transaction.commit")->gather(1);
+ }
+ } else {
+ print STDERR "importing new record (id:$id/tcn:$tcn_value)\n" if $verbose;
+
+ $cstore->request("open-ils.cstore.transaction.begin")->gather(1);
+ $req = $cstore->request("open-ils.cstore.direct.biblio.record_entry.create",$bib)->gather(1);
+ $cstore->request("open-ils.cstore.transaction.commit")->gather(1);
+ }
+ print Dumper($req);
+ } else {
+ print OpenSRF::Utils::JSON->perl2JSON($bib)."\n";
+ }