Commit 3c5d23d1 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#63383_probleme_sur_import_de_panier' into 'stable'

Hotline#63383 probleme sur import de panier

See merge request !2349
parents 1eae81ec f7b365de
- ticket #63383 : Cosmogramme : correction de l'import des paniers.
\ No newline at end of file
<?php
try{
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$adapter->query('alter table integrations add column nom_fichier varchar(255) not null');
$adapter->query('alter table notices_paniers add column integration_hash varchar(255) not null');
} catch(Exception $e) {}
?>
......@@ -38,7 +38,8 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract {
'role' => 'integration',
'referenced_in' => 'profil']],
$_default_attribute_values = ['type_doc' => ''],
$_default_attribute_values = ['type_doc' => '',
'nom_fichier' => ''],
$_data_source;
......@@ -144,4 +145,18 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract {
$this->_data_source = $source;
return $this;
}
public function getHash() {
return md5(implode(',', $this->_getHashAttributes()));
}
protected function _getHashAttributes() {
return [$this->getIdBib(),
$this->getTypeOperation(),
$this->getProfil(),
$this->getTypeDoc(),
$this->getNomFichier()];
}
}
\ No newline at end of file
......@@ -128,13 +128,14 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
->setIdIntBib($id_int_bib)
->setUser($owner)
->setIdabon($owner->getIdabon())
->setIntegrationHash($integration->getHash())
->addNotice($exemplaire->getNotice())
->save();
}
protected function _clean($integration) {
$baskets = Class_PanierNotice::findAllBy(['id_int_bib' => $integration->getId()]);
$baskets = Class_PanierNotice::findAllBy(['integration_hash' => $integration->getHash()]);
foreach($baskets as $basket)
$basket->setNotices('')->save();
}
......@@ -151,7 +152,5 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
protected function _afterFileProcessed($integration) {
Class_PanierNotice::deleteBy(['id_int_bib' => $integration->getId(),
'notices' => '']);
}
}
......@@ -210,17 +210,13 @@ class Class_Cosmogramme_Integration_PhasePrepareIntegrations extends Class_Cosmo
public function _newIntegration($filename, $majauto) {
$id_bib = $majauto->getIdBib();
$id_profil = $majauto->getProfil();
$type_operation = $majauto->getTypeOperation();
$type_doc = $majauto->getTypeDoc();
$integration = Class_Cosmogramme_Integration::newInstance(['id_bib' => $id_bib,
'type_operation' => $type_operation,
'profil' => $id_profil,
'type_doc' => $type_doc,
$integration = Class_Cosmogramme_Integration::newInstance(['id_bib' => $majauto->getIdBib(),
'type_operation' => $majauto->getTypeOperation(),
'profil' => $majauto->getProfil(),
'type_doc' => $majauto->getTypeDoc(),
'date_transfert' => $this->getCurrentDate(),
'fichier' => $filename,
'nom_fichier' => $majauto->getNomFichier(),
'traite' => 'non']);
$integration->save();
}
......
......@@ -135,7 +135,8 @@ class Class_PanierNotice extends Storm_Model_Abstract {
'unique' => true]],
$_default_attribute_values = ['notices' => '',
'libelle' => ''];
'libelle' => '',
'integration_hash' => ''];
public function index() {
......
......@@ -1733,4 +1733,28 @@ class UpgradeDB_335_Test extends UpgradeDBTestCase {
$batch = $this->fetchBatchByType($type);
$this->assertEquals($pick_day, $batch['pick_day']);
}
}
\ No newline at end of file
}
class UpgradeDB_336_Test extends UpgradeDBTestCase {
public function prepare() {
try {
$this->query('ALTER TABLE integrations DROP column nom_fichier');
$this->query('ALTER TABLE notices_paniers DROP column integration_hash');
} catch(Exception $e) {}
}
/** @test */
public function columnNomFichierShouldBePresent() {
$this->assertColumn('integrations', 'nom_fichier');
}
/** @test */
public function columnIntegrationHashShouldBePresent() {
$this->assertColumn('notices_paniers', 'integration_hash');
}
}
......@@ -44,11 +44,12 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
$this->fixture('Class_Cosmogramme_Integration',
['id' => 999,
'bib' => Class_IntBib::find(2),
'profil_donnees' => Class_IntProfilDonnees::find(102),
'id_bib' => 2,
'profil' => 102,
'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL,
'traite' => 'non',
'fichier' => 'baskets.txt',
'nom_fichier' => 'baskets.txt',
'pointeur_reprise' => 0]);
}
......@@ -121,6 +122,7 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase {
'id_user' => 3,
'id_sigb' => 1,
'id_int_bib' => 2,
'integration_hash' => '577f79a2c26968b6f5e1360df0dc17af',
'libelle' => 'will be killed',
'notices' => 'VOL714']);
......@@ -173,13 +175,23 @@ class PhasePanierKohaSameIdOrigine extends PhasePanierKohaTestCase {
/** @test */
public function firstBasketRecordsShouldContainNoticeLune() {
$this->assertEquals(['COKEENSTOCK',
'CASTAFIORE',
'LUNE'],
Class_PanierNotice::find(1)->getClesNotices());
public function fourthBasketRecordsShouldBeEmpty() {
$this->assertEmpty(Class_PanierNotice::find(4)->getClesNotices());
}
/** @test */
public function fourthBasketIntegrationHashShouldBe577f79a2c26968b6f5e1360df0dc17af() {
$this->assertEquals('577f79a2c26968b6f5e1360df0dc17af',
Class_PanierNotice::find(4)->getIntegrationHash());
}
/** @test */
public function firstBasketIntegrationHashShouldBecome577f79a2c26968b6f5e1360df0dc17af() {
$this->assertEquals('577f79a2c26968b6f5e1360df0dc17af',
Class_PanierNotice::find(1)->getIntegrationHash());
}
}
......@@ -254,7 +266,7 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase {
/** @test */
public function basketTitiShouldBeEmpty() {
$this->assertEmpty(Class_PanierNotice::findFirstBy(['id_sigb' => '7'])->getClesNotices());
$this->assertEmpty(Class_PanierNotice::findFirstBy(['id_sigb' => 7])->getClesNotices());
}
......@@ -454,7 +466,7 @@ class PhasePanierNanookTest extends PhasePanierTestCase {
/** @test */
public function IdIntBibShouldBe2() {
$this->assertEquals('2', $this->_basket->getIdIntBib());
public function IdIntBibShouldBe999() {
$this->assertEquals(2, $this->_basket->getIdIntBib());
}
}
......@@ -188,11 +188,23 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA
/** @test */
public function firstIntegrationURIShouldBeIntegre1179DotPan() {
public function firstIntegrationFileShouldBeIntegre1179DotPan() {
$this->assertEquals('integre1179.pan', Class_Cosmogramme_Integration::find(2)->getFichier());
}
/** @test */
public function firstIntegrationFileNameShouldBeMyLibraryTotalDotTxt() {
$this->assertEquals('foo/mylibrarytotal.txt', Class_Cosmogramme_Integration::find(2)->getNomFichier());
}
/** @test */
public function firstIntegrationKeyShouldBeHash() {
$this->assertEquals('a7be1b1bbdfe70b6fec563334accab3f', Class_Cosmogramme_Integration::find(2)->getHash());
}
/** @test */
public function secondIntegrationURIShouldBeOAIRepository() {
$this->assertEquals('http://oai-repository.fr/oai', Class_Cosmogramme_Integration::find(3)->getFichier());
......
Markdown is supported
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