Skip to content
Snippets Groups Projects

Master

Merged Ghislain Loas requested to merge master into WIP
Compare and
+ 212
56
Preferences
Compare changes
Files
@@ -51,6 +51,8 @@ class notice_integration
private $mode_doublon; // Mode de dédoublonnage (tous identifiants ou clef alpha prioritaire)
private $url_site; // Url d'origine du site opac
private $flag_koha=false; // flag pour réentrance des notices de periodiques koha
/** @category testing */
protected $_service_runner;
// ----------------------------------------------------------------
// Constructeur
@@ -214,44 +216,50 @@ class notice_integration
}
// Mise a jour
if(!$id_notice)
{
if(!$id_notice) {
$this->notice["qualite"]=$this->qualite_bib;
$id_notice=$this->insertNotice();
if(!$id_notice) return;
else $this->statut=1;
}
else
{
} else {
// Controle des identifiants pour dedoublonnage eventuel
if($this->identification["statut"] == "code_barres")
{
if ($this->identification["statut"] == "code_barres") {
// Lecture identifiants de la notice de la base
$new_id_notice=0;
$enreg=$sql->fetchEnreg("Select isbn,ean,id_commerciale from notices where id_notice=$id_notice");
if($this->notice["isbn10"] and $this->notice["isbn10"] != $enreg["isbn"] and $this->notice["isbn13"] != $enreg["isbn"])
{
$enreg = $sql->fetchEnreg("Select isbn,ean,id_commerciale from notices where id_notice=$id_notice");
if ($this->notice["isbn10"]
and $this->notice["isbn10"] != $enreg["isbn"]
and $this->notice["isbn13"] != $enreg["isbn"]) {
$new_id_notice=$this->identification["isbn"];
if(!$new_id_notice) $new_id_notice="creation";
}
if(!$new_id_notice and $this->notice["ean"] and $this->notice["ean"] != $enreg["ean"])
{
if(!$new_id_notice
and $this->notice["ean"]
and $this->notice["ean"] != $enreg["ean"]) {
$new_id_notice=$this->identification["ean"];
if(!$new_id_notice) $new_id_notice="creation";
}
// if(!$new_id_notice and !$ean and $this->notice["id_commerciale"] != $enreg["id_commerciale"])
// {
// $new_id_notice=$this->identification["id_commerciale"];
// if(!$new_id_notice) $new_id_notice="creation";
// }
if($new_id_notice)
{
if($new_id_notice == "creation") { $new_id_notice=$this->insertNotice(); if(!$new_id_notice) return; }
else $this->updateNotice($new_id_notice,$this->qualite_bib);
if ($new_id_notice) {
if ($new_id_notice == "creation") {
$this->notice["qualite"]=$this->qualite_bib;
$new_id_notice = $this->insertNotice();
if (!$new_id_notice) return;
} else {
$this->updateNotice($new_id_notice,$this->qualite_bib);
}
// on supprime les exemplaires de l'ancienne notice
for($i=0; $i<count($this->notice["exemplaires"]); $i++)
{
for($i=0; $i<count($this->notice["exemplaires"]); $i++) {
$ex=$this->notice["exemplaires"][$i];
$sql->execute("delete from exemplaires where id_bib=$id_bib and id_notice=$id_notice and code_barres='".$ex["code_barres"]."'");
}
@@ -296,56 +304,53 @@ class notice_integration
return $ret;
}
// ----------------------------------------------------------------
// Traitement notice succinte
// ----------------------------------------------------------------
public function traiteSuccinte($enreg)
{
public function traiteSuccinte($enreg) {
global $sql;
extract($enreg);
$this->id_bib=$id_bib;
$notice=unserialize($data);
$this->notice=$notice;
/**
* $this->id_bib is deprecated, use $this->id_int_bib instead.
* @see http://forge.afi-sa.fr/issues/14279
*/
$this->id_bib = $this->id_int_bib = $id_bib;
$notice = unserialize($data);
$this->notice = $notice;
// On la cherche dans la base
$id_notice=$this->chercheNotice();
if($id_notice)
{
$unimarc=$sql->fetchOne("select unimarc from notices where id_notice=$id_notice");
$this->notice_sgbd->ouvrirNotice($unimarc,0);
$this->notice=$this->notice_sgbd->getNoticeIntegration();
$this->notice["id_origine"]=$notice["id_origine"];
$this->notice["statut_exemplaires"] = $notice["statut_exemplaires"];
$this->notice["exemplaires"] = $notice["exemplaires"];
$this->updateNotice($id_notice,$this->notice["qualite"]);
$this->ecrireExemplaires($id_notice);
if ($id_notice = $this->chercheNotice()) {
$this->handleSuccinteLocaly($notice, $id_notice, $sql);
$ret["statut"]=4;
}
// On cherche sur les serveurs z3950
else
{
else {
$args["isbn"]=$notice["isbn"];
$args["ean"]= $notice["ean"];
$args["id_commerciale"]=$notice["id_commerciale"];
$args["no_request"]=getVariable("Z3950_cache_only");
$ret=communication::runService(4,$args);
$ret = $this->getServiceRunner()->run(4, $args);
// Statut ok : on remplace la notice
if(!$this->analyseur) $this->analyseur=new notice_unimarc();
if($ret["statut_z3950"] > "1")
{
if (!$this->analyseur)
$this->analyseur = new notice_unimarc();
if ($ret["statut_z3950"] > "1") {
$this->analyseur->ouvrirNotice($ret["unimarc"],1);
$this->notice=$this->analyseur->getNoticeIntegration();
$this->notice["id_origine"]=$notice["id_origine"];
$this->notice["statut_exemplaires"] = $notice["statut_exemplaires"];
$this->notice["exemplaires"] = $notice["exemplaires"];
$this->notice["qualite"]=getVariable("homogene_code_qualite");
$id_notice=$this->insertNotice();
$this->ecrireExemplaires($id_notice);
$ret["statut"]=1;
if ($this->notice["titre_princ"]
&& $id_notice = $this->insertNotice()) {
$this->ecrireExemplaires($id_notice);
$ret["statut"] = 1;
}
$ret["statut"] = 0;
} else {
$ret["statut"] = 0;
}
else $ret["statut"]=0;
}
// Mise a jour
@@ -353,17 +358,29 @@ class notice_integration
$ret["id_bib"]=$id_bib;
$ret["isbn"]=$notice["isbn"];
$ret["ean"]= $notice["ean"];
$ret["id_commerciale"]=$notice["id_commerciale"];
if($id_notice) $sql->execute("delete from notices_succintes where id=$id");
else $nb=$sql->execute("Update notices_succintes set z3950_retry = z3950_retry +1 Where id=$id");
$ret["id_commerciale"] = $notice["id_commerciale"];
$query = ($id_notice)
? "delete from notices_succintes where id=$id"
: "Update notices_succintes set z3950_retry = z3950_retry +1 Where id=$id";
$sql->execute($query);
return $ret;
}
// ----------------------------------------------------------------
// Traitement pseudo_notices
// ----------------------------------------------------------------
public function traitePseudoNotice($type_doc, $enreg)
{
protected function handleSuccinteLocaly($succinte, $id_notice, $sql) {
$unimarc=$sql->fetchOne("select unimarc from notices where id_notice=$id_notice");
$this->notice_sgbd->ouvrirNotice($unimarc,0);
$this->notice=$this->notice_sgbd->getNoticeIntegration();
$this->notice["id_origine"]=$succinte["id_origine"];
$this->notice["statut_exemplaires"] = $succinte["statut_exemplaires"];
$this->notice["exemplaires"] = $succinte["exemplaires"];
$this->updateNotice($id_notice, $this->notice["qualite"]);
$this->ecrireExemplaires($id_notice);
}
public function traitePseudoNotice($type_doc, $enreg) {
global $sql;
if (!$enreg['id_bib'])
@@ -1332,6 +1349,27 @@ class notice_integration
public function get_subfield() {
return call_user_func_array([$this->analyseur, 'get_subfield'], func_get_args());
}
/** @category testing */
public function getServiceRunner() {
if (null != $this->_service_runner)
return $this->_service_runner;
return new Service_Runner();
}
public function setServiceRunner($runner) {
$this->_service_runner = $runner;
return $this;
}
}
class Service_Runner {
public function run($type, $args) {
return communication::runService($type, $args);
}
}
?>