Commit 4fd89d0d authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Mise à jour du système de positionnement de colonnes

parent 67a73622
Loading
Loading
Loading
Loading
+14
Changes for admin/actions/update-ddl.php: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

$dirname    = $oa->getOseDir() . 'data/ddl';
$colPosFile = $oa->getOseDir() . 'data/ddl_columns_pos.php';

$filters = [
    'table'              => ['excludes' => 'UNICAEN_%'],
@@ -20,5 +21,18 @@ $filters = [

$c->begin('Génération du fichier de DDL à partir de la base de données');
$ddl = $oa->getBdd()->getDdl($filters);


/* Traitement des positionnement de colonnes */
if (file_exists($colPosFile)) {
    $positions = require_once $colPosFile;
} else {
    $positions = [];
}
$positions = $ddl->applyColumnPositions($positions);
$ddl->writeArray($colPosFile, $positions);
$c->end('Positionnement de colonnes à jour');


$ddl->saveToDir($dirname);
$c->end('Définition Fichier de la base de données mise à jour');
 No newline at end of file
+44 −1
Changes for admin/src/BddAdmin/Ddl/Ddl.php: 44 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -232,7 +232,50 @@ class Ddl implements \Iterator, \ArrayAccess



    protected function writeArray(string $filename, array $data)
    /**
     * @param array $positions
     *
     * @return array
     */
    public function applyColumnPositions(array $positions): array
    {
        $tables = $this->get(Ddl::TABLE);
        foreach ($tables as $tableName => $table) {
            $cols = [];
            foreach ($positions[$tableName] as $idc => $col) {
                if (!array_key_exists($col, $table['columns'])) {
                    unset($positions[$tableName][$idc]);
                }
            }
            foreach ($table['columns'] as $column) {
                $colname = $column['name'];
                if (!isset($positions[$tableName]) || !in_array($colname, $positions[$tableName])) {
                    $cols[$colname] = $column['position'];
                }
            }
            asort($cols);
            $cols = array_keys($cols);

            if (!isset($positions[$tableName])) {
                $positions[$tableName] = [];
            }
            $cols = array_merge($positions[$tableName], $cols);

            foreach ($cols as $pos => $col) {
                if (isset($this->data[Ddl::TABLE][$tableName]['columns'][$col])) {
                    $this->data[Ddl::TABLE][$tableName]['columns'][$col]['position'] = $pos + 1;
                }
            }

            $positions[$tableName] = $cols;
        }

        return $positions;
    }



    public function writeArray(string $filename, array $data)
    {
        $ddlString = "<?php\n\n//@" . "formatter:off\n\nreturn " . $this->arrayExport($data) . ";\n\n//@" . "formatter:on\n";

+2 −2
Changes for data/ddl/table/ADRESSE_NUMERO_COMPL.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 1,
            'position'    => 2,
            'commentaire' => NULL,
        ],
        'ID'      => [
@@ -30,7 +30,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 2,
            'position'    => 1,
            'commentaire' => NULL,
        ],
        'LIBELLE' => [
+11 −11
Changes for data/ddl/table/AFFECTATION.php: 11 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 7,
            'position'    => 8,
            'commentaire' => NULL,
        ],
        'HISTO_CREATION'        => [
@@ -30,7 +30,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => 'SYSDATE',
            'position'    => 6,
            'position'    => 7,
            'commentaire' => NULL,
        ],
        'HISTO_DESTRUCTEUR_ID'  => [
@@ -42,7 +42,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 11,
            'position'    => 12,
            'commentaire' => NULL,
        ],
        'HISTO_DESTRUCTION'     => [
@@ -54,7 +54,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 10,
            'position'    => 11,
            'commentaire' => NULL,
        ],
        'HISTO_MODIFICATEUR_ID' => [
@@ -66,7 +66,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 9,
            'position'    => 10,
            'commentaire' => NULL,
        ],
        'HISTO_MODIFICATION'    => [
@@ -78,7 +78,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => 'SYSDATE',
            'position'    => 8,
            'position'    => 9,
            'commentaire' => NULL,
        ],
        'ID'                    => [
@@ -102,7 +102,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 2,
            'position'    => 3,
            'commentaire' => NULL,
        ],
        'SOURCE_CODE'           => [
@@ -114,7 +114,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 5,
            'position'    => 6,
            'commentaire' => NULL,
        ],
        'SOURCE_ID'             => [
@@ -126,7 +126,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 4,
            'position'    => 5,
            'commentaire' => NULL,
        ],
        'STRUCTURE_ID'          => [
@@ -138,7 +138,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 3,
            'position'    => 4,
            'commentaire' => NULL,
        ],
        'UTILISATEUR_ID'        => [
@@ -150,7 +150,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 12,
            'position'    => 2,
            'commentaire' => NULL,
        ],
    ],
+9 −9
Changes for data/ddl/table/AFFECTATION_RECHERCHE.php: 9 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 7,
            'position'    => 8,
            'commentaire' => NULL,
        ],
        'HISTO_CREATION'        => [
@@ -30,7 +30,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => 'SYSDATE',
            'position'    => 6,
            'position'    => 7,
            'commentaire' => NULL,
        ],
        'HISTO_DESTRUCTEUR_ID'  => [
@@ -42,7 +42,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 11,
            'position'    => 12,
            'commentaire' => NULL,
        ],
        'HISTO_DESTRUCTION'     => [
@@ -54,7 +54,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 10,
            'position'    => 11,
            'commentaire' => NULL,
        ],
        'HISTO_MODIFICATEUR_ID' => [
@@ -66,7 +66,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 9,
            'position'    => 10,
            'commentaire' => NULL,
        ],
        'HISTO_MODIFICATION'    => [
@@ -78,7 +78,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => 'SYSDATE',
            'position'    => 8,
            'position'    => 9,
            'commentaire' => NULL,
        ],
        'ID'                    => [
@@ -114,7 +114,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 12,
            'position'    => 4,
            'commentaire' => NULL,
        ],
        'SOURCE_CODE'           => [
@@ -126,7 +126,7 @@ return [
            'precision'   => NULL,
            'nullable'    => TRUE,
            'default'     => NULL,
            'position'    => 5,
            'position'    => 6,
            'commentaire' => NULL,
        ],
        'SOURCE_ID'             => [
@@ -138,7 +138,7 @@ return [
            'precision'   => NULL,
            'nullable'    => FALSE,
            'default'     => NULL,
            'position'    => 4,
            'position'    => 5,
            'commentaire' => NULL,
        ],
        'STRUCTURE_ID'          => [
Loading