Skip to content
Snippets Groups Projects
Commit 9da07a96 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #93469 : fix codif thesaurus generation

parent 91632d18
Branches
Tags
3 merge requests!3297WIP: Master,!3163Hotline,!3155hotline #93469 : fix codif thesaurus generation
Pipeline #7378 passed with stage
in 35 minutes and 48 seconds
- ticket #93469 : Intégrations : Amélioration de la création des facettes dynamiques
\ No newline at end of file
...@@ -471,7 +471,6 @@ class KohaRecordIntegrationVagabondWithTooMany610aTest extends KohaRecordIntegra ...@@ -471,7 +471,6 @@ class KohaRecordIntegrationVagabondWithTooMany610aTest extends KohaRecordIntegra
class KohaRecordIntegrationEscapableAnnexeCodesTest extends KohaRecordIntegrationTestCase { class KohaRecordIntegrationEscapableAnnexeCodesTest extends KohaRecordIntegrationTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
...@@ -496,3 +495,64 @@ class KohaRecordIntegrationEscapableAnnexeCodesTest extends KohaRecordIntegratio ...@@ -496,3 +495,64 @@ class KohaRecordIntegrationEscapableAnnexeCodesTest extends KohaRecordIntegratio
$this->assertEquals('CHYJR', $this->notice_data['exemplaires'][0]['annexe']); $this->assertEquals('CHYJR', $this->notice_data['exemplaires'][0]['annexe']);
} }
} }
class KohaRecordIntegrationBdMilleniumWithAuthorityTest extends KohaRecordIntegrationTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_CodifThesaurus',
['id' => 6,
'libelle' => 'Mots-clés',
'id_thesaurus' => 'MOTC',
'id_origine' => null,
'code' => 'MOTC',
'rule_zone' => '609',
'rule_label_field' => 'a',
'rule_id_field' => '9']);
$attributs = [[Class_IntProfilDonnees::PROFILE_INDEX_SYSTEMS_FIELDS
=> [['rule' => '',
'system' => 'MSAS',
'default_type' => 'j',
'thesaurus' => '6']]]];
$this->fixture('Class_IntProfilDonnees',
['id' => 1004,
'libelle' => 'Authorities',
'type_fichier' => Class_IntProfilDonnees::FT_AUTHORITY,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'attributs' => serialize($attributs),
]);
$this->loadNotice('unimarc_bd_millenium_with_authority');
$this->millenium = Class_Notice::findFirstBy(['type' => 1]);
}
/** @test */
public function titreShouldBeHommesQuiNaimaientPasLesFemmes() {
$this->assertEquals('Les hommes qui n\'aimaient pas les femmes',
$this->millenium->getTitrePrincipal());
}
/** @test */
public function codifThesaurusIdOrigineShouldBeTrilogie() {
$this->assertNotNull(Class_CodifThesaurus::findFirstBy(['code' => 'MOTC',
'id_thesaurus' => 'MOTC0001',
'id_origine' => 'TRILOGIE',
'libelle' => 'Trilogie',
]));
}
/** @test */
public function codifThesaurusIdOrigineShouldNotBe37483() {
$this->assertNull(Class_CodifThesaurus::findFirstBy(['code' => 'MOTC',
'id_origine' => '37483',
]));
}
}
01322 2200301 4500001000700000010002400007035002100031073001800052090001900070091000900089099000700098100004100105101000800146102000700154106000600161200019000167210004300357215006700400225001700467609002000484700004500504701002200549702004300571801006700614995010900681995012100790995010900911260265 a9782800157771brel. a(OCoLC)868591687 1a9782800157771 9260265a260265 a2c1 tBD a20140318 frey50  afre aFR ar1 aLes hommes qui n'aimaient pas les femmesbTexte impriméeseconde partiefscénario, Sylvain Runberggdessin, José Homsgd'après la trilogie de Stieg LarssonhTome 2hseconde partie aPariscDupuisd2013eimpr. en Belgique a1 vol. (64 p.)ctout ill. en coul., couv. ill. en coul.d32 cm aMilleniumv2 aTrilogie937483 9495032aRunbergbSylvainf1971-....4690 9485177aHoms4440 9545077aLarssonbStiegf1954-20044100 3gAFNORaFRbMediatheque intercommunale Ouest Provencec20140225 f31301011644247m2014-07-0840009492216bFOS20kBD RUN62014-03-11o0cLLv14.50rBDaFOSeL1l00qNL4 f31301011644122m2014-10-0440009492217bMIR20kBD RUN62014-03-11n2014-10-25o0cLLv14.50rBDaMIReL1l00qNL4 f31301011644189m2014-10-1040009492218bENT20kBD RUN62014-03-11o0cLLv14.50rBDaENTeL1l00qNL4
\ No newline at end of file
...@@ -32,7 +32,7 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets { ...@@ -32,7 +32,7 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets {
protected function _newFor($thesaurus, $int_bib) { protected function _newFor($thesaurus, $int_bib) {
return $int_bib && ($index_systems = $thesaurus->authoritiesIndexSystems()) return ($index_systems = $thesaurus->authoritiesIndexSystems())
? new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Authority($thesaurus, $index_systems, $int_bib) ? new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Authority($thesaurus, $index_systems, $int_bib)
: new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Simple($thesaurus); : new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Simple($thesaurus);
} }
...@@ -60,12 +60,20 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Simple { ...@@ -60,12 +60,20 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Simple {
protected function _getOrCreateChildren($rules, $reader) { protected function _getOrCreateChildren($rules, $reader) {
$id_labels = $rules->extractIdAndFields($reader); $id_labels = $rules->extractIdAndFields($reader);
return array_map(function($id_label) return array_filter(array_map([$this, '_getOrCreateChild'], $id_labels));
{ }
return $this->_thesaurus->getOrCreateChild($id_label['id'],
$id_label['label']);
}, protected function _getOrCreateChild($id_label) {
$id_labels); $id = trim($id_label['id']);
$label = trim($id_label['label']);
if (!$label)
return;
if (!$id)
$id = strtoupper($label);
return $this->_thesaurus->getOrCreateChild($id, $label);
} }
} }
......
...@@ -5,15 +5,6 @@ require(__DIR__.'/../console.php'); ...@@ -5,15 +5,6 @@ require(__DIR__.'/../console.php');
echo "\n\nWelcome to the iReindex Authorities 3000 PRO tool by @patbator\n\n"; echo "\n\nWelcome to the iReindex Authorities 3000 PRO tool by @patbator\n\n";
$int_bib = null;
while(!$int_bib) {
$id_int_bib = (int)readline('Please tell me the id_int_bib : ');
echo ($int_bib = Class_IntBib::find($id_int_bib))
? ("Authorities generated by bibliographic links will be linked to : " . $int_bib->getNomCourt() . "\n\n")
: "IntBib not found try again \n\n";
}
echo "\n\n==== AUTHORITIES ====\n\n"; echo "\n\n==== AUTHORITIES ====\n\n";
class Scripts_Local_Authorities_Indexer { class Scripts_Local_Authorities_Indexer {
...@@ -79,18 +70,23 @@ while ($records = Class_Notice::findAllBy(['type' => Class_Notice::TYPE_AUTHORIT ...@@ -79,18 +70,23 @@ while ($records = Class_Notice::findAllBy(['type' => Class_Notice::TYPE_AUTHORIT
echo "\n\n==== BIBLIOS ====\n\n"; echo "\n\n==== BIBLIOS ====\n\n";
class Scripts_Local_Biblios_Indexer { class Scripts_Local_Biblios_Indexer {
protected $_dynamic_facets, $_int_bib; protected $_dynamic_facets;
public function __construct($int_bib) { public function __construct() {
$this->_int_bib = $int_bib;
$this->_dynamic_facets = new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets(); $this->_dynamic_facets = new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets();
} }
public function index($record) { public function index($record) {
echo '.'; echo '.';
$thesauri = $this->_dynamic_facets->thesauriOf($record, $this->_int_bib); if (!$first_item = $record->getFirstExemplaire())
return;;
if (!$bib = $first_item->getIntBib())
return;
$thesauri = $this->_dynamic_facets->thesauriOf($record, $bib);
$record->updateFacette(implode(' ', array_map(function($item) { return $item->getFacetCode(); }, $record->updateFacette(implode(' ', array_map(function($item) { return $item->getFacetCode(); },
array_filter($thesauri)))) array_filter($thesauri))))
->save(); ->save();
...@@ -98,7 +94,7 @@ class Scripts_Local_Biblios_Indexer { ...@@ -98,7 +94,7 @@ class Scripts_Local_Biblios_Indexer {
} }
$indexer = new Scripts_Local_Biblios_Indexer($int_bib); $indexer = new Scripts_Local_Biblios_Indexer();
$page = 1; $page = 1;
while ($records = Class_Notice::findAllBy(['type' => Class_Notice::TYPE_BIBLIOGRAPHIC, while ($records = Class_Notice::findAllBy(['type' => Class_Notice::TYPE_BIBLIOGRAPHIC,
'limitPage' => [$page, 1000]])) { 'limitPage' => [$page, 1000]])) {
......
...@@ -147,7 +147,7 @@ class AuthoritiesNoticeAjaxControllerTest extends AuthoritiesTestCase { ...@@ -147,7 +147,7 @@ class AuthoritiesNoticeAjaxControllerTest extends AuthoritiesTestCase {
class AuthoritiesBibliographicDynamicFacetsWithoutIndexSystemTest extends ModelTestCase { class AuthoritiesBibliographicDynamicFacetsWithoutIndexSystemTest extends ModelTestCase {
protected $_thesaurus; protected $_thesauri;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
...@@ -162,22 +162,39 @@ class AuthoritiesBibliographicDynamicFacetsWithoutIndexSystemTest extends ModelT ...@@ -162,22 +162,39 @@ class AuthoritiesBibliographicDynamicFacetsWithoutIndexSystemTest extends ModelT
'rule_label_field' => 'a', 'rule_label_field' => 'a',
'rule_id_field' => '9']); 'rule_id_field' => '9']);
$thesauri = (new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets()) $this->_thesauri = (new Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets())
->thesauriOf((new Class_NoticeUnimarc())->setNotice(file_get_contents(__DIR__ . '/vagabond.mrc')), ->thesauriOf((new Class_NoticeUnimarc())->setNotice(file_get_contents(__DIR__ . '/vagabond.mrc')),
$this->fixture('Class_IntBib', ['id' => 3])); $this->fixture('Class_IntBib', ['id' => 3]));
$this->_thesaurus = reset($thesauri);
} }
/** @test */ /** @test */
public function thesaurusIdShouldBeMots0001() { public function shouldHave2Thesauri() {
$this->assertEquals('MOTS0001', $this->_thesaurus->getIdThesaurus()); $this->assertEquals(2, count($this->_thesauri));
} }
/** @test */ /** @test */
public function thesaurusLabelShouldBeManga() { public function firstThesaurusIdShouldBeMots0001() {
$this->assertEquals('Manga', $this->_thesaurus->getLibelle()); $this->assertEquals('MOTS0001', $this->_thesauri[0]->getIdThesaurus());
}
/** @test */
public function firstThesaurusLabelShouldBeManga() {
$this->assertEquals('Manga', $this->_thesauri[0]->getLibelle());
}
/** @test */
public function firstThesaurusIdOrigineShouldBe213399() {
$this->assertEquals('213399', $this->_thesauri[0]->getIdOrigine());
}
/** @test */
public function secondThesaurusLabelShouldBeTrimmed() {
$this->assertEquals('Cicatrice', $this->_thesauri[1]->getLibelle());
} }
...@@ -373,19 +390,36 @@ class AuthoritiesBibliographicDynamicFacetsWithIndexSystemAlreadyExistingTest ex ...@@ -373,19 +390,36 @@ class AuthoritiesBibliographicDynamicFacetsWithIndexSystemAlreadyExistingTest ex
/** @test */ /** @test */
public function authorityShouldNotBeCreated() { public function authorityItemShouldNotBeDuplicated() {
$this->assertEquals(1, Class_Notice::countBy(['type' => Class_Notice::TYPE_AUTHORITY])); $this->assertEquals(1, Class_Exemplaire::countBy(['type' => Class_Notice::TYPE_AUTHORITY,
'id_origine' => 213399]));
} }
/** @test */ /** @test */
public function authorityItemShouldNotBeCreated() { public function authorityShouldHaveOneItemOnly() {
$this->assertEquals(1, Class_Notice::find(14)->numberOfExemplaires()); $this->assertEquals(1, Class_Notice::find(14)->numberOfExemplaires());
} }
/** @test */ /** @test */
public function authorityShouldHaveThesaurusFacet() { public function authorityShouldHaveThesaurusFacetHMOTS0001() {
$this->assertContains('HMOTS0001', Class_Notice::find(14)->getFacetCodes()); $this->assertContains('HMOTS0001', Class_Notice::find(14)->getFacetCodes());
} }
/** @test */
public function authorityItemForCicatriceShouldBeCreated() {
$this->assertNotNull(Class_Exemplaire::findFirstBy(['type' => Class_Notice::TYPE_AUTHORITY,
'id_origine' => 78]));
}
/** @test */
public function authorityRecordForCicactriceShouldHaveThesaurusFacetHMOTS0002() {
$this->assertContains('HMOTS0002',
Class_Exemplaire::findFirstBy(['type' => Class_Notice::TYPE_AUTHORITY,
'id_origine' => 78])
->getNotice()->getFacetCodes());
}
} }
01499nam 2200361 4500001000400000003004700004010004700051020001700098021002000115039001900135090000800154091001900162099001300181100004100194101000800235102000700243105001800250106000600268200017600274210005600450215009700506461003300603610001000636619001800646676001000664700007200674702005000746702006100796702004000857801007000897930002900967995014100996869http://catalogue.bnf.fr/ark:/12148/cb37710769n a2-84580-144-0bbr.dPrix : 59 F : 8,99 EUR aFRb00201411 aFRbDL 01-54100 oOPLa027037083 a869 b20140822c1a2 eUZELtBD a20020103d2001 m y0frey50 ba1 afre aFR aa t 00|a| ar1 aVagabondbTexte impriméh4fTakehiko Inouégd'après l'oeuvre d'Eiji Yoshikawa, "Miyamoto Musashi"g[trad. du japonais par Jacques Lalloz]g[adapté par Philippe Marcel] aPariscÉd. Tonkamd2001e35-RennesgImpr. Oberthur aNon paginé [ca 206] p.cill. en noir et en coul., couv. ill., jaquette ill. en coul.d19 cm 0tVagabondv4aTakehiko Inoué aManga aManga9213399 a741.5 313527612935oISNI0000000121039965aInouebTakehikof1967-....4070 311929525936aYoshikawabEijif1892-19624100 312040286937oISNI0000000108815456aLallozbJacques4730 312320807938aMarcelbPhilippe4010 0aFRbFR-751131015c20020103gAFNORhFRBNF3771076900000002intermrc 5FR-751131010:2003-196584 fSTJ000095w2014-06-2630009117cMTRSTJ20kBD VAG 452012-09-07o0efiction adulte bande dessineesddcrBDm2014-06-19bMTRSTJ6MTRSTJ 01557nam 2200385 4500001000400000003004700004010004700051020001700098021002000115039001900135090000800154091001900162099001300181100004100194101000800235102000700243105001800250106000600268200017600274210005600450215009700506461003300603610001000636619001800646619002300664619001100687676001000698700007200708702005000780702006100830702004000891801007000931930002901001995014101030869http://catalogue.bnf.fr/ark:/12148/cb37710769n a2-84580-144-0bbr.dPrix : 59 F : 8,99 EUR aFRb00201411 aFRbDL 01-54100 oOPLa027037083 a869 b20140822c1a2 eUZELtBD a20020103d2001 m y0frey50 ba1 afre aFR aa t 00|a| ar1 aVagabondbTexte impriméh4fTakehiko Inouégd'après l'oeuvre d'Eiji Yoshikawa, "Miyamoto Musashi"g[trad. du japonais par Jacques Lalloz]g[adapté par Philippe Marcel] aPariscÉd. Tonkamd2001e35-RennesgImpr. Oberthur aNon paginé [ca 206] p.cill. en noir et en coul., couv. ill., jaquette ill. en coul.d19 cm 0tVagabondv4aTakehiko Inoué aManga aManga9213399 a Cicatrice 978 a98839 a741.5 313527612935oISNI0000000121039965aInouebTakehikof1967-....4070 311929525936aYoshikawabEijif1892-19624100 312040286937oISNI0000000108815456aLallozbJacques4730 312320807938aMarcelbPhilippe4010 0aFRbFR-751131015c20020103gAFNORhFRBNF3771076900000002intermrc 5FR-751131010:2003-196584 fSTJ000095w2014-06-2630009117cMTRSTJ20kBD VAG 452012-09-07o0efiction adulte bande dessineesddcrBDm2014-06-19bMTRSTJ6MTRSTJ
\ No newline at end of file \ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment