Skip to content
Snippets Groups Projects
Commit 078bcf2f authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#86956_panier_nanook_bokeh_ressources_numeriques_en_sus' into 'hotline'

hotline #86956 fix cosmogramme basket import

See merge request !3024
parents 5feb3f30 50fc0340
Branches
Tags
3 merge requests!3297WIP: Master,!3047Hotline,!3024hotline #86956 fix cosmogramme basket import
Pipeline #6441 passed with stage
in 32 minutes and 3 seconds
- ticket #86956 : Intégration Cosmogramme : correction de l'import de paniers
\ No newline at end of file
......@@ -98,13 +98,7 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
$id_int_bib = $integration->getIdBib();
if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $map['id_notice_sigb'],
'id_int_bib' => $id_int_bib])) {
$this->_log->error($this->_('L\'exemplaire id_origine : %s / id_int_bib : %s n\'a pas été trouvé.',
$map['id_notice_sigb'],
$id_int_bib));
$exemplaire = new Class_Entity();
}
$exemplaire = $this->_getItem($map['id_notice_sigb'], $id_int_bib);
$owners = $this->findPossibleOwnersOfBasketRecord($map);
if ($owners->isEmpty()) {
......@@ -134,6 +128,35 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
}
protected function _getItem($id_notice_sigb, $id_int_bib) {
return ($items = Class_Exemplaire::findAllBy(['id_origine' => $id_notice_sigb,
'id_int_bib' => $id_int_bib]))
? $this->_findItem($items, $id_notice_sigb, $id_int_bib)
: $this->_noItem($id_notice_sigb, $id_int_bib);
}
protected function _findItem($items, $id_notice_sigb, $id_int_bib) {
foreach ($items as $item) {
if (!$record = $item->getNotice())
continue;
if ($record->isSigb())
return $item;
}
return $this->_noItem($id_notice_sigb, $id_int_bib);
}
protected function _noItem($id_notice_sigb, $id_int_bib) {
$this->_log->error($this->_('L\'exemplaire id_origine : %s / id_int_bib : %s n\'a pas été trouvé.',
$id_notice_sigb,
$id_int_bib));
return new Class_Entity();
}
protected function _clean($integration) {
$baskets = Class_PanierNotice::findAllBy(['integration_hash' => $integration->getHash()]);
foreach($baskets as $basket)
......
......@@ -128,6 +128,7 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase {
$this->fixture('Class_Notice',
['id' => 23,
'type_doc' => 1,
'clef_alpha' => 'CASTAFIORE',
'exemplaires' => [$this->fixture('Class_Exemplaire',
['id' => 231,
......@@ -137,19 +138,29 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase {
$this->fixture('Class_Notice',
['id' => 45,
'clef_alpha' => 'TIBET',
'type_doc' => 1,
'exemplaires' => [$this->fixture('Class_Exemplaire',
['id' => 4511,
'id_int_bib' => 2,
'id_origine' => 72490])]]);
$this->fixture('Class_Notice',
['id' => 289898,
'clef_alpha' => 'NONO',
'type_doc' => '121',
'exemplaires' => [$this->fixture('Class_Exemplaire',
['id' => 21,
'id_int_bib' => 2,
'id_origine' => 58265])]]);
$this->fixture('Class_Notice',
['id' => 24,
'clef_alpha' => 'LUNE',
'type_doc' => 1,
'exemplaires' => [$this->fixture('Class_Exemplaire',
['id' => 241,
'id_int_bib' => 2,
'id_origine' => 58265])]]);
}
}
......@@ -157,7 +168,7 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase {
class PhasePanierKohaSameIdOrigine extends PhasePanierKohaTestCase {
class PhasePanierKohaSameIdOrigineTest extends PhasePanierKohaTestCase {
public function _prepareFixtures() {
parent::_prepareFixtures();
......@@ -192,6 +203,12 @@ class PhasePanierKohaSameIdOrigine extends PhasePanierKohaTestCase {
$this->assertEquals('577f79a2c26968b6f5e1360df0dc17af',
Class_PanierNotice::find(1)->getIntegrationHash());
}
/** @test */
public function firstBasketRecordsShouldContainsCOKEENSTOCKCASTAFIORELUNE() {
$this->assertEquals('COKEENSTOCK;CASTAFIORE;LUNE', Class_PanierNotice::find(1)->getNotices());
}
}
......
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