Commit 19534178 authored by Sebastian Castro's avatar Sebastian Castro

Somes fixs

parent 0a6d6828
......@@ -104,4 +104,6 @@ db.Element.updateMany( { } , { $rename: { 'website': 'data.website', 'telephone'
db.Element.updateMany({ 'data.openhours_more_infos': null }, { $unset: { 'data.openhours_more_infos': "" } })
db.Element.find({ 'data.openhours_more_infos': null })
db.GoGoLog.updateMany( { } , { $rename: { 'type': 'level' } } )
\ No newline at end of file
db.GoGoLog.updateMany( { } , { $rename: { 'type': 'level' } } )
db.Configuration.updateMany( { } , { $set: { 'defautTileLayer': DBRef("TileLayer", 7, "gogocarto_default") }})
......@@ -20,21 +20,20 @@ class ImportAdmin extends ImportAbstractAdmin
->add('file', 'file', array('label' => 'Fichier à importer', 'required' => false))
->add('url', 'text', array('label' => 'Ou Url vers une API Json', 'required' => false))
->add('geocodeIfNecessary', null, array('required' => false, 'label' => 'Géocoder les élements sans latitude ni longitude à partir de leur adresse'))
->add('createMissingOptions', null, array('required' => false, 'label' => 'Créer les options manquantes'))
// ->add('parentCategoryToCreateOptions', 'sonata_type_model', array(
// 'class'=> 'Biopen\GeoDirectoryBundle\Document\Category',
// 'required' => false,
// 'btn_add' => false,
// 'label' => 'Catégorie parente pour créer les options manquantes',
// 'mapped' => true), array('admin_code' => 'admin.category'))
->add('createMissingOptions', null, array('required' => false, 'label' => 'Créer les options manquantes à partir des catégories renseignées dans chaque élément'))
->add('createMissingOptions', null, array('required' => false, 'label' => 'Créer les catégories manquantes à partir des catégories renseignées dans chaque élément'))
->add('optionsToAddToEachElement', 'sonata_type_model', array(
'class'=> 'Biopen\GeoDirectoryBundle\Document\Option',
'required' => false,
'choices_as_values' => true,
'multiple' => true,
'btn_add' => false,
'label' => 'Options à ajouter à chaque élément importé'), array('admin_code' => 'admin.option'))
'label' => 'Catégories à ajouter à chaque élément importé'), array('admin_code' => 'admin.option'))
->end()
;
}
......
......@@ -36,7 +36,7 @@ class ImportAdminController extends Controller
$this->get('biopen.async')->callCommand('app:elements:importSource', [$object->getId()]);
// $result = $this->get('biopen.element_import')->importJson($object);
// $result = $this->get('biopen.element_import')->startImport($object);
$redirectionUrl = $this->admin->generateUrl('create');
$stateUrl = $this->generateUrl('biopen_import_state', ['id' => $object->getId()]);
......
......@@ -482,14 +482,6 @@ class Element
if ($this->getGeo()->getLatitude() != 0 && $this->getGeo()->getLongitude() != 0)
$needed = false;
break;
case ModerationState::PotentialDuplicate:
$potDups = $this->getPotentialDuplicates();
$count = is_array($potDups) ? count($potDups) : $potDups->count();
if ($count) {
$needed = false;
$this->setIsDuplicateNode(false);
}
break;
}
if (!$needed) $this->setModerationState(ModerationState::NotNeeded);
......
......@@ -89,6 +89,14 @@ class Import extends AbstractFile
*/
private $currMessage;
/**
* After importing some Data, if the user hard delete some elements, their ids will be remembered
* so next time we do not import them again
*
* @MongoDB\Field(type="collection")
*/
private $idsToIgnore = [];
public function __construct() {
$this->logs = new \Doctrine\Common\Collections\ArrayCollection();;
......@@ -98,6 +106,11 @@ class Import extends AbstractFile
public function isDynamicImport() { return false; }
public function addIdToIgnore($id)
{
$this->idsToIgnore[] = $id;
}
/**
* Get id
*
......@@ -323,4 +336,26 @@ class Import extends AbstractFile
{
return $this->currMessage;
}
/**
* Set idsToIgnore
*
* @param collection $idsToIgnore
* @return $this
*/
public function setIdsToIgnore($idsToIgnore)
{
$this->idsToIgnore = $idsToIgnore;
return $this;
}
/**
* Get idsToIgnore
*
* @return collection $idsToIgnore
*/
public function getIdsToIgnore()
{
return $this->idsToIgnore;
}
}
......@@ -32,13 +32,7 @@ class ImportDynamic extends Import
*/
private $nextRefresh = null;
/**
* After importing some Data, if the user hard delete some elements, their ids will be remembered
* so next time we do not import them again
*
* @MongoDB\Field(type="collection")
*/
private $idsToIgnore = [];
public function isDynamicImport() { return true; }
......@@ -54,11 +48,6 @@ class ImportDynamic extends Import
}
}
public function addIdToIgnore($id)
{
$this->idsToIgnore[] = $id;
}
/**
* Set refreshFrequencyInDays
*
......@@ -125,26 +114,4 @@ class ImportDynamic extends Import
{
return $this->nextRefresh;
}
/**
* Set idsToIgnore
*
* @param collection $idsToIgnore
* @return $this
*/
public function setIdsToIgnore($idsToIgnore)
{
$this->idsToIgnore = $idsToIgnore;
return $this;
}
/**
* Get idsToIgnore
*
* @return collection $idsToIgnore
*/
public function getIdsToIgnore()
{
return $this->idsToIgnore;
}
}
......@@ -119,7 +119,7 @@
$('#{{ form.vars.id }}').val(JSON.stringify(formBuilder.actions.getData()));
// Changes icons and icones helpers
$('a[type=remove].icon-cancel').removeClass('icon-cancel').addClass('fa fa-trash');
$('a[type=remove].icon-cancel').removeClass('icon-cancel').addClass('fa fa-trash-alt');
$('a[type=copy].icon-copy').attr('title', 'Dupliquer');
$('a[type=edit].icon-pencil').attr('title', 'Editer/Masquer');
......
......@@ -72,7 +72,7 @@ class ElementImportService
// Getting php array of data from CSV
$data = $this->converter->convert($fileName, ',');
if (!$data) return "Cannot open the CSV file";
if (!$data) return "Cannot open the CSV file";
return $this->importData($data, $import);
}
......@@ -343,7 +343,7 @@ class ElementImportService
private function fixsOntology($data)
{
$keysTable = ['lat' => 'latitude', 'long' => 'longitude', 'lon' => 'longitude', 'lng' => 'longitude',
'title' => 'name', 'nom' => 'name', 'categories' => 'taxonomy'];
'title' => 'name', 'nom' => 'name', 'categories' => 'taxonomy', 'address' => 'streetAddress'];
foreach ($data as $key => $row) {
foreach ($keysTable as $search => $replace) {
......@@ -371,7 +371,7 @@ class ElementImportService
private function saveCustomFields($element, $raw_data)
{
$customFields = array_diff(array_keys($raw_data), $this->coreFields);
$customFields = array_diff($customFields, ['lat', 'long', 'lon', 'lng', 'title', 'nom', 'categories']);
$customFields = array_diff($customFields, ['lat', 'long', 'lon', 'lng', 'title', 'nom', 'categories', 'address']);
$customData = [];
foreach ($customFields as $customField) {
$customData[$customField] = $raw_data[$customField];
......
......@@ -83,7 +83,7 @@ class ProjectController extends AbstractSaasController
// Clone the root configuration into the new project
// Due to conflicts between ODM, we get the Configuration froma Json API, and convert it to an object
$configUrl = $this->getParameter('base_protocol') . $this->getParameter('base_url') . $this->generateUrl('biopen_api_configuration');
$configUrl = 'http://' . $this->getParameter('base_url') . $this->generateUrl('biopen_api_configuration');
$rootConfigToCopy = json_decode(file_get_contents($configUrl));
$rootConfigToCopy->appName = $project->getName();
$rootConfigToCopy->appBaseLine = "";
......
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