Skip to content
Snippets Groups Projects
Commit 65dee17e authored by Laurent's avatar Laurent
Browse files

dev #17871 OAI

increment import
parent e1c959f8
Branches
Tags
2 merge requests!917Dev#17871 oaista la vista,!904Dev#17871 oaista la vista
......@@ -94,15 +94,32 @@ class Class_Cosmogramme_Integration_DataSourceOAI extends Class_Cosmogramme_Inte
public function __construct($integration) {
parent::__construct($integration);
list($uri_path, $uri_params) = array_filter(explode('?', $integration->getFichier()));
$this->_uri = $uri_path;
parse_str($uri_params, $this->_uri_params);
$this->_computeURIParams($uri_params, $integration);
$this->_oai_client = $this->newClient();
$this->_position = $this->_integration->getPointeurReprise();
$this->_barcode_field = $integration->getProfilDonnees()->getBarCodeField();
}
protected function _computeURIParams($uri_params, $integration) {
parse_str($uri_params, $this->_uri_params);
if ($integration->isTotal())
return $this;
if (!$last_integration = Class_Cosmogramme_Integration::findFirstBy(['fichier' => $integration->getFichier(),
'id_bib' => $integration->getIdBib(),
'order' => 'id desc',
'traite' => 'oui']))
return $this;
$this->_uri_params['dateFrom'] = $last_integration->getDateTransfert();
}
public function isValid() {
return true;
}
......
......@@ -117,4 +117,37 @@ class PhaseNoticeOAIWithBarcodeOnFieldGTest extends PhaseNoticeOAITestCase {
}
class PhaseNoticeOAIPartialImportTest extends PhaseNoticeOAITestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
Class_Cosmogramme_Integration::find(999)->beIncrementImport()->save();
$this->fixture('Class_Cosmogramme_Integration',
['id' => 998,
'bib' => Class_IntBib::find(2),
'profil_donnees' => Class_IntProfilDonnees::find(102),
'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL,
'traite' => 'oui',
'date_transfert' => '2014-04-13',
'fichier' => 'http://oai.sta/lavista?verb=ListRecords&metadataPrefix=marc21&set=SCD01',
'pointeur_reprise' => 0]);
$webclient = Storm_Test_ObjectWrapper::mock();
$webclient->whenCalled('open_url')
->with('http://oai.sta/lavista?verb=ListRecords&metadataPrefix=marc21&set=SCD01&dateFrom=2014-04-13')
->answers(file_get_contents(__DIR__.'/oairesults_page2.xml'))
->beStrict();
Class_WebService_OAI::setDefaultHttpClient($webclient);
}
/** @test */
public function totalNumberOfRecordsFromOAIShouldBeSeven() {
$this->assertEquals(7, Class_Notice::countBy([]));
}
}
?>
\ 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