Commit 6aaa348e authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge remote-tracking branch 'refs/remotes/origin/hotline' into origin-master

Conflicts:
	cosmogramme/sql/patch/patch_361.php
	tests/db/UpgradeDBTest.php
parents 6e55492e 0d307bda
Pipeline #5916 passed with stage
in 32 minutes and 19 seconds
10/01/2019 - v7.12.54
- ticket #82189 : Connecteur LeKiosk : correction de la mise à jour lors du moissonage
- ticket #78084 : Administration des albums : correction du chargement d'une feuille de style incorrecte lors de l'ajout de médias
- ticket #82201 : Intégrations : optimisation de l'indexation des ressources numériques
08/01/2019 - v7.12.53
- ticket #84476 : SIGB Orphee correction authentification avec WS configuré en authentification SIGB uniquement
08/01/2019 - v7.12.52
- ticket #81938 : correction de la sauvegarde du paramétrage des boîtes qui pouvait échouer dans certaines conditions
......
......@@ -46,7 +46,6 @@ $(document).ready(function () {
});");
$this->view->headLink()
->appendStylesheet(URL_CSS . 'global.css')
->appendStylesheet(URL_ADMIN_JS . 'multi_upload/fileuploader.css');
$this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml');
......
<?php
(new Class_Migration_DynamicFacets())->run();
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try {
$adapter->query('ALTER TABLE album modify id_origine varchar(255)');
} catch(Exception $e) {}
<?php
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try {
$adapter->query('ALTER TABLE album ADD KEY date_maj (date_maj)');
} catch(Exception $e) {}
<?php
(new Class_Migration_DynamicFacets())->run();
......@@ -54,7 +54,6 @@
*/
class AlbumLoader extends Storm_Model_Loader {
use Trait_MemoryCleaner;
......@@ -82,6 +81,14 @@ class AlbumLoader extends Storm_Model_Loader {
$page++;
}
}
public function findAllAfter($id, $date_maj, $limit=100) {
$where = "id > " . $id . " and date_maj >= '" . $date_maj . "'";
return Class_Album::findAllBy(['where' => $where,
'order' => 'id',
'limit' => $limit]);
}
}
......@@ -173,6 +180,8 @@ class Class_Album extends Storm_Model_Abstract {
protected $path_flash;
protected $_date_maj_enabled = true;
public function __construct() {
parent::__construct();
......@@ -901,6 +910,13 @@ class Class_Album extends Storm_Model_Abstract {
}
public function saveWithoutDateMaj() {
$this->_date_maj_enabled = false;
$this->save();
$this->_date_maj_enabled = true;
}
public function collectAuthors() {
$authors = $this->_collect('authors', self::AUTHOR_FIELD);
if(isset($authors['author']))
......@@ -944,6 +960,9 @@ class Class_Album extends Storm_Model_Abstract {
public function updateDateMaj() {
if (!$this->_date_maj_enabled)
return $this;
return $this->setDateMaj(date('Y-m-d H:i:s', self::getTimeSource()->time()));
}
......
......@@ -24,7 +24,9 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord
extends Class_Cosmogramme_Integration_PhaseAbstract {
use Trait_MemoryCleaner;
protected $_model_id_field, $_memory_cleaner;
protected
$_model_id_field,
$_previous_page = [];
/** @var Trait_Indexable */
protected $_model_name;
......@@ -53,6 +55,9 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord
if ($this->isTimeOut())
return;
if ($this->_isPreviousPage($models))
break;
$this->_runPage($models);
$this->_cleanMemory();
}
......@@ -61,6 +66,16 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord
}
protected function _isPreviousPage($page) {
if ($this->_previous_page
&& !array_filter(array_diff($this->_previous_page, $page)))
return true;
$this->_previous_page = $page;
return false;
}
protected function _runPage($models) {
$this->_log->log($this->_getData('nombre') . '<br>');
foreach($models as $model) {
......
......@@ -25,10 +25,39 @@ class Class_Cosmogramme_Integration_PhasePseudoRecordAlbum extends Class_Cosmogr
protected $_label = 'Pseudo-notices : RESSOURCES NUMERIQUES';
protected $_model_name = 'Class_Album';
protected $_last_update_date;
/** @return array **/
protected function _previousPhaseIds() {
return [0.4];
}
protected function _loadPage() {
$this->_cleanMemory();
return Class_Album::findAllAfter($this->_getData('pointeur_reprise'),
$this->_getData('pointeur'));
}
protected function _runOne($model) {
parent::_runOne($model);
$this->_last_update_date = $model->getDateMaj();
}
protected function _init($phase) {
parent::_init($phase);
$phase->setData('pointeur',
($last_date = Class_CosmoVar::getValueOf('date_maj_albums'))
? $last_date
: '0000-00-00 00:00:00');
}
protected function _summarize() {
Class_CosmoVar::setValueOf('date_maj_albums', $this->getCurrentDateTime());
parent::_summarize();
}
}
......@@ -80,12 +80,16 @@ class Class_Indexation_PseudoNotice {
if (!$this->_ensureItem())
return false;
$this->_updateLinkToRecord();
$this->_index();
return true;
}
protected function _updateLinkToRecord() {
$this->_model
->updateAttributes([$this->_id_notice => $this->_notice->getId()])
->save();
$this->_index();
return true;
}
......@@ -235,9 +239,6 @@ class Class_Indexation_PseudoNotice {
$this->_notice->save();
$this->_indexItem();
$this->_model->setNotice($this->_notice)
->save();
}
......@@ -437,6 +438,13 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{
}
protected function _updateLinkToRecord() {
$this->_model
->setNoticeId($this->_notice->getId())
->saveWithoutDateMaj();
}
protected function _modelIdAcceptVisitor($visitor) {}
......
......@@ -163,7 +163,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac
protected function hasGetAdh() {
return $this->_search_client && $this->_search_client->hasFunction('GetAdh');
return $this->getSearchClient()->hasFunction('GetAdh');
}
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
......@@ -120,4 +121,10 @@ class Lekiosk_Service extends Class_DigitalResource_Service {
? $result['token']
: null;
}
protected function _deleteNonHarvested() {
return $this->_deleteNonHarvestedAlbums();
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ class Lekiosk_Service_Parser {
$album = new Lekiosk_Service_Album();
$album
->setId($attribs['PUBLICATIONID'])
->setId($attribs['PUBLICATIONID'].':'.$attribs['ISSUENUMBER'])
->setTitle($this->_getTitle($attribs))
->setExternalUri($attribs['SSOURL'])
->setDescription($attribs['ISSUEDESCRIPTION'])
......
......@@ -314,8 +314,8 @@ class LekioskServiceHarvestTest extends LekioskServiceTestCase {
/** @test */
public function nationalSportIdShouldBe851749() {
$this->assertEquals(851749, $this->_10_national_sport->getIdOrigine());
public function nationalSportIdShouldBe851749419() {
$this->assertEquals('851749:419', $this->_10_national_sport->getIdOrigine());
}
/** @test */
......@@ -576,14 +576,59 @@ abstract class LekioskServiceHttpHarvestingTestCase extends AbstractControllerTe
$service = new Lekiosk_Service($config);
$service->harvest();
Class_Album::clearCache();
}
}
class LekioskServiceHttpUpdateHarvestingTest extends LekioskServiceHttpHarvestingTestCase {
public function setUp() {
parent::setUp();
$token_json = file_get_contents(__DIR__. '/token.json');
$http_client = $this->mock()
->whenCalled('postRawData')
->with('https://apipros.lekiosk.com/login',
'{"username":"FOIX","userpwd":"PWD"}','application/json')
->answers($token_json)
->whenCalled('open_url')
->with('https://apipros.lekiosk.com/publications/flow',
['headers' => ['Authorization' => 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjY2MjAxNiwibmFtZSI6Illvbm5lQGdtYWlsLmNvbSIsImV4cCI6MTUxNzM5OTE0M30.qZuwpsrZmk95LU0XYKPBFqpJJ4wxOVyZnJ_Gt3panxw']])
->answers(file_get_contents(__DIR__. '/updated_catalogue_from_http.xml'))
->whenCalled('open_url')
->answers(null);
Lekiosk_Service::setDefaultHttpClient($http_client);
$config = Lekiosk_Config::getInstance();
$config->setTimeSource(new TimeSourceForTest('2019-02-06 10:00:00'));
$service = new Lekiosk_Service($config);
$service->harvest();
Class_Album::clearCache();
}
/** @test */
public function allPreviousAlbumShouldBeDeleted() {
$this->assertCount(2, Class_Album::findAll());
}
/** @test */
public function oneAlbumTitleShouldBe10NationalSport() {
$this->assertEquals('Le 10 Sport National n°440 : 6 décembre 2018', Class_Album::find(4)->getTitre());
}
}
class LekioskServiceHttpHarvestingTest extends LekioskServiceHttpHarvestingTestCase {
/** @test */
public function contextShouldExpectation() {
......
B<IFData><Data Typeproduction="Magazine numérique" PublicationDescription="Le 10 Sport National est le mensuel entièrement dédié au sport. Vous y trouverez les infos foot, tennis ou encore basket du moment..." Frequency="Mensuel" IsAdult="0" IssueTitle="Le 10 Sport National" IssueDescription="Le 10 Sport National est le mensuel entièrement dédié au sport. Vous y trouverez les infos foot, tennis ou encore basket du moment..." IssueNumber="440" CoverURL="http://cdn2.lekiosk.com/Public/Publications/851749/21424703/Images/Detail.jpg" ReleaseDate="Thu Dec 06 2018 00:00:00 GMT+0000 (UTC)" PagesCount="32" URL="https://pros.lekiosk.com/login/accesshash?email=107653616b7e508f0f4293c23f868135851bb6ecf777eb8066e2ce89ff47fe8a&amp;id=756&amp;AccessHash=cb39b7947805ae2a98103e393fbf642841a1a83f&amp;returnUrl=/fr/pageproduct/851749/21424703" Editeur="10 Medias" PublicationId="851749" Categories="Sports" SSOURL="https://apipros.lekiosk.com/login/cas?id=756&amp;returnUrl=/fr/pageproduct/851749/21424703" SSOFORMURL="/fr/pageproduct/851749/21424703"/><Data Typeproduction="Magazine numérique" PublicationDescription="20minutes.fr, information en continu. Actualités, Politique, Football, People, High Tech." Frequency="Quotidien" IsAdult="0" IssueTitle="20 Minutes" IssueDescription="" IssueNumber="20190108" CoverURL="http://cdn2.lekiosk.com/Public/Publications/1883912/21431411/Images/Detail.jpg" ReleaseDate="Tue Jan 08 2019 00:00:00 GMT+0000 (UTC)" PagesCount="10" URL="https://pros.lekiosk.com/login/accesshash?email=107653616b7e508f0f4293c23f868135851bb6ecf777eb8066e2ce89ff47fe8a&amp;id=756&amp;AccessHash=cb39b7947805ae2a98103e393fbf642841a1a83f&amp;returnUrl=/fr/pageproduct/1883912/21431411" Editeur="20 Minutes France" PublicationId="1883912" Categories="Quotidiens" SSOURL="https://apipros.lekiosk.com/login/cas?id=756&amp;returnUrl=/fr/pageproduct/1883912/21431411" SSOFORMURL="/fr/pageproduct/1883912/21431411"/></IFData>
......@@ -81,7 +81,7 @@ class Bokeh_Engine {
function setupConstants() {
defineConstant('BOKEH_MAJOR_VERSION','7.12');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.52');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.54');
defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/');
......
......@@ -2397,6 +2397,35 @@ class UpgradeDB_360_Test extends UpgradeDBTestCase {
class UpgradeDB_361_Test extends UpgradeDBTestCase {
public function prepare() {
$this->silentQuery('ALTER TABLE album modify id_origine varchar(50)');
}
/** @test */
public function idOrigineLengthShouldBe255() {
$this->assertFieldType('album','id_origine', 'varchar(255)');
}
}
class UpgradeDB_362_Test extends UpgradeDBTestCase {
public function prepare() {
$this->silentQuery('ALTER TABLE album drop KEY date_maj');
}
/** @test */
public function dateMajShouldBeIndexed() {
$this->assertIndex('album', 'date_maj');
}
}
class UpgradeDB_363_Test extends UpgradeDBTestCase {
public function prepare() {
$this->silentQuery("replace into codif_thesaurus (id_thesaurus, libelle, code, rules) values ('TEST', 'TEST', 'TEST', '{\"label\":\"609\$a\"}')");
}
......
......@@ -36,7 +36,8 @@ abstract class PhasePseudoRecordTestCase extends Class_Cosmogramme_Integration_P
protected function _prepareFixtures() {
$loader = $this->onLoaderOfModel($this->_model_name)
$loader = $this
->onLoaderOfModel($this->_model_name)
->whenCalled('findAllBy')
->with(['where' => $this->_model_id . ' > 0',
......@@ -423,11 +424,42 @@ abstract class PhasePseudoRecordAlbumTestCase extends PhasePseudoRecordTestCase
$_model_name = 'Class_Album',
$_model_id = 'id';
protected function _prepareFixtures() {
Class_Cosmogramme_Integration_PhasePseudoRecordAlbum::setTimeSource(new TimeSourceForTest('2019-01-09 12:11:38'));
Class_CosmoVar::setValueOf('date_maj_albums', '2018-12-18 17:21:54');
$loader = $this
->onLoaderOfModel($this->_model_name)
->whenCalled('findAllBy')
->with(['where' => $this->_model_id . ' > 0 and date_maj >= \'2018-12-18 17:21:54\'',
'order' => $this->_model_id,
'limit' => 100])
->answers([$this->_buildModel(15)])
->whenCalled('findAllBy')
->with(['where' => $this->_model_id . ' > 15 and date_maj >= \'2018-12-18 17:21:54\'',
'order' => $this->_model_id,
'limit' => 100])
->answers([$this->_buildModel(16)])
->whenCalled('findAllBy')->answers([])
;
}
public function tearDown() {
Class_Cosmogramme_Integration_PhasePseudoRecordAlbum::setTimeSource(null);
parent::tearDown();
}
protected function _getModelAttribs($id) {
return array_merge(parent::_getModelAttribs($id),
['titre' => 'Album ' . $id,
'visible' => 1,
'status' => Class_Album::STATUS_VALIDATED]);
'status' => Class_Album::STATUS_VALIDATED,
'date_maj' => '2018-12-18 17:21:54']);
}
}
......@@ -472,6 +504,13 @@ class PhasePseudoRecordAlbumValidInteractiveCallbackTest
->beCallBack()
->setData('nombre', 1)
->setData('pointeur_reprise', 15)
->setData('pointeur', '2018-12-18 17:21:54')
->setCount(Class_Cosmogramme_Integration_Phase::RECORD_INSERT, 6);
}
/** @test */
public function dateMajAlbumsShouldBeUpdated() {
$this->assertEquals('2019-01-09 12:11:38', Class_CosmoVar::get('date_maj_albums'));
}
}
\ No newline at end of file
......@@ -26,11 +26,12 @@ include_once('OrpheeFixtures.php');
class Class_WebService_SIGB_Orphee_ServiceForTesting extends Class_WebService_SIGB_Orphee_Service {
public function __construct($search_client) {
$this->_search_client = $search_client;
$this->_provided_search_client = $search_client;
}
public function getSearchClient() {
$this->_search_client = $this->_provided_search_client;
$result = $this->_search_client->GetId(new GetId());
$this->_guid = $result->GetIdResult;
$this->_search_client->__setCookie('ASP.NET_SessionId', $this->_guid);
......
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