diff --git a/VERSIONS_HOTLINE/89128 b/VERSIONS_HOTLINE/89128 new file mode 100644 index 0000000000000000000000000000000000000000..e6df06576ed6a5b08ca172a0768c24a1158482c5 --- /dev/null +++ b/VERSIONS_HOTLINE/89128 @@ -0,0 +1 @@ + - ticket #89128 : Cosmogramme : Correction du libellé de la variable "unicite_code_barres" \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 53df279299acb5553deda62d4bb69f477b4f5043..180443e837fa3cdda08c18c7618badf4129c8153 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -736,10 +736,13 @@ class notice_integration { } if (!empty($code_barres)) { - $unicite_codes_barres = getVariable('unicite_code_barres'); - $delete_duplicates_args = ($unicite_codes_barres == '1') ? [] : ['id_int_bib' => $this->id_int_bib]; - $delete_duplicates_args['id_notice'] = $id_notice; - $delete_duplicates_args['code_barres'] = $code_barres; + $unicite_codes_barres = Class_CosmoVar::get(Class_Notice_DoubleFinder::VAR_BARCODE_UNIQ_MODE); + $delete_duplicates_args = ['id_notice' => $id_notice, + 'code_barres' => $code_barres]; + + if ($unicite_codes_barres == Class_CosmoVar::UNIQ_BARCODE_WITHIN_LIBRARY) + $delete_duplicates_args['id_int_bib'] = $this->id_int_bib; + Class_Exemplaire::deleteBy($delete_duplicates_args); } diff --git a/cosmogramme/sql/patch/patch_373.php b/cosmogramme/sql/patch/patch_373.php new file mode 100644 index 0000000000000000000000000000000000000000..301eff1d9e2eb178ac40e37a8cdb7081c987dbbe --- /dev/null +++ b/cosmogramme/sql/patch/patch_373.php @@ -0,0 +1,6 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); +try { + $adapter->query("UPDATE `variables` SET liste='0:Code-barres uniquement\r\n1:Bibliothèque + codes-barres' WHERE clef='unicite_code_barres'"); + +} catch(Exception $e) {} diff --git a/cosmogramme/tests/php/classes/CarthameIntegrationTest.php b/cosmogramme/tests/php/classes/CarthameIntegrationTest.php index 6c97ae89bed819660171a14ae7facc38c491891d..cdf69fc11d9d1b81a65ec6aaabf0c63d634085c4 100644 --- a/cosmogramme/tests/php/classes/CarthameIntegrationTest.php +++ b/cosmogramme/tests/php/classes/CarthameIntegrationTest.php @@ -32,7 +32,7 @@ abstract class CarthameIntegrationTestCase extends NoticeIntegrationTestCase { 'non_exportable'=> 'electre;decitre;gam;zebris', 'controle_codes_barres'=> 0, 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, 'champs_sup' => '', 'ean_345' => '']; foreach($vars as $key => $value) diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php index 9acd648e55fb0d34b9c8ad985f48e9a05004c155..f14a43f727fc9e1bec7d8ad2cc2261581ab70a74 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php @@ -24,7 +24,13 @@ require_once 'NoticeIntegrationTest.php'; abstract class NoticeIntegrationAloesTestCase extends NoticeIntegrationTestCase { - public function getProfilDonnees() { + public function setUp() { + parent::setUp(); + Class_CosmoVar::setValueOf('unicite_code_barres', Class_CosmoVar::UNIQ_BARCODE_WITHIN_LIBRARY); + } + + + public function getProfilDonnees() { return Class_IntProfilDonnees::forALOES() ->setIdProfil(111) ->getRawAttributes(); @@ -32,6 +38,7 @@ abstract class NoticeIntegrationAloesTestCase extends NoticeIntegrationTestCase } + class NoticeIntegrationAloes11septembre2001Test extends NoticeIntegrationAloesTestCase { public function getProfilDonnees() { return Class_IntProfilDonnees::forALOES() @@ -275,7 +282,7 @@ class NoticeIntegrationAloesDimancheALaPiscineTest extends NoticeIntegrationAloe ->setIdProfil(111) ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT, 'u') ->getRawAttributes(); - } + } public function setUp() { @@ -302,7 +309,7 @@ class NoticeIntegrationAloesDimancheALaPiscineTest extends NoticeIntegrationAloe 'id_bib' => 4, 'invisible' => 0]); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire'); + $this->onLoaderOfModel('Class_Exemplaire'); $this->loadNotice("unimarc_dimanche_a_la_piscine"); } diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php index 8f3b325827a604ec712e787cca9895268f8e2de2..42f838e6c3c1d5f31b6be6f75ad1a58fec74b08d 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php @@ -63,7 +63,7 @@ class NoticeIntegrationDedupWithoutIsbnTest extends NoticeIntegrationTestCase { 'non_exportable'=> 'electre;decitre;gam;zebris', 'controle_codes_barres'=> 0, 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, 'champs_sup' => '', 'ean_345' => '']); @@ -96,7 +96,7 @@ class NoticeIntegrationDedupSameUnimarcLoadedTest extends NoticeIntegrationTestC 'non_exportable'=> 'electre;decitre;gam;zebris', 'controle_codes_barres'=> 0, 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, 'champs_sup' => '', 'ean_345' => '']); @@ -171,7 +171,7 @@ class NoticeIntegrationDedupCaliceWithoutIsbnTest extends NoticeIntegrationTestC 'non_exportable'=> 'electre;decitre;gam;zebris', 'controle_codes_barres' => 1, 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, 'champs_sup' => '', 'ean_345' => 1]); @@ -184,3 +184,69 @@ class NoticeIntegrationDedupCaliceWithoutIsbnTest extends NoticeIntegrationTestC $this->assertEquals(2, Class_Notice::count()); } } + + + + +/** @see http://forge.afi-sa.fr/issues/89128 */ +class NoticeIntegrationDedupOnBarcodeWithinLibraryTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forPMB() + ->setIdProfil(113) + ->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Notice', + ['id' => 30, + 'type_doc' => 1, + 'alpha_titre' => 'ACTUALITE DU VIRTUEL', + 'alpha_auteur' => 'FR BNF', + 'titres' => 'ACTUALITE AKTUALIT VIRTUEL', + 'auteurs' => 'BNF', + 'editeur' => '[Centre national d\'art et de culture Georges-Pompidou (Paris)]', + 'isbn' => '978-2-7189-6666-4', + 'unimarc' => '', + 'ean' => null, + 'id_commerciale' => '', + 'id_bnf' => '', + 'clef_alpha' => 'ACTUALITEDUVIRTUEL--FRB--CENTRENATIONALDARTETDECULTUREGEORGESPOMPIDOUPARIS-1997-5', + 'clef_oeuvre' => 'ACTUALITEDUVIRTUEL--FRB-', + 'clef_chapeau' => '', + 'qualite' => 10, + 'date_creation' => '2015-05-02 00:00:00', + 'date_maj' => '2015-09-13 13:22:53', + 'url_vignette' => Class_WebService_Vignette::NO_DATA, + 'url_image' => Class_WebService_Vignette::NO_DATA]); + + + $this->fixture('Class_Exemplaire', + ['id' => 23, + 'id_notice' => 30, + 'code_barres' => '18120', + 'id_int_bib' => 6]); + } + + + /** @test */ + public function withUniciteCodeBarresOnlyNumberOfRecordsShouldBeOne() { + Class_CosmoVar::set(Class_Notice_DoubleFinder::VAR_BARCODE_UNIQ_MODE, + Class_CosmoVar::UNIQ_BARCODE_ONLY); + $this->loadNotice('unimarc_pmb_pierres'); + $this->assertCount(1, Class_Notice::findAll()); + $this->assertCount(1, Class_Exemplaire::findAll()); + } + + + /** @test */ + public function withUniciteCodeBarresWithLibraryNumberOfRecordsShouldBeTwo() { + Class_CosmoVar::set(Class_Notice_DoubleFinder::VAR_BARCODE_UNIQ_MODE, + Class_CosmoVar::UNIQ_BARCODE_WITHIN_LIBRARY); + $this->loadNotice('unimarc_pmb_pierres'); + $this->assertCount(2, Class_Notice::findAll()); + $this->assertCount(2, Class_Exemplaire::findAll()); + } +} \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationSuccinteTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationSuccinteTest.php index efb3636e1bc7c0ba5057ce50dfc593596f19f502..d6e1569eb884b6338683097acd6d247283bb0292 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationSuccinteTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationSuccinteTest.php @@ -33,7 +33,7 @@ class NoticeIntegrationSuccinteTest extends ModelTestCase { 'non_exportable'=> 'electre;decitre;gam;zebris', 'controle_codes_barres'=> 0, 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, 'champs_sup' => '', 'ean_345' => '', 'Z3950_cache_only' => '0', @@ -104,7 +104,7 @@ class NoticeIntegrationSuccinteTest extends ModelTestCase { 'statut_z3950' => "3", 'serveur' => "Bnf", 'erreur' => false, - 'unimarc' => '01075cjm 22002893 450 001002100000009004700021020001700068021005400085071004100139073001800180100004100198101000800239102000700247126002500254200007900279210006800358215004700426306003500473608002100508608001600529608003500545686007000580700003600650716002900686801003900715930003100754FRBNF400642570000008http://catalogue.bnf.fr/ark:/12148/cb400642576 aFRb70601036 5FR-759999999:SDC 12-202181aFRbDLS-20051103-917001bInsideOutMusicaSPV 48622 CDcboÃite 0a0693723486222 a20051103d2005 u y0frey50 ba0 aeng aDE aaguxhxx||||||cdbbex1 a?bEnregistrement sonorefNeal Morse, chant, guit., claviers [acc. instr.] aKlevecInsideOutMusica[Paris]c[distrib. Wagram music]dP 2005 a1 disque compact (56 min 26 s)e1 brochure aProd. : InsideOutMusic, P 2005 arock, pop2frTAV arock2frTAV aÂedition phonographique2frTAV a1062Cadre de classement de la Bibliographie nationale franÐcaise |314208951aMorsebNeal47214545 314032403aInsideOutMusic 0aFRbBNFc20051103gAFNOR2intermrc 5FR-759999999:SDC 12-202181']) + 'unimarc' => '01075cjm 22002893 450 001002100000009004700021020001700068021005400085071004100139073001800180100004100198101000800239102000700247126002500254200007900279210006800358215004700426306003500473608002100508608001600529608003500545686007000580700003600650716002900686801003900715930003100754FRBNF400642570000008http://catalogue.bnf.fr/ark:/12148/cb400642576 aFRb70601036 5FR-759999999:SDC 12-202181aFRbDLS-20051103-917001bInsideOutMusicaSPV 48622 CDcboîte 0a0693723486222 a20051103d2005 u y0frey50 ba0 aeng aDE aaguxhxx||||||cdbbex1 a?bEnregistrement sonorefNeal Morse, chant, guit., claviers [acc. instr.] aKlevecInsideOutMusica[Paris]c[distrib. Wagram music]dP 2005 a1 disque compact (56 min 26 s)e1 brochure aProd. : InsideOutMusic, P 2005 arock, pop2frTAV arock2frTAV aÉdition phonographique2frTAV a1062Cadre de classement de la Bibliographie nationale française |314208951aMorsebNeal47214545 314032403aInsideOutMusic 0aFRbBNFc20051103gAFNOR2intermrc 5FR-759999999:SDC 12-202181']) ->beStrict()) ->traiteSuccinte($succinte); diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index 0d4388a0818d01a491dd4aca9fc0e5c7e3d9e3a5..cc0fc85e4fc3fec52e6e9a21517a2a7b180b72b5 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -92,7 +92,7 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { 'non_exportable'=> 'electre;decitre;gam;zebris', 'controle_codes_barres'=> 0, 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => 0, + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, 'champs_sup' => '', 'ean_345' => '']) ->setListeCache(['nature_docs'=> "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image", diff --git a/cosmogramme/tests/php/classes/unimarc_pmb_pierres.txt b/cosmogramme/tests/php/classes/unimarc_pmb_pierres.txt new file mode 100644 index 0000000000000000000000000000000000000000..f61b765ea7dab08bb57eab917f9e3ade9e74121f --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_pmb_pierres.txt @@ -0,0 +1 @@ +01446nam0 22002291i 450 0010005000001000035000050090015000402000087000550100031001421010008001732150018001813270010001993190028002097000028002377020043002652100040003082250039003484100039003878960186004269950085006129960519006972872 a20101012u u u0frey50 a1979-01-011 aCes pierres qui attendentePour un dialogue entre l'hindouisme et le christianisme a978-2-7189-0137-4dE 28.200 afre a268 p.d20 cm aIndex aAucun droit spécifique 1aCocagnacbA.M.9id:2149 1aDorébJoseph4080f1936-....9id:1123 aParisbPariscDescléed19799id:412 aJésus et Jésus-Christv89id:201 0tJésus et Jésus-Christv89id:201 ahttps://brieuc.bibliossimo.net/pmb/opac_css/getimage.php?url_image=http%3A%2F%2Fimages-eu.amazon.com%2Fimages%2FP%2F%21%21isbn%21%21.08.MZZZZZZZ.jpg¬icecode=9782718901374&vigurl= aMédiathèque Saint-YvescMédiathèque Saint-Yvesf18120kC274ruuqCollections f18120kC274m00000000n00000000aMédiathèque Saint-Yvesb1vSalle RuffeletxCollectionsyCollectionseLivre1Empruntable319expl_id:191029create_date:2014-03-04 10:31:219expl_cb:181209expl_cote:C2749expl_statut:19statut_libelle:Empruntable9expl_typdoc:19tdoc_libelle:Livre9expl_section:19section_libelle:Collections9sdoc_codage_import:Collections9expl_owner:19lender_libelle:Médiathèque Saint-Yves9codestat_libelle:Exemplaires9pret_flag:19location_libelle:Salle Ruffelet9locdoc_codage_import:8 \ No newline at end of file diff --git a/library/Class/CosmoVar.php b/library/Class/CosmoVar.php index 2d947484e044bead92e5a26303d698592989138e..fdc23f30455c4b93b8c55303619fe68dee1704bd 100644 --- a/library/Class/CosmoVar.php +++ b/library/Class/CosmoVar.php @@ -105,6 +105,9 @@ class Class_CosmoVar extends Storm_Model_Abstract { const DOUBLE_SEARCH_ALPHA_KEY = 1; const DOUBLE_SEARCH_IDS = 0; + const UNIQ_BARCODE_ONLY = 0; + const UNIQ_BARCODE_WITHIN_LIBRARY = 1; + const PICKUP_LOCATION_ITEM = 0; const PICKUP_LOCATION_CHOICE = 1; const PICKUP_LOCATION_PATRON = 2; diff --git a/library/Class/Notice/DoubleFinder.php b/library/Class/Notice/DoubleFinder.php index 628c45bbb43a52f6452646a95ff4adf63ee4b4cd..dd6642a4620c0576ba9e86c0a7c3670cb7579d78 100644 --- a/library/Class/Notice/DoubleFinder.php +++ b/library/Class/Notice/DoubleFinder.php @@ -21,8 +21,9 @@ class Class_Notice_DoubleFinder { - const VAR_BARCODE_UNIQ_MODE = 'unicite_code_barres'; - const VAR_DOUBLE_MODE = 'mode_doublon'; + const + VAR_BARCODE_UNIQ_MODE = 'unicite_code_barres', + VAR_DOUBLE_MODE = 'mode_doublon'; protected $_barcode_uniq_mode, @@ -90,7 +91,7 @@ class Class_Notice_DoubleFinder { return; $conditions = ['code_barres' => $item['code_barres']]; - if ($this->_barcode_uniq_mode == '1') + if ($this->_barcode_uniq_mode == Class_CosmoVar::UNIQ_BARCODE_WITHIN_LIBRARY) $conditions['id_int_bib'] = (int) $this->_library->getId(); return $this->_getRecordIdByItem($conditions); diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 6132a4ec3fadda56cd833430dd1530cb55c0e562..fdecc7505705321ca12a956ddd6addae9398b634 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2625,6 +2625,7 @@ class UpgradeDB_371_Test extends UpgradeDBTestCase { + class UpgradeDB_372_Test extends UpgradeDBTestCase { public function prepare() { $this->dropTable('rendez_vous_user_notification'); @@ -2674,4 +2675,22 @@ class UpgradeDB_372_Test extends UpgradeDBTestCase { public function shouldHavePrimaryId() { $this->assertPrimary('rendez_vous_user_notification', 'id'); } +} + + + + +class UpgradeDB_373_Test extends UpgradeDBTestCase { + public function prepare() { + $this->silentQuery("UPDATE `variables` SET liste='0:Bibliothèque + codes-barres\r\n1:Code-barres uniquement' WHERE clef='unicite_code_barres'"); + } + + + /** @test */ + public function firstOptionShouldBeBarcodeOnlyThenWithBib() { + $this->assertEquals(['0' => 'Code-barres uniquement', + '1' => 'Bibliothèque + codes-barres'], + Class_CosmoVar::getList('unicite_code_barres')); + } + } \ No newline at end of file