begin adapt old tainacan importer
This commit is contained in:
parent
3653930f9a
commit
fca1d52b36
|
@ -8,12 +8,16 @@
|
|||
|
||||
namespace Tainacan\Importer;
|
||||
|
||||
class Old_Tainacan extends Importer
|
||||
{
|
||||
class Old_Tainacan extends Importer{
|
||||
|
||||
protected $manual_mapping = true;
|
||||
|
||||
protected $manual_collection = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->set_repository();
|
||||
// $this->set_repository();
|
||||
$this->set_steps($this->steps);
|
||||
$this->remove_import_method('file');
|
||||
$this->add_import_method('url');
|
||||
|
@ -30,13 +34,23 @@ class Old_Tainacan extends Importer
|
|||
'socialdb_property_fixed_attachments'
|
||||
],
|
||||
$steps = [
|
||||
'Creating all categories' => 'create_categories',
|
||||
'Create empty collections' => 'create_collections',
|
||||
'Creating relationships metadata' => 'create_relationships_meta',
|
||||
'Create repository metadata' => 'treat_repo_meta',
|
||||
'Create collections metadata' => 'treat_collection_metas',
|
||||
'Create collections items' => 'create_collection_items',
|
||||
"Finishing" => 'clear'
|
||||
//'Creating all categories' => 'create_categories',
|
||||
//'Create empty collections' => 'create_collections',
|
||||
//'Creating relationships metadata' => 'create_relationships_meta',
|
||||
//'Create repository metadata' => 'treat_repo_meta',
|
||||
//'Create collections metadata' => 'treat_collection_metas',
|
||||
[
|
||||
'name' => 'Create categories, collections and metadata',
|
||||
'callback' => 'process_collections'
|
||||
],
|
||||
[
|
||||
'name' => 'Import Items',
|
||||
'callback' => 'process_collections'
|
||||
],
|
||||
[
|
||||
'name' => 'Finishing',
|
||||
'callback' => 'clear'
|
||||
]
|
||||
], $tainacan_api_address, $wordpress_api_address;
|
||||
|
||||
|
||||
|
@ -653,12 +667,13 @@ class Old_Tainacan extends Importer
|
|||
* get values for a single item
|
||||
*
|
||||
* @param $index
|
||||
* @param $collection_id
|
||||
* @return array with field_source's as the index and values for the
|
||||
* item
|
||||
*
|
||||
* Ex: [ 'Field1' => 'value1', 'Field2' => [ 'value2','value3' ]
|
||||
*/
|
||||
public function process_item($index)
|
||||
public function process_item( $index, $collection_id )
|
||||
{
|
||||
$processedItem = [];
|
||||
$headers = $this->get_fields();
|
||||
|
@ -759,6 +774,7 @@ class Old_Tainacan extends Importer
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method implemented by the child importer class to return the number of items to be imported
|
||||
* @return int
|
||||
|
@ -774,4 +790,19 @@ class Old_Tainacan extends Importer
|
|||
|
||||
return $this->total_items = $file_content->found_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method implemented by the child importer class to return the number of items to be imported
|
||||
* @return int
|
||||
*/
|
||||
public function get_progress_total_from_source(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Method implemented by the child importer class to return the number of items to be imported
|
||||
* @return int
|
||||
*/
|
||||
public function get_source_fields(){
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$id = $old_tainacan_importer->get_id();
|
||||
$_SESSION['tainacan_importer'][$id]->set_collection( $collection );
|
||||
this->assertEquals( $collection->get_id(), $_SESSION['tainacan_importer'][$id]->collection->get_id() );
|
||||
}
|
||||
}*/
|
||||
|
||||
public function test_automapping_old_tainacan()
|
||||
{
|
||||
|
@ -38,29 +38,31 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$old_tainacan = new Importer\Old_Tainacan();
|
||||
$id = $old_tainacan->get_id();
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->set_items_per_step(50);
|
||||
|
||||
//if(!copy('./tests/attachment/json_old_tainacan_base.txt', './tests/attachment/json_old_tainacan.txt'))
|
||||
//{
|
||||
//return false;
|
||||
//}
|
||||
|
||||
//$_SESSION['tainacan_importer'][$id]->set_file( './tests/attachment/json_old_tainacan.txt' );
|
||||
$url = 'http://localhost/wordpress_tainacan/';
|
||||
$_SESSION['tainacan_importer'][$id]->set_url($url);
|
||||
$_SESSION['tainacan_importer'][$id]->set_repository();
|
||||
$url_repository = 'http://localhost/wordpress_tainacan/';
|
||||
$url_repository = '';
|
||||
if( $url_repository !== '' ){
|
||||
$_SESSION['tainacan_importer'][$id]->set_url($url);
|
||||
$_SESSION['tainacan_importer'][$id]->set_repository();
|
||||
|
||||
while (!$_SESSION['tainacan_importer'][$id]->is_finished())
|
||||
{
|
||||
$_SESSION['tainacan_importer'][$id]->run();
|
||||
while (!$_SESSION['tainacan_importer'][$id]->is_finished())
|
||||
{
|
||||
$_SESSION['tainacan_importer'][$id]->run();
|
||||
}
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
$this->assertEquals(3, $collections, 'total collection in this url does not match');
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
|
||||
$this->assertEquals(3, $collections, 'total collection in this url does not match');
|
||||
|
||||
$this->assertTrue(true);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
/*public function test_file_old_tainacan () {
|
||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||
|
|
Loading…
Reference in New Issue