Commit 8b1a5b41 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Possibilité d'ordonner les imports/synchros.

parent 01d60ebd
Loading
Loading
Loading
Loading
Loading
+2 −0
Changes for CHANGELOG.md: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ Changelog

4.0.2
-----
- Possibilité d'ordonner les imports/synchros.
- Possibilité d'afficher les logs d'import/synchro en live (avec unicaen/livelog).
- Possibilité de sélectionner les imports/synchros à lancer.
- Ajout d'un témoin indiquant si un problème a été rencontré pendant l'exécution.
- [FIX] ApiService : prise en compte des paramètres de config 'timeout' et 'connect_timeout'.
+8 −0
Changes for src/UnicaenDbImport/Config/Config.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -390,6 +390,10 @@ class Config
     */
    public function setImports(array $imports): self
    {
        usort($imports, function(ImportInterface $a, ImportInterface $b) {
            return $a->getOrder() <=> $b->getOrder();
        });

        $this->imports = $imports;

        return $this;
@@ -424,6 +428,10 @@ class Config
     */
    public function setSynchros(array $synchros): self
    {
        usort($synchros, function(SynchroInterface $a, SynchroInterface $b) {
            return $a->getOrder() <=> $b->getOrder();
        });

        $this->synchros = $synchros;

        return $this;
+15 −2
Changes for src/UnicaenDbImport/Domain/Import.php: 15 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -42,13 +42,18 @@ class Import implements ImportInterface
     */
    protected function validateConfig()
    {
        (new AssertionChain($this->config->get($key = 'source'), "Une instance de " . SourceInterface::class . " est requise pour la clé suivante: $key"))
        (new AssertionChain($this->config->get($key = 'source'), "Une instance de " . SourceInterface::class . " est requise pour la clé suivante: $key (import {$this})"))
            ->notEmpty()
            ->isInstanceOf(SourceInterface::class);

        (new AssertionChain($this->config->get($key = 'destination'), "Une instance de " . DestinationInterface::class . " est requise pour la clé suivante: $key"))
        (new AssertionChain($this->config->get($key = 'destination'), "Une instance de " . DestinationInterface::class . " est requise pour la clé suivante: $key (import {$this})"))
            ->notEmpty()
            ->isInstanceOf(DestinationInterface::class);

        if ($this->config->offsetExists($key = 'order')) {
            (new AssertionChain($this->config->get('order'), "Un entier est requis pour la clé suivante: $key (import {$this})"))
                ->integer();
        }
    }

    /**
@@ -86,4 +91,12 @@ class Import implements ImportInterface
    {
        return $this->config->get('destination');
    }

    /**
     * @return null|int
     */
    public function getOrder(): ?int
    {
        return $this->config->get('order');
    }
}
 No newline at end of file
+7 −0
Changes for src/UnicaenDbImport/Domain/ImportInterface.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,4 +24,11 @@ interface ImportInterface
     * @return DestinationInterface
     */
    public function getDestination(): DestinationInterface;

    /**
     * Retourne le numéro d'ordre éventuel de cet import.
     *
     * @return null|int
     */
    public function getOrder(): ?int;
}
 No newline at end of file
+17 −4
Changes for src/UnicaenDbImport/Domain/Synchro.php: 17 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -49,20 +49,25 @@ class Synchro implements SynchroInterface
     */
    protected function validateConfig()
    {
        (new AssertionChain($this->config->get($key = 'source'), "Une instance de " . SourceInterface::class . " est requise pour la clé suivante: $key"))
        (new AssertionChain($this->config->get($key = 'source'), "Une instance de " . SourceInterface::class . " est requise pour la clé suivante: $key (synchro {$this})"))
            ->notEmpty()
            ->isInstanceOf(SourceInterface::class);

        (new AssertionChain($this->config->get($key = 'destination'), "Une instance de " . DestinationInterface::class . " est requise pour la clé suivante: $key"))
        (new AssertionChain($this->config->get($key = 'destination'), "Une instance de " . DestinationInterface::class . " est requise pour la clé suivante: $key (synchro {$this})"))
            ->notEmpty()
            ->isInstanceOf(DestinationInterface::class);

        if ($this->config->offsetExists($key = 'intermediate_table')) {
            $intermediateTable = $this->config->get($key = 'intermediate_table');
            (new AssertionChain($intermediateTable, "Une string non vide est requise pour la clé facultative suivante: $key"))
            $intermediateTable = $this->config->get($key);
            (new AssertionChain($intermediateTable, "Une string non vide est requise pour la clé facultative suivante: $key (synchro {$this})"))
                ->notEmpty()
                ->string();
        }

        if ($this->config->offsetExists($key = 'order')) {
            (new AssertionChain($this->config->get('order'), "Un entier est requis pour la clé suivante: $key (synchro {$this})"))
                ->integer();
        }
    }

    /**
@@ -101,6 +106,14 @@ class Synchro implements SynchroInterface
        return $this->config->get('destination');
    }

    /**
     * @return null|int
     */
    public function getOrder(): ?int
    {
        return $this->config->get('order');
    }

    /**
     * @inheritDoc
     */
Loading