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

hotline #37288 improve localisation with cote

parent 116bb1d3
Branches
Tags
9 merge requests!1553Master,!1519Master,!1502Master,!1501Stable,!1491Master,!1472Stable,!1461Stable,!1454Stable,!1433Hotline#37288 fetch best quality cote from sigb in localisation
- ticket #37288 : Affinement de la localisation des exemplaires grace à la cote récupérée depuis le webservice
\ No newline at end of file
......@@ -79,6 +79,16 @@ class Class_Exemplaire extends Storm_Model_Abstract {
}
public function getBestCote() {
if($this->_sigb_exemplaire &&
($sigb_cote = $this->_sigb_exemplaire->getCote()) &&
(strlen($sigb_cote) > strlen($this->getCote())))
return $sigb_cote;
return $this->getCote();
}
public function getLibelleSite() {
if (null === ($site = Class_CodifAnnexe::findFirstBy(['code' => (string)$this->getAnnexe()])))
return '';
......
......@@ -236,6 +236,7 @@ class Class_Localisation extends Storm_Model_Abstract {
return null;
$quality += $cote_quality;
return [$quality => $this];
}
......@@ -244,18 +245,20 @@ class Class_Localisation extends Storm_Model_Abstract {
if(!$this->hasCoteDebut() && !$this->hasCoteFin())
return 0;
if($this->hasCoteFin() && ($item->getCote() > $this->getCoteFin()))
$item_cote = $item->getBestCote();
if($this->hasCoteFin() && ($item_cote > $this->getCoteFin()))
return -1;
if($this->hasCoteDebut() && ($item->getCote() < $this->getCoteDebut()))
if($this->hasCoteDebut() && ($item_cote < $this->getCoteDebut()))
return -1;
$cote_quality = 0;
if($this->hasCoteDebut() && ($item->getCote() >= $this->getCoteDebut()))
if($this->hasCoteDebut() && ($item_cote >= $this->getCoteDebut()))
$cote_quality++;
if($this->hasCoteFin() && ($item->getCote() <= $this->getCoteFin()))
if($this->hasCoteFin() && ($item_cote <= $this->getCoteFin()))
$cote_quality++;
return $cote_quality;
......
......@@ -35,6 +35,13 @@ class LocalisationTest extends Storm_Test_ModelTestCase {
'section' => 'A',
'type_doc' => 1]);
$this->fixture('Class_Localisation',
['id' => 55,
'id_bib' => 1,
'libelle' => 'Polar',
'cote_debut' => 'ROM AAA',
'cote_fin' => 'ROM ZZZ']);
$this->fixture('Class_Localisation',
['id' => 2,
'id_bib' => 1,
......@@ -171,6 +178,25 @@ class LocalisationTest extends Storm_Test_ModelTestCase {
Class_Localisation::getItemLocalisation($item)['libelle']);
}
}
?>
\ No newline at end of file
/** @test */
public function romanByCoteFromSigbLocalisationShouldBePolar() {
$item = $this->fixture('Class_Exemplaire',
['id' => 4,
'id_bib' => 1,
'cote' => 'ROM',
'section' => '1',
'type_doc' => 1,
'annexe' => 1,
'notice' => $this->fixture('Class_Notice',
['id' => 2,
'type_doc' => 1])]);
$item->setSigbExemplaire(Storm_Test_ObjectWrapper::mock()
->whenCalled('getCote')
->answers('ROM POL'));
$this->assertEquals('Polar',
Class_Localisation::getItemLocalisation($item)['libelle']);
}
}
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