diff --git a/VERSIONS_HOTLINE/50880 b/VERSIONS_HOTLINE/50880 new file mode 100644 index 0000000000000000000000000000000000000000..c7ccd058a2bc4c4b9934ad5e835bcdf599a5bb51 --- /dev/null +++ b/VERSIONS_HOTLINE/50880 @@ -0,0 +1 @@ + - ticket #50880 : Problème d'intégration des paniers dans le cas de plusieurs SIGB \ No newline at end of file diff --git a/cosmogramme/php/util_paniers.php b/cosmogramme/php/util_paniers.php deleted file mode 100644 index 323dda4b109bf9feb897eea1a883f34764f201c0..0000000000000000000000000000000000000000 --- a/cosmogramme/php/util_paniers.php +++ /dev/null @@ -1,159 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -//////////////////////////////////////////////////////////////////////////////////// -// REINDEXATION DES CLEFS NOTICES DANS LES PANIERS ET AVIS -//////////////////////////////////////////////////////////////////////////////////// - -include("_init_frame.php"); - -// Includes -require_once("classe_chronometre.php"); -require_once("classe_unimarc.php"); -require_once("Class/Isbn.php"); - -// Instanciations -$chrono = new chronometre(); - -// Initialisations -$nb_notices=0; -$nb_total=0; -$avance=-1; -$pointeur_reprise=0; -$timeout=intval(ini_get("max_execution_time") * 0.75); -$timeStart=time(); -$chrono->start(); - -// ---------------------------------------------------------------- -// Début du traitement -// ---------------------------------------------------------------- -if($_REQUEST["reprise"]=="oui") restaureContext(); -else -{ - $nb_total = $sql->fetchOne("select count(*) from notices_paniers"); - $nb_total += $sql->fetchOne("select count(*) from notices_avis"); -} - -// Jauge -print('<h1>Réindexation des paniers de notices et des avis sur les notices</h1>'); -print(BR.'<div class="message_grand">Traitement en cours...</div>').BR; -print(BR.'<div class="jauge" style="border:none"><div id="pct" class="pct">0 %</div>'); -print('<div class="jauge"><div id="jauge" class="jauge_avance"></div></div>'); -print('</div>'); -print('<br><div>'); -print('<span id="notice"></span>'); -print('</div>'); -flush(); - -// ---------------------------------------------------------------- -// Paniers -// ---------------------------------------------------------------- -$resultat=$sql->prepareListe("select ID_PANIER,ID_USER,NOTICES from notices_paniers where id_panier > $pointeur_reprise Order by id_panier"); -while($ligne=$sql->fetchNext($resultat)) -{ - if($chrono->tempsPasse() > $timeout) sauveContexte(); - if(!$ligne["NOTICES"]) continue; - $clefs=""; - $notices=explode(";",$ligne["NOTICES"]); - foreach($notices as $id_notice) - { - if(!trim($id_notice)) continue; - if(strlen($id_notice) < 8) $clef_alpha=$sql->fetchOne("select clef_alpha from notices where id_notice=$id_notice"); - else $clef_alpha=$id_notice; - if($clef_alpha) $clefs.=";".$clef_alpha.";"; - } - $sql->execute("update notices_paniers set NOTICES='$clefs' where ID_USER=".$ligne["ID_USER"]." and ID_PANIER=".$ligne["ID_PANIER"]); - $pointeur_reprise=$ligne["id_panier"]; - $nb_notices++; - afficherAvance($nb_notices,$nb_total); -} - -// ---------------------------------------------------------------- -// Avis -// ---------------------------------------------------------------- -$pointeur_reprise=0; -$resultat=$sql->prepareListe("select ID_USER,ID_NOTICE from notices_avis where id_user >= $pointeur_reprise Order by id_user"); -while($ligne=$sql->fetchNext($resultat)) -{ - if($chrono->tempsPasse() > $timeout) sauveContexte(); - $id_user=$ligne["ID_USER"]; - $id_notice=$ligne["ID_NOTICE"]; - $clef_oeuvre=$sql->fetchOne("select clef_oeuvre from notices where id_notice=$id_notice"); - $sql->execute("update notices_avis set CLEF_OEUVRE='$clef_oeuvre' where ID_USER=$id_user and ID_NOTICE=$id_notice"); - $pointeur_reprise=$id_user; - $nb_notices++; - afficherAvance($nb_notices,$nb_total); -} - -// ---------------------------------------------------------------- -// Fin -// ---------------------------------------------------------------- -afficherAvance($nb_total,$nb_total); -$chrono->timeStart=$timeStart; -print("<h4>Traitement terminé.</h4>"); -print('Temps de traitement : '.$chrono->end().BR); - -print('</body></html>'); -exit; - -// ---------------------------------------------------------------- -// Gestion du contexte pour les timeout -// ---------------------------------------------------------------- -function sauveContexte() -{ - global $timeStart,$pointeur_reprise; - global $nb_notices,$nb_total; - - $data=compact("timeStart","pointeur_reprise","nb_notices","nb_total"); - $_SESSION["reprise"]=$data; - redirection( "util_indexation.php?reprise=oui"); -} - -function restaureContext() -{ - global $timeStart,$pointeur_reprise; - global $nb_notices,$nb_total; - - extract($_SESSION["reprise"]); - unset($_SESSION["reprise"]); -} - -function afficherAvance($pointeur,$nb_total) -{ - global $avance; - $pct=(int)(($pointeur / $nb_total) * 100); - if($pct > $avance) - { - $avance=$pct; - print('<script>'); - print("document.getElementById('pct').innerHTML='".$pct."%';"); - $jauge="document.getElementById('jauge').style.width='".$pct."%';"; - print($jauge); - print('</script>'); - } - if($pointeur % 100 == 0 or $pct==100) - { - print('<script>'); - print("document.getElementById('notice').innerHTML='".$pointeur." / ".$nb_total."';"); - print('</script>'); - } - flush(); -} -?> diff --git a/library/Class/Cosmogramme/Integration/PhasePanier.php b/library/Class/Cosmogramme/Integration/PhasePanier.php index bb8d40cc8b66affac93c5abdce4da18347c63479..e1a732bf71bb825b2b87a1a64d75b38d4341f61f 100644 --- a/library/Class/Cosmogramme/Integration/PhasePanier.php +++ b/library/Class/Cosmogramme/Integration/PhasePanier.php @@ -92,7 +92,9 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr return; $map = $this->mapRecordColumns($integration, $datas); - if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $map['id_notice_sigb']])) + + if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $map['id_notice_sigb'], + 'id_int_bib' => $integration->getId()])) return; $owners = $this->findPossibleOwnersOfBasketRecord($map); diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php index 7b923c5e7095994d27139ac4ca95794c322adfef..d76d74fa56f30748c266d9760e7629f7ccd9ebd1 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php @@ -127,26 +127,61 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase { 'clef_alpha' => 'CASTAFIORE', 'exemplaires' => [$this->fixture('Class_Exemplaire', ['id' => 231, + 'id_int_bib' => 999, 'id_origine' => 39925])]]); + $this->fixture('Class_Notice', + ['id' => 45, + 'clef_alpha' => 'TIBET', + 'exemplaires' => [$this->fixture('Class_Exemplaire', + ['id' => 4511, + 'id_int_bib' => 999, + 'id_origine' => 72490])]]); + $this->fixture('Class_Notice', ['id' => 24, 'clef_alpha' => 'LUNE', 'exemplaires' => [$this->fixture('Class_Exemplaire', ['id' => 241, + 'id_int_bib' => 999, 'id_origine' => 58265])]]); - $this->fixture('Class_Notice', - ['id' => 45, - 'clef_alpha' => 'TIBET', - 'exemplaires' => [$this->fixture('Class_Exemplaire', - ['id' => 4511, - 'id_origine' => 72490])]]); } + } + + +class PhasePanierKohaSameIdOrigine extends PhasePanierKohaTestCase { + + public function _prepareFixtures() { + parent::_prepareFixtures(); + Class_Notice::find(45)->addExemplaire($this->fixture('Class_Exemplaire', + ['id' => 22, + 'id_origine' => 58265, + 'id_int_bib' => 98 + ]))->save(); + + Class_Notice::find(24)->setExemplaires([$this->fixture('Class_Exemplaire', + ['id' => 243, + 'id_origine' => 58265, + 'id_int_bib' => 999])])->save(); + } + + + /** @test */ + public function firstBasketRecordsShouldContainNoticeLune() { + $this->assertEquals([ 'CASTAFIORE', 'LUNE'], + Class_PanierNotice::find(1)->getClesNotices()); + } + +} + + + + class PhasePanierFullImportTest extends PhasePanierKohaTestCase { public function _prepareFixtures() { parent::_prepareFixtures(); @@ -396,6 +431,7 @@ class PhasePanierNanookTest extends PhasePanierTestCase { 'clef_alpha' => 'CASTAFIORE', 'exemplaires' => [$this->fixture('Class_Exemplaire', ['id' => 231, + 'id_int_bib' => 999, 'id_origine' => 45633])]]); }