Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPORT] Intégrer les champs d'import lors de l'installation d'un protocole #398

Conversation

jules-jean-louis1
Copy link

[IMPORT][MONITORING] IM_IMPORT_01.0 - Intégrer les champs d'import lors de l'installation d'un protocole Import V3 (view)

Intégration des champs d'import lors de l'installation d'un protocole

Ajout dans la table bib_destinations

  • Intégration du protocole installé dans la table bib_destinations.

Récupération et insertion des entités

  • Lecture des entités définies dans le fichier config.json du module.
  • Ajout des entités récupérées dans la table bib_entities.

Gestion des champs spécifiques et génériques

  • Génération d'un fichier JSON contenant :
    • Les champs génériques (surcouche).
    • Les champs spécifiques au protocole.
  • Insertion de ces champs dans les tables bib_fields et cor_entity_field.

Création de la table d'import

  • Mise en place d’une nouvelle table dédiée : t_import_{protocole}.
  • Cette table contiendra l'ensemble des champs du protocole, et sera ajoutée au schéma gn_imports.

jacquesfize and others added 18 commits December 13, 2024 10:16
* VESION and requirements.in

* Docs

* Changelog 1.0.0 / complément

* Update README.md

* Update docs/changelog.md

* Bump GeoNature

* Add postgis ltree extension

* Suppression données orpheline synthese

* Use geonature 03b_populate_db.sh script

* Changelog

---------

Co-authored-by: Camille Monchicourt <camille.monchicourt@ecrins-parcnational.fr>
…tions/gn_module_monitoring into feat/import/install-protocol
@camillemonchicourt
Copy link
Member

Il faudrait rebaser la branche de destination sur DEVELOP, car là la PR semble ajouter des commits qui sont liés à d'autres évolutions récentes de DEVELOP.

@jules-jean-louis1 jules-jean-louis1 marked this pull request as draft December 23, 2024 14:37
@jules-jean-louis1 jules-jean-louis1 changed the base branch from feat/import-monitoring to develop December 23, 2024 15:21
jacquesfize and others added 9 commits December 23, 2024 16:39
* VESION and requirements.in

* Docs

* Changelog 1.0.0 / complément

* Update README.md

* Update docs/changelog.md

* Bump GeoNature

* Add postgis ltree extension

* Suppression données orpheline synthese

* Use geonature 03b_populate_db.sh script

* Changelog

---------

Co-authored-by: Camille Monchicourt <camille.monchicourt@ecrins-parcnational.fr>
@20cents 20cents force-pushed the feat/import/install-protocol branch from d3af099 to 4e1ffa7 Compare February 28, 2025 08:44
@jules-jean-louis1 jules-jean-louis1 changed the base branch from develop to feat/import-monitoring March 6, 2025 14:44
@jules-jean-louis1 jules-jean-louis1 marked this pull request as ready for review March 11, 2025 15:28
@jacquesfize jacquesfize force-pushed the feat/import-monitoring branch from 4fb75fe to 90863ed Compare March 14, 2025 09:03
generic_data = json_from_file(generic_data_path, result_default={})

entity_confs[entity_code] = {
"specific_data": generic_data,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"specific_data": generic_data,
"specific_data": specific_data,

try:
module = get_simple_module("module_code", module_code)
# test si le module existe
# Vérifier si le module existe
if module:
Copy link
Contributor

@jacquesfize jacquesfize Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si le module monitoring existe déjà dans t_modules, il faut le vérifier et procéder à l'installation de la couche import (et ignoré la maj). Par exemple, en vérifiant l'existence dans la table destination

Suggested change
if module:
destination_exists = DB.session.scalar(
exists(Destination).where(Destination.code == module_code).select()
)
if module and destination_exists:

Booléen indiquant si la mise à jour a réussi.
"""
try:
DB.session.rollback()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi un rollback ici ?

@jacquesfize
Copy link
Contributor

Si un module de monitoring existe déjà dans t_modules, il faut ignorer le groupe d'instruction faisant l'ajout en base

L157 - cmd.py

 module = TMonitoringModules()
    module.from_dict(module_data)
    DB.session.add(module)
    DB.session.commit()

A remplacer par exemple par

if not DB.session.scalar(
        exists(TMonitoringModules).where(
            TMonitoringModules.module_code == module_code
        ).select()
    ):
        module = TMonitoringModules()
        module.from_dict(module_data)
        DB.session.add(module)
        DB.session.commit()

@20cents 20cents force-pushed the feat/import/install-protocol branch 2 times, most recently from 6667140 to 3e910fa Compare March 17, 2025 17:03
@20cents 20cents force-pushed the feat/import/install-protocol branch from 3e910fa to 7ebeb32 Compare March 18, 2025 08:28
Comment on lines +884 to +889
elif (
"value" in field_data
and isinstance(field_data["value"], dict)
and "code_nomenclature_type" in field_data["value"]
):
mnemonique = field_data["value"]["code_nomenclature_type"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Étrange ça ? La nomenclature peut être déclaré à des endroits différents selon le protocole ?

@jacquesfize jacquesfize force-pushed the feat/import-monitoring branch from 9e73f30 to 4c0d6be Compare April 7, 2025 13:30
@jacquesfize
Copy link
Contributor

Intégré dans #424

@jacquesfize jacquesfize closed this Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants