Commit a29c5beb authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : Retour des commandes de chargement des données

parent 63b537c6
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class OscarActivityImportJsonCommand extends OscarCommandAbstract
        return $realpath;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    protected function execute(InputInterface $input, OutputInterface $output) :int
    {
        $this->addOutputStyle($output);

@@ -158,7 +158,7 @@ class OscarActivityImportJsonCommand extends OscarCommandAbstract
            $file = $this->getReadablePath($input->getOption('fichier'));
        } catch (\Exception $e) {
            $io->error("Impossible de lire le fichier source : " . $e->getMessage());
            return;
            return self::FAILURE;
        }

        $options = [
@@ -223,6 +223,8 @@ class OscarActivityImportJsonCommand extends OscarCommandAbstract

        $output = new ConnectorRepportToPlainText();
        $output->format($repport);

        return self::SUCCESS;
        /****/
    }
}
 No newline at end of file
+12 −6
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ class OscarOrganizationsSyncJsonCommand extends OscarCommandAbstract
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    protected function execute(InputInterface $input, OutputInterface $output) :int
    {
        $this->addOutputStyle($output);

@@ -68,15 +68,18 @@ class OscarOrganizationsSyncJsonCommand extends OscarCommandAbstract
        try {
            $fichier = $input->getArgument('fichier');

            if (!$fichier)
                die("Vous devez spécifier le chemin complet vers le fichier JSON");
            if (!$fichier) {
                $io->error("Vous devez spécifier le chemin complet vers le fichier JSON");
                return self::FAILURE;
            }

            echo "Synchronisation depuis le fichier $fichier\n";
            $io->info("Synchronisation depuis le fichier $fichier");
            $sourceJSONFile = new GetJsonDataFromFileStrategy($fichier);
            try {
                $datas = $sourceJSONFile->getAll();
            } catch (\Exception $e) {
                die("ERR : Impossible de charger les ogranizations depuis $fichier : " . $e->getMessage());
                $io->error($e->getMessage());
                return self::FAILURE;
            }

            $connector = new ConnectorOrganizationJSON($datas,
@@ -88,7 +91,8 @@ class OscarOrganizationsSyncJsonCommand extends OscarCommandAbstract

            $connectorFormatter->format($repport);
        } catch (\Exception $e) {
            die("ERR : " . $e->getMessage());
            $io->error($e->getMessage());
            return self::FAILURE;
        }

        $io->section("Reconstruction de l'index de recherche : ");
@@ -102,9 +106,11 @@ class OscarOrganizationsSyncJsonCommand extends OscarCommandAbstract
                $io->success(sprintf('Index de recherche mis à jour avec %s organisations indexées', count($organizations)));
            } catch ( \Exception $e ){
                $io->error($e->getMessage());
                return self::FAILURE;
            }
        } else {
            $io->warning("Pas de reconstruction d'index");
        }
        return self::SUCCESS;
    }
}
 No newline at end of file
+8 −4
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class OscarPersonsSyncJsonCommand extends OscarCommandAbstract
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    protected function execute(InputInterface $input, OutputInterface $output) :int
    {
        $this->addOutputStyle($output);

@@ -77,7 +77,8 @@ class OscarPersonsSyncJsonCommand extends OscarCommandAbstract
            try {
                $datas = $sourceJSONFile->getAll();
            } catch (\Exception $e) {
                die("ERR : Impossible de charger les ogranizations depuis $fichier : " . $e->getMessage());
                $io->error("Impossible de charger les ogranizations depuis $fichier : " . $e->getMessage());
                return self::FAILURE;
            }

            $connector = new ConnectorPersonJSON($datas, $entityManager, "json");
@@ -86,7 +87,8 @@ class OscarPersonsSyncJsonCommand extends OscarCommandAbstract

            $connectorFormatter->format($repport);
        } catch (\Exception $e) {
            die("ERR : " . $e->getMessage());
            $io->error($e->getMessage());
            return self::FAILURE;
        }

        $io->section("Reconstruction de l'index de recherche : ");
@@ -100,9 +102,11 @@ class OscarPersonsSyncJsonCommand extends OscarCommandAbstract
                $io->success(sprintf('Index de recherche mis à jour avec %s organisations indexées', count($organizations)));
            } catch ( \Exception $e ){
                $io->error($e->getMessage());
                return self::FAILURE;
            }
        } else {
            $io->warning("Pas de reconstruction d'index");
            $io->info("Pas de reconstruction d'index");
        }
        return self::SUCCESS;
    }
}
 No newline at end of file