diff --git a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.info.yml b/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.info.yml deleted file mode 100644 index 2193927ca..000000000 --- a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.info.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: 'HELfi KYMP Migration' -type: module -description: 'Migrates project taxonomies' -core_version_requirement: ^9 || ^10 -package: HELfi diff --git a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.install b/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.install deleted file mode 100644 index 6c973f629..000000000 --- a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.install +++ /dev/null @@ -1,18 +0,0 @@ -get('helfi_kymp_migrations.parent_district_migration_complete')) { - helfi_kymp_migrations__run_taxonomy_migration(); - } -} diff --git a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.module b/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.module deleted file mode 100644 index 8227e862b..000000000 --- a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.module +++ /dev/null @@ -1,36 +0,0 @@ -set('helfi_kymp_migrations.parent_district_migration_complete', TRUE); - } -} - -/** - * Run taxonomy migrations. - */ -function helfi_kymp_migrations__run_taxonomy_migration() : void { - $logger = \Drupal::service('logger.channel.default'); - $migration = \Drupal::service( - 'helfi_kymp_migrations.taxonomy_migration_service' - ); - - try { - $migration->migrate(); - } - catch (\Exception $e) { - $logger->error('HELfi KYMP Migration taxonomy migration failed with error: ' . $e->getMessage()); - } -} diff --git a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.services.yml b/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.services.yml deleted file mode 100644 index 0f77c0439..000000000 --- a/public/modules/custom/helfi_kymp_migrations/helfi_kymp_migrations.services.yml +++ /dev/null @@ -1,4 +0,0 @@ -services: - helfi_kymp_migrations.taxonomy_migration_service: - class: Drupal\helfi_kymp_migrations\TaxonomyMigrationService - arguments: [ '@file_system', '@module_handler', '@entity_type.manager' ] diff --git a/public/modules/custom/helfi_kymp_migrations/src/TaxonomyMigrationService.php b/public/modules/custom/helfi_kymp_migrations/src/TaxonomyMigrationService.php deleted file mode 100644 index 90ec9b809..000000000 --- a/public/modules/custom/helfi_kymp_migrations/src/TaxonomyMigrationService.php +++ /dev/null @@ -1,148 +0,0 @@ -projectFilePath = $this->fileSystem->realpath( - $this->moduleHandler->getModule('helfi_kymp_migrations')->getPath() - ) . '/src/csv/taxonomies.csv'; - } - - /** - * Run migrations. - */ - public function migrate(): array { - if (!file_exists($this->projectFilePath)) { - return ['Project file is missing!']; - } - - $this->file = fopen($this->projectFilePath, 'r'); - - $errors = $this->migrateTaxonomies(); - - fclose($this->file); - - if ($errors) { - throw new \Exception(implode(',', $errors)); - } - return $errors; - } - - /** - * Loop though csv file. - */ - protected function rows(): iterable { - while (!feof($this->file)) { - $row = fgetcsv($this->file, 4096, ';'); - yield $row; - } - } - - /** - * Migrate project taxonomies. - */ - private function migrateTaxonomies(): array { - $errors = []; - $headers = []; - $i = 0; - $set = []; - - foreach ($this->rows() as $key => $row) { - if (empty($headers)) { - $headers = $row; - continue; - } - - if (empty($row)) { - continue; - } - - if (count($headers) != count($row)) { - $errors[] = $key; - continue; - } - - if ($i < 2) { - $set[$row[3]] = $row; - $i++; - continue; - } - - if ($i == 2) { - $taxonomy_data = [ - 'vid' => $row[0], - 'name' => trim($row[1]), - 'langcode' => 'en', - ]; - - if ($row[0] == 'project_sub_district') { - $taxonomy_data['field_parent_district'] = NULL; - } - - $existing_term = $this->entityTypeManager->getStorage('taxonomy_term') - ->loadByProperties(['name' => trim($row[1]), 'vid' => $row[0]]); - - if (!$existing_term) { - $term = Term::create($taxonomy_data); - $term->save(); - $translation = $term->hasTranslation('fi') ? $term->getTranslation('fi') : $term->addTranslation('fi'); - $translation->set('name', $set['fi'][1]) - ->save(); - - $translation = $term->hasTranslation('sv') ? $term->getTranslation('sv') : $term->addTranslation('sv'); - $translation->set('name', $set['sv'][1]) - ->save(); - - if ( - $term->bundle() == 'project_sub_district' && - $term->hasField('field_parent_district') - ) { - $parent = $this->entityTypeManager->getStorage('taxonomy_term')->loadByProperties(['name' => $row[4]]); - if ($parent) { - $term->field_parent_district->entity = reset($parent); - $term->save(); - } - } - } - - $set = []; - $i = 0; - } - } - return $errors; - } - -} diff --git a/public/modules/custom/helfi_kymp_migrations/src/csv/taxonomies.csv b/public/modules/custom/helfi_kymp_migrations/src/csv/taxonomies.csv deleted file mode 100644 index 15390fa29..000000000 --- a/public/modules/custom/helfi_kymp_migrations/src/csv/taxonomies.csv +++ /dev/null @@ -1,265 +0,0 @@ -taxonomy;value;parent;langcode;parent_district -project_district;Koko Helsinki;;fi; -project_district;Hela Helsingfors;Koko Helsinki;sv; -project_district;All Helsinki;Koko Helsinki;en; -project_district;Alppiharju;;fi; -project_district;Åshöjden;Alppiharju;sv; -project_district;Alppiharju;Alppiharju;en; -project_district;Eira;;fi; -project_district;Eira;Eira;sv; -project_district;Eira;Eira;en; -project_district;Hermanni;;fi; -project_district;Hermanstad;Hermanni;sv; -project_district;Hermanni;Hermanni;en; -project_district;Herttoniemi;;fi; -project_district;Hertonäs;Herttoniemi;sv; -project_district;Herttoniemi;Herttoniemi;en; -project_district;Kaartinkaupunki;;fi; -project_district;Gardesstaden;Kaartinkaupunki;sv; -project_district;Kaartinkaupunki;Kaartinkaupunki;en; -project_district;Kamppi;;fi; -project_district;Kampen;Kamppi;sv; -project_district;Kamppi;Kamppi;en; -project_district;Kluuvi;;fi; -project_district;Gloet;Kluuvi;sv; -project_district;Kluuvi;Kluuvi;en; -project_district;Kalasatama;;fi; -project_district;Fiskehamnen;Kalasatama;sv; -project_district;Kalasatama;Kalasatama;en; -project_district;Koivusaari;;fi; -project_district;Björkholmen;Koivusaari;sv; -project_district;Koivusaari;Koivusaari;en; -project_district;Kruununhaka;;fi; -project_district;Kronohagen;Kruununhaka;sv; -project_district;Kruununhaka;Kruununhaka;en; -project_district;Käpylä;;fi; -project_district;Kottby;Käpylä;sv; -project_district;Käpylä;Käpylä;en; -project_district;Lauttasaari;;fi; -project_district;Drumsö;Lauttasaari;sv; -project_district;Lauttasaari;Lauttasaari;en; -project_district;Malmi;;fi; -project_district;Malm;Malmi;sv; -project_district;Malmi;Malmi;en; -project_district;Munkkiniemi;;fi; -project_district;Munksnäs;Munkkiniemi;sv; -project_district;Munkkiniemi;Munkkiniemi;en; -project_district;Oulunkylä;;fi; -project_district;Åggelby;Oulunkylä;sv; -project_district;Oulunkylä;Oulunkylä;en; -project_district;Pitäjänmäki;;fi; -project_district;Sockenbacka;Pitäjänmäki;sv; -project_district;Pitäjänmäki;Pitäjänmäki;en; -project_district;Ruskeasuo;;fi; -project_district;Brunakärr;Ruskeasuo;sv; -project_district;Ruskeasuo;Ruskeasuo;en; -project_district;Suomenlinna;;fi; -project_district;Sveaborg;Suomenlinna;sv; -project_district;Suomenlinna;Suomenlinna;en; -project_district;Sörnäinen;;fi; -project_district;Sörnäs;Sörnäinen;sv; -project_district;Sörnäinen;Sörnäinen;en; -project_district;Tammisalo;;fi; -project_district;Tammelund;Tammisalo;sv; -project_district;Tammisalo;Tammisalo;en; -project_district;Tuomarinkylä;;fi; -project_district;Domarby;Tuomarinkylä;sv; -project_district;Tuomarinkylä;Tuomarinkylä;en; -project_district;Ultuna;;fi; -project_district;Ultuna;Ultuna;sv; -project_district;Ultuna;Ultuna;en; -project_district;Vartiokylä;;fi; -project_district;Botby;Vartiokylä;sv; -project_district;Vartiokylä;Vartiokylä;en; -project_district;Villinki;;fi; -project_district;Villinge;Villinki;sv; -project_district;Villinki;Villinki;en; -project_district;Östersundom;;fi; -project_district;Östersundom;Östersundom;sv; -project_district;Östersundom;Östersundom;en; -project_district;Hakaniemi;;fi; -project_district;Hagnäs;Hakaniemi;sv; -project_district;Hakaniemi;Hakaniemi;en; -project_district;Hernesaari ja Telakkaranta;;fi; -project_district;Ärtholmen och Dockstranden;Hernesaari ja Telakkaranta;sv; -project_district;Hernesaari ja Telakkaranta;Hernesaari ja Telakkaranta;en; -project_district;Jätkäsaari;;fi; -project_district;Busholmen;Jätkäsaari;sv; -project_district;Jätkäsaari;Jätkäsaari;en; -project_district;Kaivopuisto;;fi; -project_district;Brunssparken;Kaivopuisto;sv; -project_district;Kaivopuisto;Kaivopuisto;en; -project_district;Karhusaari;;fi; -project_district;Björnsö;Karhusaari;sv; -project_district;Karhusaari;Karhusaari;en; -project_district;Konala;;fi; -project_district;Kånala;Konala;sv; -project_district;Konala;Konala;en; -project_district;Kannelmäki;;fi; -project_district;Gamlas;Kannelmäki;sv; -project_district;Kannelmäki;Kannelmäki;en; -project_district;Kruunuvuorenranta;;fi; -project_district;Kronbergsstranden;Kruunuvuorenranta;sv; -project_district;Kruunuvuorenranta;Kruunuvuorenranta;en; -project_district;Kulosaari;;fi; -project_district;Brändö;Kulosaari;sv; -project_district;Kulosaari;Kulosaari;en; -project_district;Laajasalo;;fi; -project_district;Degerö;Laajasalo;sv; -project_district;Laajasalo;Laajasalo;en; -project_district;Länsisatama;;fi; -project_district;Västra hamnen;Länsisatama;sv; -project_district;Länsisatama;Länsisatama;en; -project_district;Meilahti;;fi; -project_district;Mejlans;Meilahti;sv; -project_district;Meilahti;Meilahti;en; -project_district;Mustikkamaa-Korkeasaari;;fi; -project_district;Blåbärslandet-Högholmen;Mustikkamaa-Korkeasaari;sv; -project_district;Mustikkamaa-Korkeasaari;Mustikkamaa-Korkeasaari;en; -project_district;Pakila;;fi; -project_district;Baggböle;Pakila;sv; -project_district;Pakila;Pakila;en; -project_district;Pukinmäki;;fi; -project_district;Bocksbacka;Pukinmäki;sv; -project_district;Pukinmäki;Pukinmäki;en; -project_district;Salmenkallio;;fi; -project_district;Sundberg;Salmenkallio;sv; -project_district;Salmenkallio;Salmenkallio;en; -project_district;Suurmetsä;;fi; -project_district;Storskog;Suurmetsä;sv; -project_district;Suurmetsä;Suurmetsä;en; -project_district;Töölö;;fi; -project_district;Tölö;Töölö;sv; -project_district;Töölö;Töölö;en; -project_district;Tapaninkylä;;fi; -project_district;Staffansby;Tapaninkylä;sv; -project_district;Tapaninkylä;Tapaninkylä;en; -project_district;Ulkosaaret;;fi; -project_district;Utöarna;Ulkosaaret;sv; -project_district;Ulkosaaret;Ulkosaaret;en; -project_district;Vallila;;fi; -project_district;Vallgård;Vallila;sv; -project_district;Vallila;Vallila;en; -project_district;Vartiosaari;;fi; -project_district;Vårdö;Vartiosaari;sv; -project_district;Vartiosaari;Vartiosaari;en; -project_district;Vuosaari;;fi; -project_district;Nordsjö;Vuosaari;sv; -project_district;Vuosaari;Vuosaari;en; -project_district;Haaga;;fi; -project_district;Haga;Haaga;sv; -project_district;Haaga;Haaga;en; -project_district;Honkasuo;;fi; -project_district;Hongasmossa;Honkasuo;sv; -project_district;Honkasuo;Honkasuo;en; -project_district;Kaarela;;fi; -project_district;Kårböle;Kaarela;sv; -project_district;Kaarela;Kaarela;en; -project_district;Kallio;;fi; -project_district;Berghäll;Kallio;sv; -project_district;Kallio;Kallio;en; -project_district;Katajanokka;;fi; -project_district;Skatudden;Katajanokka;sv; -project_district;Katajanokka;Katajanokka;en; -project_district;Koskela;;fi; -project_district;Forsby;Koskela;sv; -project_district;Koskela;Koskela;en; -project_district;Keskusta;;fi; -project_district;Centrum;Keskusta;sv; -project_district;City centre;Keskusta;en; -project_district;Kuninkaantammi;;fi; -project_district;Kungseken;Kuninkaantammi;sv; -project_district;Kuninkaantammi;Kuninkaantammi;en; -project_district;Kumpula;;fi; -project_district;Gumtäkt;Kumpula;sv; -project_district;Kumpula;Kumpula;en; -project_district;Laakso;;fi; -project_district;Dal;Laakso;sv; -project_district;Laakso;Laakso;en; -project_district;Malminkartano;;fi; -project_district;Malmgård;Malminkartano;sv; -project_district;Malminkartano;Malminkartano;en; -project_district;Mellunkylä;;fi; -project_district;Mellungsby;Mellunkylä;sv; -project_district;Mellunkylä;Mellunkylä;en; -project_district;Myllypuro;;fi; -project_district;Kvarnbäcken;Myllypuro;sv; -project_district;Myllypuro;Myllypuro;en; -project_district;Pasila;;fi; -project_district;Böle;Pasila;sv; -project_district;Pasila;Pasila;en; -project_district;Punavuori;;fi; -project_district;Rödbergen;Punavuori;sv; -project_district;Punavuori;Punavuori;en; -project_district;Santahamina;;fi; -project_district;Sandhamn;Santahamina;sv; -project_district;Santahamina;Santahamina;en; -project_district;Suutarila;;fi; -project_district;Skomakarböle;Suutarila;sv; -project_district;Suutarila;Suutarila;en; -project_district;Talosaari;;fi; -project_district;Husö;Talosaari;sv; -project_district;Talosaari;Talosaari;en; -project_district;Toukola;;fi; -project_district;Majstad;Toukola;sv; -project_district;Toukola;Toukola;en; -project_district;Ullanlinna;;fi; -project_district;Ulrikasborg;Ullanlinna;sv; -project_district;Ullanlinna;Ullanlinna;en; -project_district;Vanhakaupunki;;fi; -project_district;Gammelstaden;Vanhakaupunki;sv; -project_district;Vanhakaupunki;Vanhakaupunki;en; -project_district;Viikki;;fi; -project_district;Vik;Viikki;sv; -project_district;Viikki;Viikki;en; -project_theme;Kadut ja liikenne;;fi; -project_theme;Gator och trafik;Kadut ja liikenne;sv; -project_theme;Streets and traffic;Kadut ja liikenne;en; -project_theme;Viher- ja virkistysalueet;;fi; -project_theme;Grön- och rekreationsområden;Viher- ja virkistysalueet;sv; -project_theme;Green and recreational areas;Viher- ja virkistysalueet;en; -project_theme;Palvelurakennukset;;fi; -project_theme;Servicelokaler;Palvelurakennukset;sv; -project_theme;Service facilities;Palvelurakennukset;en; -project_theme;Asunnot;;fi; -project_theme;Bostäder;Asunnot;sv; -project_theme;Housing;Asunnot;en; -project_theme;Liiketilat;;fi; -project_theme;Affärslokaler;Liiketilat;sv; -project_theme;Business facilities;Liiketilat;en; -project_phase;Suunnitteilla;;fi; -project_phase;Under planering;Suunnitteilla;sv; -project_phase;Under planning;Suunnitteilla;en; -project_phase;Odottaa toteutusta;;fi; -project_phase;Väntar genomförande;Odottaa toteutusta;sv; -project_phase;Waiting for implementation;Odottaa toteutusta;en; -project_phase;Rakenteilla;;fi; -project_phase;Under byggande;Rakenteilla;sv; -project_phase;Under construction;Rakenteilla;en; -project_phase;Valmis;;fi; -project_phase;Färdig;Valmis;sv; -project_phase;Finished;Valmis;en; -project_type;Kaavoitus;;fi; -project_type;Planläggning;Kaavoitus;sv; -project_type;Planning;Kaavoitus;en; -project_type;Liikenne- ja katusuunnittelu;;fi; -project_type;Trafik- och gatuplanering;Liikenne- ja katusuunnittelu;sv; -project_type;Traffic and street planning;Liikenne- ja katusuunnittelu;en; -project_type;Viheralueiden suunnittelu;;fi; -project_type;Planering av grönområden;Viheralueiden suunnittelu;sv; -project_type;Planning of green areas;Viheralueiden suunnittelu;en; -project_type;Luonnonsuojelualueet;;fi; -project_type;Naturskyddsområden;Luonnonsuojelualueet;sv; -project_type;Nature reserves;Luonnonsuojelualueet;en; -project_type;Suunnittelukilpailut;;fi; -project_type;Planeringstävlingar;Suunnittelukilpailut;sv; -project_type;Architectural competitions;Suunnittelukilpailut;en; -project_type;Kehittämisvaraukset;;fi; -project_type;Utvecklingsreserveringar;Kehittämisvaraukset;sv; -project_type;Development reservation;Kehittämisvaraukset;en; -project_sub_district;Etu-Töölö;;fi;Töölö -project_sub_district;Främre Tölö;Etu-Töölö;sv;Töölö -project_sub_district;Etu-Töölö;Etu-Töölö;en;Töölö -project_sub_district;Taka-Töölö;;fi;Töölö -project_sub_district;Bortre Tölö;Taka-Töölö;sv;Töölö -project_sub_district;Taka-Töölö;Taka-Töölö;en;Töölö \ No newline at end of file