Merge branch 'develop'
This commit is contained in:
commit
abd670c61d
|
@ -160,7 +160,7 @@ class CSV extends Importer {
|
||||||
$valueToInsert = $this->handle_encoding( $values[ $column ] );
|
$valueToInsert = $this->handle_encoding( $values[ $column ] );
|
||||||
|
|
||||||
if( !is_numeric($metadatum_id) ){
|
if( !is_numeric($metadatum_id) ){
|
||||||
$metadatum = $this->create_metadata( $metadatum_id, $collection_definition['id']);
|
$metadatum = $this->create_metadata( $headers[ $column ], $collection_definition['id']);
|
||||||
} else {
|
} else {
|
||||||
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
|
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -908,8 +908,8 @@ abstract class Importer {
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected function create_metadata( $metadata_description, $collection_id){
|
protected function create_metadata( $metadata_description, $collection_id){
|
||||||
$taxonomy_repo = \Repositories\Taxonomy::get_instance();
|
$taxonomy_repo = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||||
$metadata_repo = \Repositories\Metadata::get_instance();
|
$metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
|
||||||
|
|
||||||
$properties = array_filter( explode('|', $metadata_description) );
|
$properties = array_filter( explode('|', $metadata_description) );
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
$file = fopen($file_name, 'w');
|
$file = fopen($file_name, 'w');
|
||||||
|
|
||||||
// save the column headers
|
// save the column headers
|
||||||
fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
|
fputcsv($file, array('novo metadatao|text', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
|
||||||
|
|
||||||
// Sample data
|
// Sample data
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -363,7 +363,12 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
//create a random mapping
|
//create a random mapping
|
||||||
$map = [];
|
$map = [];
|
||||||
foreach ( $metadata as $index => $metadatum ){
|
foreach ( $metadata as $index => $metadatum ){
|
||||||
$map[$metadatum->get_id()] = $headers[$index];
|
if( $index === 0){
|
||||||
|
$map['create_metadata'] = $headers[$index];
|
||||||
|
} else {
|
||||||
|
$map[$metadatum->get_id()] = $headers[$index];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection_definition['mapping'] = $map;
|
$collection_definition['mapping'] = $map;
|
||||||
|
@ -383,17 +388,6 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$items = $Tainacan_Items->fetch( ['order'=> 'ASC','orderby' => 'date'], $collection, 'OBJECT' );
|
$items = $Tainacan_Items->fetch( ['order'=> 'ASC','orderby' => 'date'], $collection, 'OBJECT' );
|
||||||
|
|
||||||
foreach ( $items as $index => $item ) {
|
|
||||||
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadata_taxonomy );
|
|
||||||
|
|
||||||
if( in_array( $item->get_title(),[ 'Data 11','Data 51', 'Data 12','Data 52'] ) ){
|
|
||||||
|
|
||||||
$term = $singleItemMetadata->get_value();
|
|
||||||
$this->assertTrue(in_array( $term->get_name(),['DATA 151','DATA551'] ));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_source_number_of_items(), count( $items ) );
|
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_source_number_of_items(), count( $items ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue