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

Nouvelles données de démo

parent 5a123bd1
Loading
Loading
Loading
Loading
+2421 −2387

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Changes for module/Oscar/src/Oscar/Controller/ConsoleController.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -183,6 +183,8 @@ class ConsoleController extends AbstractOscarController
        }
    }



    public function shuffleAction(){
        /** @var ShuffleDataService $serviceShuffle */
        $serviceShuffle = $this->getServiceLocator()->get('ShuffleService');
+375 −17
Changes for module/Oscar/src/Oscar/Service/ShuffleDataService.php: 375 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -170,6 +170,374 @@ class ShuffleDataService implements ServiceLocatorAwareInterface, EntityManagerA

    }

    private $villes = [
        'Winterfell' => 'Nord',
        'Dreadfort' => 'Nord',
        'Blancport' => 'Nord',
        'Greywater' => 'Nord',
        'Vivesaigues' => 'Conflans',
        'Viergétang' => 'Conflans',
        'Harrenhal' => 'Conflans',
        'Les Jumeaux' => 'Conflans',
        'Les Eyrié' => 'Le Val d\'Arryn',
        'Pyk' => 'îles de Fer',
        'Wyk' => 'îles de Fer',
        'Harloi' => 'îles de Fer',
        'Salfalaise' => 'îles de Fer',
        'Noirmarées' => 'îles de Fer',
        'Orkmont' => 'îles de Fer',
        'Peyredragon' => 'Terres de la Couronne',
        'Port-Réal' => 'Terres de la Couronne',
        'Castral Roc' => 'Terres de l\'Ouest',
        'Accalmie' => 'Terres de l\'Orage',
        'Hautjardin' => 'Le Bief',
        'Villevieille' => 'Le Bief',
        'Lancehélion' => 'Dorne',
        'Braavos' => 'Essos',
        'Pentos' => 'Essos',
        'Volantis' => 'Essos',
        'Lorath' => 'Essos',
        'Lys' => 'Essos',
        'Myr' => 'Essos',
        'Norvos' => 'Essos',
        'Qohor' => 'Essos',
        'Tyrosh' => 'Essos',
        'Astapor' => 'Baie des serfs',
        'Yunkaï' => 'Baie des serfs',
        'Meereen' => 'Baie des serfs',
    ];

    private $societes = ["ACME", "Omni Carte des produits", "Tyrell Corporation", "COGIP", "Dinoco", "Cartel", "Aperture", "Alchemax", "BNL", "Fondation", "Winch", "Lex", "Stark", "US Robot", "Tomato", "Umbrella", "Black Mesa", "Wayne Industries", "World", "Queen", "Oceanic Airline", "Shaara", "Wolfram", "Har", "SHIELD", "Oscorp", "Soyent", "Degasi", "Perk", "Cyberdyne", "Tripod", "Quarantine", "Butor", "Roadtrip", "Microhard", "Trichar", "Monopoly", "Diurn", "Chemical Industries", "Fondation Phoenix", "Pixelart", "Centrino", "Percum Quantum", "Power 3000", "Morley Tabacco", "Pizza Planet", "Aaltra", "Agence Security", "Altra Automotive", "Aquilair", "Avalon", "Banque Cordell", "Beaumont-Liégard", "Dapper Dan", "Mac Gir", "France Hebdo", "Gaitoutou", "Geugène Industrie", "GGT", "Grant Texas Industries", "Planète Assistance", "Protovision", "R2I", "Rekall", "Red Apple", "Rocade", "Blue Star Airlines", "Los poyos Hermanos", "HAL Labs", "Lacuna Inc", "Madone", "Victoria", "Weyland-Yutani", "Nostromo", "Pyramid Transnational", "Cadre Cola", "6000 SUX", "Jabot cosmétiques", "Fenmore", "Mr. Cluck's", "Dharma Initiative", "Apollo", "Fondation Hanso", "Drive Shaft", "Tech Con", "TCNN", "EPRAD", "Capsule Corp", "Alabama man", "Cheesy Poofs", "Harbucks", "Cherokee Hair", "Beta Romero", "Lard Lad", "Duff", "Slurm", "Fudd", "Kwik E Mart", "Plomox", "Citronault", "Adadas", "Grossimil", "Grogle", "eXsorbeo", "Transfenders", "Bonewerkz", "SoulStorm", "Magog Motors", "Chokovat", "Khonsu", "Ubik", "Rosen Corporation", "Grunnings", "Nimbus", "Veidt Enterprises"];

    private $disciplines = [
        "Biologie" => [
            "Agronomie",
            "Zootechnie",
            "Anatomie",
            "Anthropologie",
            "Anthropométrie",
            "Astrobiologie",
            "Bio-informatique",
            "Botanique",
            "Biochimie",
            "Ecologie",
            "Epidémiologie"
        ],

        "Santé" => [
            "Anatomie",
            "Cardiologie",
            "Oncologie",
            "Patologie",
            "Pharmacologie",
            "Physiologie",
            "Toxicologie",
            "Neurologie"
        ],

        "Chimie" => [
            "Biochimie",
            "Électrochimie",
            "Géochimie",
            "Pétrochimie",
            "Spectroscopie",
            "Thermochimie",
        ],

        "Physique" => [
            "Astronomie",
            "Cryogénie",
            "Électronique",
            "Électromagnétisme",
            "Mécanique",
            "Optique",
            "Optronique",
            "Thermodynamique",
        ],

        "Géosciences" => [
            "Géographie",
            "Géologie",
            "Géophysique",
            "Granulométrie",
            "Minéralogie",
            "Nanogéosciences",
            "Pétrographie",
            "Spéléologie",
            "Volcanologie",
        ],

        "Anthropologie" => [
            "Archéologie",
            "Ethnologie",
        ],

        "Criminologie" => [
            "Biocriminologie",
            "Psychocriminologie",
            "Pénologie",
            "Polémologie",
            "Victimologie",
        ],

        "Économie" => [
            "Macroéconomie",
            "Microéconomie",
            "Économétrie",
            "financière",
            "environnement",
            "urbaine",
        ],

        "Géographie" => [
            "Démographie",
            "Géoarchéologie",
            "Géomatique",
            "Géopolitique",
        ],

        "Histoire" => [
            "Culturelle",
            "Art",
            "Muséologie",
            "Philologie",
        ],

        "Linguistique" => [
            "Dialectologie",
            "Lexicographie",
            "Lexicologie",
            "Sociolinguistique",
            "Phonétique",
            "Phonologie",
        ],

        "Musicologie" => [
            "Organologie",
            "Ethnomusicologie",
        ],

        "Psychologie" => [
            "Neuropsychologie",
            "Psychanalyse",
            "Psychobiologie",
            "Psychogénétique",
            "Psycholinguistique",
            "Psychométrie",
            "Psychopathologie",
            "Psychopédagogie",
            "Psychophonie",
            "Psychophysiologie",
            "Psychosociologie",
        ],

        "Sciences de l'éducation" => [
            "Didactique",
            "Pédégogie",
        ],
    ];

    function getCode( $str ){

        $split = explode(' ', preg_replace("/[^A-Za-z0-9 ]/", '', $str));
        $out = "";
        foreach ($split as $word) {
            $out .= substr(ucfirst($word), 0, 1);
        }
        return $out;
    }

    private function getSocieteData()
    {
        static $societes, $indexSocietes;
        if( $societes === null ){
            shuffle($this->societes);
            $societes = [];
            foreach ($this->societes as $ste ) {
                $randomPlace = $this->randomCity();
                $fullname =$ste;
                $code = "";
                $societes[] = [
                    'fullname' => $fullname,
                    'shortname' => $code,
                    "city" => $randomPlace['city'],
                    "country" => $randomPlace['country']
                ];

            }
        }

        if( $indexSocietes == null || $indexSocietes >= count($societes) ){
            $indexSocietes = 0;
        }
        return $societes[$indexSocietes++];

    }

    private function getAssociation()
    {
        static $associations, $associationsIndex;
        if( $associations === null ){
            shuffle($this->societes);
            $associations = [];
            foreach ($this->societes as $ste ) {
                $randomPlace = $this->randomCity();
                $fullname = "Association " . $ste;
                $code = $this->getCode($fullname);
                $associations[] = [
                    'fullname' => $fullname,
                    'shortname' => $code,
                    "city" => $randomPlace['city'],
                    "country" => $randomPlace['country']
                ];

            }
        }
        if( $associationsIndex == null || $associationsIndex >= count($associations) ){
            $associationsIndex = 0;
        }
        return $associations[$associationsIndex++];
    }

    private function getCollectivite()
    {
        static $collectivites, $collectivitesIndex;
        if( $collectivites === null ){
            $collectivites = [];
            foreach ($this->villes as $city => $country) {

                $fullname = "Collectivité de " . $city;
                $code = $this->getCode($fullname);
                $collectivites[] = [
                    'fullname' => $fullname,
                    'shortname' => $code,
                    "city" => $city,
                    "country" => $country
                ];

            }
        }
        if( $collectivitesIndex == null || $collectivitesIndex >= count($collectivites) ){
            $collectivitesIndex = 0;
        }
        return $collectivites[$collectivitesIndex++];
    }

    private function getEtablissement()
    {
        static $etablissements, $etablissementsIndex;
        if( $etablissements === null ){
            $etablissements = [];
            foreach ($this->disciplines as $discipline => $sousDisciplines) {
                $randomPlace = $this->randomCity();
                $fullname = "Etablisement d'étude en " . $discipline;
                $code = $this->getCode($fullname);
                $etablissements[] = [
                    'fullname' => $fullname,
                    'shortname' => $code,
                    "city" => $randomPlace['city'],
                    "country" => $randomPlace['country']
                ];

            }
        }
        if( $etablissementsIndex == null || $etablissementsIndex >= count($etablissements) ){
            $etablissementsIndex = 0;
        }
        return $etablissements[$etablissementsIndex++];
    }

    private function getLaboratoireData()
    {
        static $laboratoires, $indexLaboratoires;
        if( $laboratoires === null ){
            $laboratoires = [];

            foreach ($this->disciplines as $discipline => $sousDisciplines ) {
                foreach( $sousDisciplines as $sousDiscipline ){
                    $randomPlace = $this->randomCity();
                    $fullname = "Laboratoire de recherche en $sousDiscipline de " . $randomPlace['city'];
                    $code = $this->getCode($fullname);
                    $laboratoires[] = [
                        'fullname' => $fullname,
                        'shortname' => $code,
                        "city" => $randomPlace['city'],
                        "country" => $randomPlace['country']
                    ];
                }
            }
        }

        if( $indexLaboratoires == null || $indexLaboratoires >= count($laboratoires) ){
            $indexLaboratoires = 0;
        }
        return $laboratoires[$indexLaboratoires++];

    }

    private function getComposanteData(){
        static $composantes, $indexComposantes;
        if( $composantes === null ){
            $composantes = [];

            foreach ($this->disciplines as $discipline => $sousDisciplines ) {
                $fullname = "UFR de $discipline";
                $code = $this->getCode($fullname);
                $randomPlace = $this->randomCity();
                $composantes[] = [
                    'fullname' => $fullname,
                    'shortname' => $code,
                    "city" => $randomPlace['city'],
                    "country" => $randomPlace['country']
                ];
            }

            foreach ($this->villes as $ville => $pays ) {
                $fullname = "IUT de $ville ($pays)";
                $code = $this->getCode($fullname);
                $composantes[] = [
                    'fullname' => $fullname,
                    'shortname' => $code,
                    "city" => $ville,
                    "country" => $pays
                ];
            }
        }
        if( $indexComposantes == null || $indexComposantes >= count($composantes) ){
            $indexComposantes = 0;
        }

        return $composantes[$indexComposantes++];
    }

    public function getRandomOrganization($type){
       switch( $type ) {
           case "1":
               return $this->getComposanteData();
               break;
           case "2":
               return $this->getLaboratoireData();
               break;
           case "3":
               return $this->getSocieteData();
               break;
           case "4":
               return $this->getAssociation();
               break;
           case "6":
               return $this->getCollectivite();
               break;

           case "7":
               return $this->getEtablissement();
               break;

           default :
               return $this->getSocieteData();
               break;
       }
    }

    public function shuffleOrganizations() {
        $organizations = $this->getEntityManager()->getRepository(Organization::class)->findAll();
        $steIndex = 0;
@@ -224,18 +592,12 @@ class ShuffleDataService implements ServiceLocatorAwareInterface, EntityManagerA
        /****/
        /** @var Organization $organization */
        foreach ($organizations as $organization ){
            if( $organization->getType() == 3 ){
            echo " - " . $organization->getType() . "\n";
                if ($steIndex >= count($ste) ){
                    $steIndex = 0;
                }
                $organization->setFullName($ste[$steIndex])
                    ->setSiret('MEH');
                $steIndex++;
            }
            $data = $this->getRandomOrganization($organization->getType());

            $randomPlace = $this->randomCity();
            $organization->setPhone(null)
            $organization
                ->setFullName($data['fullname'])
                ->setShortName($data['shortname'])
                ->setPhone(null)
                ->setEmail(null)
                ->setPhone(null)
                ->setBp(null)
@@ -247,13 +609,9 @@ class ShuffleDataService implements ServiceLocatorAwareInterface, EntityManagerA
                ->setBp(null)
                ->setZipCode('')

                ->setCity($randomPlace['city'])
                ->setCountry($randomPlace['country'])
                ->setCity($data['city'])
                ->setCountry($data['country']);

                /*->setCode($data['code'])
                ->setFullName($data['fullname'])
                ->setShortName($data['shortname'])*/;
//            $count[$type]++;
        }
        $this->getEntityManager()->flush();
    }