From a389f59473e3fdd5b8ad5cf1fc54e06cf79b86c8 Mon Sep 17 00:00:00 2001 From: francois Date: Sat, 16 May 2020 14:25:11 -0400 Subject: [PATCH] ajout gestion des relations --- choix_entite.py | 27 + entites.py | 59 +- etat_libre_entites.xmi | 1188 +++++++++-------- makefile | 2 +- questions_entite.py | 28 +- questions_relations.py | 29 + uml_generated_code/postgres/adresse.sql | 2 +- uml_generated_code/postgres/association.sql | 2 +- .../postgres/association_adresse.sql | 3 +- .../postgres/association_coordonnees.sql | 3 +- .../postgres/association_logo.sql | 3 +- uml_generated_code/postgres/coordonnees.sql | 2 +- uml_generated_code/postgres/cours.sql | 2 +- .../postgres/cours_coordonnees.sql | 3 +- .../postgres/cours_etablissement.sql | 3 +- uml_generated_code/postgres/etablissement.sql | 2 +- .../postgres/etablissement_adresse.sql | 3 +- .../postgres/etablissement_coordonnees.sql | 3 +- uml_generated_code/postgres/evenement.sql | 2 +- .../postgres/evenement_association.sql | 3 +- .../postgres/evenement_etablissement.sql | 3 +- uml_generated_code/postgres/licence.sql | 2 +- uml_generated_code/postgres/logo.sql | 2 +- uml_generated_code/postgres/personne.sql | 2 +- .../postgres/personne_coordonnees.sql | 3 +- uml_generated_code/postgres/projet.sql | 2 +- .../postgres/projet_association.sql | 3 +- .../postgres/projet_coordonnees.sql | 3 +- .../postgres/projet_licence.sql | 3 +- 29 files changed, 752 insertions(+), 640 deletions(-) create mode 100755 choix_entite.py create mode 100755 questions_relations.py diff --git a/choix_entite.py b/choix_entite.py new file mode 100755 index 0000000..8618d52 --- /dev/null +++ b/choix_entite.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat May 16 09:36:14 2020 + +@author: francois +""" + + +def choix_entite(nom, message): + return { + 'type': 'list', + 'name': nom, + 'message': message, + 'choices': [ + 'adresse', + 'association', + 'coordonnees', + 'cours', + 'etablissement', + 'evenement', + 'licence', + 'logo', + 'personne', + 'projet' + ] + } diff --git a/entites.py b/entites.py index fda85a8..9e8eab3 100755 --- a/entites.py +++ b/entites.py @@ -6,20 +6,57 @@ Created on Sat May 9 09:53:25 2020 @author: francois """ -from questionary import prompt +import questionary as qq +import choix_entite as ce import questions_entite as qe +import questions_relations as qr import dataset +import pprint -choix_entite = prompt(qe.choix_entite) -reponses = prompt(qe.questions_entite[choix_entite['type']]) -print("Choix:\n"+str(choix_entite)+"\nRéponse:\n"+str(reponses)) +def saisie_entite(): + choix_entite = qq.prompt(ce.choix_entite('entite', 'entite'))['entite'] + pp.pprint(choix_entite) + reponses = qq.prompt(qe.questions_entite[choix_entite]) + pp.pprint(reponses) + try: + table = db[choix_entite] + table.insert(reponses) + except Exception as e: + print("Erreur dans l'insertion:"+str(e)) -psql_string = 'postgresql://etatdulibre:etatdulibre@172.19.0.2/etatdulibre' -try: - db = dataset.connect(psql_string) - table = db[choix_entite['type']] - table.insert(reponses) -except: - pass +def saisie_relation(): + reponses = qq.prompt(qr.questions_relations) + pp.pprint("Réponse:\n"+str(reponses)) + try: + table = db[reponses['entite1']+"_"+reponses['entite2']] + nom1 = db[reponses['entite1']].columns[0] + nom2 = db[reponses['entite2']].columns[0] + reponses_insert = {nom1: reponses['id_entite1'], + nom2: reponses['id_entite2'], + 'description': reponses['description']} + table.insert(reponses_insert) + except Exception as e: + print("Erreur dans l'insertion:"+str(e)) + + +psql_string = 'postgresql://etatdulibre:etatdulibre@172.20.0.2/etatdulibre' +db = dataset.connect(psql_string) +pp = pprint.PrettyPrinter(indent=4) + +quitter = 0 +while quitter == 0: + m0 = qq.select( + "Entité ou relation?", + choices=[ + 'entite', + 'relation', + 'quitter' + ]).ask() + if m0 == 'entite': + saisie_entite() + elif m0 == 'relation': + saisie_relation() + else: + quitter = 1 diff --git a/etat_libre_entites.xmi b/etat_libre_entites.xmi index 9b0d73f..3d90c0a 100644 --- a/etat_libre_entites.xmi +++ b/etat_libre_entites.xmi @@ -1,5 +1,5 @@ - + umbrello uml modeller http://umbrello.kde.org @@ -9,63 +9,63 @@ - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -73,604 +73,617 @@ - + - + - + - + - - - - - - - - - - + + + + + + + + + + - - - - + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - + + + + + - + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + + - + - - - - + + + + + - + - - - - + + + + + - + - - - - - + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + - + - - - - - + + + + + - + - - - - + + + + + - + - - - - - - + + + + + + - - - - - + + + + + - + - - - - + + + + + - + - - - - + + + + + - + - - - - + + + + + - + - - - - + + + + - + - - - - + + + + + - + - - - - - + + + + + - + - - - - + + + + + - + - - - - - - + + + + + + - - - - + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -681,247 +694,260 @@ - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + + - - - - - + + + + + + - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - + + + + + + - - - - - + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + + - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + - - - - - + + + + + - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + + - - - - - + + + + + + - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/makefile b/makefile index 9e810ed..5460bbe 100644 --- a/makefile +++ b/makefile @@ -10,7 +10,7 @@ run: clean: -docker stop etatdulibre pgadminlibre -docker container rm etatdulibre pgadminlibre - -docker image rm etatdulibre + -docker image rm etatdulibre pgadminlibre -docker network rm librenet -docker volume rm el_pgdata diff --git a/questions_entite.py b/questions_entite.py index 21cf921..3238a05 100755 --- a/questions_entite.py +++ b/questions_entite.py @@ -6,26 +6,6 @@ Created on Sat May 9 23:18:09 2020 @author: francois """ -choix_entite = [ - { - 'type': 'list', - 'name': 'type', - 'message': 'entite', - 'choices': [ - 'adresse', - 'association', - 'coordonnees', - 'cours', - 'etablissement', - 'evenement', - 'licence', - 'logo', - 'personne', - 'projet' - ] - } - ] - questions_entite = { 'adresse': [ { @@ -88,7 +68,7 @@ questions_entite = { ] }, { - 'type': 'editor', + 'type': 'text', 'name': 'description', 'message': 'description' }, @@ -133,7 +113,7 @@ questions_entite = { 'message': 'nom' }, { - 'type': 'editor', + 'type': 'text', 'name': 'description', 'message': 'description' } @@ -178,7 +158,7 @@ questions_entite = { 'message': 'premiere_date' }, { - 'type': 'editor', + 'type': 'text', 'name': 'description', 'message': 'description' } @@ -221,7 +201,7 @@ questions_entite = { 'message': 'nom' }, { - 'type': 'editor', + 'type': 'text', 'name': 'description', 'message': 'description' } diff --git a/questions_relations.py b/questions_relations.py new file mode 100755 index 0000000..8b87df4 --- /dev/null +++ b/questions_relations.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat May 16 09:06:41 2020 + +@author: francois +""" + +import choix_entite as ce + +questions_relations = [ + ce.choix_entite('entite1', 'entite1'), + { + 'type': 'input', + 'name': 'id_entite1', + 'message': 'id_entite1' + }, + ce.choix_entite('entite2', 'entite2'), + { + 'type': 'input', + 'name': 'id_entite2', + 'message': 'id_entite2' + }, + { + 'type': 'input', + 'name': 'description', + 'message': 'description' + } + ] diff --git a/uml_generated_code/postgres/adresse.sql b/uml_generated_code/postgres/adresse.sql index 445cc30..fd1d1d4 100644 --- a/uml_generated_code/postgres/adresse.sql +++ b/uml_generated_code/postgres/adresse.sql @@ -14,7 +14,7 @@ CREATE TABLE adresse ( date_saisie date NOT NULL ); CREATE SEQUENCE adresse_serial_seq START 1 INCREMENT 1 ; -ALTER TABLE adresse ALTER COLUMN serial SET NOT NULL; +ALTER TABLE adresse ALTER COLUMN serial SET NOT 0; ALTER TABLE adresse ALTER COLUMN serial SET DEFAULT nextval('adresse_serial_seq'); -- diff --git a/uml_generated_code/postgres/association.sql b/uml_generated_code/postgres/association.sql index 49777f0..7fdf9c4 100644 --- a/uml_generated_code/postgres/association.sql +++ b/uml_generated_code/postgres/association.sql @@ -15,7 +15,7 @@ CREATE TABLE association ( date_fermeture date ); CREATE SEQUENCE association_assoc_id_seq START 1 INCREMENT 1 ; -ALTER TABLE association ALTER COLUMN assoc_id SET NOT NULL; +ALTER TABLE association ALTER COLUMN assoc_id SET NOT 0; ALTER TABLE association ALTER COLUMN assoc_id SET DEFAULT nextval('association_assoc_id_seq'); -- diff --git a/uml_generated_code/postgres/association_adresse.sql b/uml_generated_code/postgres/association_adresse.sql index 658baae..b28c098 100644 --- a/uml_generated_code/postgres/association_adresse.sql +++ b/uml_generated_code/postgres/association_adresse.sql @@ -6,7 +6,8 @@ CREATE TABLE association_adresse ( assoc_id integer NOT NULL , - adresse_id integer NOT NULL + adresse_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/association_coordonnees.sql b/uml_generated_code/postgres/association_coordonnees.sql index 94282db..610cc31 100644 --- a/uml_generated_code/postgres/association_coordonnees.sql +++ b/uml_generated_code/postgres/association_coordonnees.sql @@ -6,7 +6,8 @@ CREATE TABLE association_coordonnees ( assoc_id integer NOT NULL , - coord_id integer NOT NULL + coord_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/association_logo.sql b/uml_generated_code/postgres/association_logo.sql index 8df4933..fbe1c69 100644 --- a/uml_generated_code/postgres/association_logo.sql +++ b/uml_generated_code/postgres/association_logo.sql @@ -6,7 +6,8 @@ CREATE TABLE association_logo ( assoc_id integer NOT NULL , - logo_id integer NOT NULL + logo_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/coordonnees.sql b/uml_generated_code/postgres/coordonnees.sql index ac5fe67..f8fe3be 100644 --- a/uml_generated_code/postgres/coordonnees.sql +++ b/uml_generated_code/postgres/coordonnees.sql @@ -10,7 +10,7 @@ CREATE TABLE coordonnees ( coord_contenu character varying ); CREATE SEQUENCE coordonnees_coord_id_seq START 1 INCREMENT 1 ; -ALTER TABLE coordonnees ALTER COLUMN coord_id SET NOT NULL; +ALTER TABLE coordonnees ALTER COLUMN coord_id SET NOT 0; ALTER TABLE coordonnees ALTER COLUMN coord_id SET DEFAULT nextval('coordonnees_coord_id_seq'); -- diff --git a/uml_generated_code/postgres/cours.sql b/uml_generated_code/postgres/cours.sql index 7c4d99b..c4292aa 100644 --- a/uml_generated_code/postgres/cours.sql +++ b/uml_generated_code/postgres/cours.sql @@ -11,7 +11,7 @@ CREATE TABLE cours ( description character varying ); CREATE SEQUENCE cours_cours_id_seq START 1 INCREMENT 1 ; -ALTER TABLE cours ALTER COLUMN cours_id SET NOT NULL; +ALTER TABLE cours ALTER COLUMN cours_id SET NOT 0; ALTER TABLE cours ALTER COLUMN cours_id SET DEFAULT nextval('cours_cours_id_seq'); -- diff --git a/uml_generated_code/postgres/cours_coordonnees.sql b/uml_generated_code/postgres/cours_coordonnees.sql index 28f0c67..3fd426c 100644 --- a/uml_generated_code/postgres/cours_coordonnees.sql +++ b/uml_generated_code/postgres/cours_coordonnees.sql @@ -6,7 +6,8 @@ CREATE TABLE cours_coordonnees ( cours_id integer NOT NULL , - coord_id integer NOT NULL + coord_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/cours_etablissement.sql b/uml_generated_code/postgres/cours_etablissement.sql index deef5ef..2d953a8 100644 --- a/uml_generated_code/postgres/cours_etablissement.sql +++ b/uml_generated_code/postgres/cours_etablissement.sql @@ -6,7 +6,8 @@ CREATE TABLE cours_etablissement ( cours_id integer NOT NULL , - etabl_id integer NOT NULL + etabl_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/etablissement.sql b/uml_generated_code/postgres/etablissement.sql index a585165..e8d0175 100644 --- a/uml_generated_code/postgres/etablissement.sql +++ b/uml_generated_code/postgres/etablissement.sql @@ -9,7 +9,7 @@ CREATE TABLE etablissement ( nom character varying ); CREATE SEQUENCE etablissement_etabl_id_seq START 1 INCREMENT 1 ; -ALTER TABLE etablissement ALTER COLUMN etabl_id SET NOT NULL; +ALTER TABLE etablissement ALTER COLUMN etabl_id SET NOT 0; ALTER TABLE etablissement ALTER COLUMN etabl_id SET DEFAULT nextval('etablissement_etabl_id_seq'); -- diff --git a/uml_generated_code/postgres/etablissement_adresse.sql b/uml_generated_code/postgres/etablissement_adresse.sql index 496e9a7..9ea64d3 100644 --- a/uml_generated_code/postgres/etablissement_adresse.sql +++ b/uml_generated_code/postgres/etablissement_adresse.sql @@ -6,7 +6,8 @@ CREATE TABLE etablissement_adresse ( etabl_id integer NOT NULL , - adresse_id integer NOT NULL + adresse_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/etablissement_coordonnees.sql b/uml_generated_code/postgres/etablissement_coordonnees.sql index 9ddf756..48784ff 100644 --- a/uml_generated_code/postgres/etablissement_coordonnees.sql +++ b/uml_generated_code/postgres/etablissement_coordonnees.sql @@ -6,7 +6,8 @@ CREATE TABLE etablissement_coordonnees ( etabl_id integer NOT NULL , - coord_id integer NOT NULL + coord_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/evenement.sql b/uml_generated_code/postgres/evenement.sql index d405839..7b33eb0 100644 --- a/uml_generated_code/postgres/evenement.sql +++ b/uml_generated_code/postgres/evenement.sql @@ -15,7 +15,7 @@ CREATE TABLE evenement ( description character varying ); CREATE SEQUENCE evenement_event_id_seq START 1 INCREMENT 1 ; -ALTER TABLE evenement ALTER COLUMN event_id SET NOT NULL; +ALTER TABLE evenement ALTER COLUMN event_id SET NOT 0; ALTER TABLE evenement ALTER COLUMN event_id SET DEFAULT nextval('evenement_event_id_seq'); -- diff --git a/uml_generated_code/postgres/evenement_association.sql b/uml_generated_code/postgres/evenement_association.sql index 18812dc..8a76cb3 100644 --- a/uml_generated_code/postgres/evenement_association.sql +++ b/uml_generated_code/postgres/evenement_association.sql @@ -6,7 +6,8 @@ CREATE TABLE evenement_association ( event_id integer NOT NULL , - assoc_id integer NOT NULL + assoc_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/evenement_etablissement.sql b/uml_generated_code/postgres/evenement_etablissement.sql index 930508a..b3d1034 100644 --- a/uml_generated_code/postgres/evenement_etablissement.sql +++ b/uml_generated_code/postgres/evenement_etablissement.sql @@ -6,7 +6,8 @@ CREATE TABLE evenement_etablissement ( event_id integer NOT NULL , - etabl_id integer NOT NULL + etabl_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/licence.sql b/uml_generated_code/postgres/licence.sql index 8efc3ba..c25cd70 100644 --- a/uml_generated_code/postgres/licence.sql +++ b/uml_generated_code/postgres/licence.sql @@ -10,7 +10,7 @@ CREATE TABLE licence ( sigle character varying ); CREATE SEQUENCE licence_licence_id_seq START 1 INCREMENT 1 ; -ALTER TABLE licence ALTER COLUMN licence_id SET NOT NULL; +ALTER TABLE licence ALTER COLUMN licence_id SET NOT 0; ALTER TABLE licence ALTER COLUMN licence_id SET DEFAULT nextval('licence_licence_id_seq'); -- diff --git a/uml_generated_code/postgres/logo.sql b/uml_generated_code/postgres/logo.sql index 0d68429..7d1ecad 100644 --- a/uml_generated_code/postgres/logo.sql +++ b/uml_generated_code/postgres/logo.sql @@ -9,7 +9,7 @@ CREATE TABLE logo ( logo_url character varying ); CREATE SEQUENCE logo_logo_id_seq START 1 INCREMENT 1 ; -ALTER TABLE logo ALTER COLUMN logo_id SET NOT NULL; +ALTER TABLE logo ALTER COLUMN logo_id SET NOT 0; ALTER TABLE logo ALTER COLUMN logo_id SET DEFAULT nextval('logo_logo_id_seq'); -- diff --git a/uml_generated_code/postgres/personne.sql b/uml_generated_code/postgres/personne.sql index 27b5e74..fcf2abe 100644 --- a/uml_generated_code/postgres/personne.sql +++ b/uml_generated_code/postgres/personne.sql @@ -10,7 +10,7 @@ CREATE TABLE personne ( prenom character varying ); CREATE SEQUENCE personne_pers_id_seq START 1 INCREMENT 1 ; -ALTER TABLE personne ALTER COLUMN pers_id SET NOT NULL; +ALTER TABLE personne ALTER COLUMN pers_id SET NOT 0; ALTER TABLE personne ALTER COLUMN pers_id SET DEFAULT nextval('personne_pers_id_seq'); -- diff --git a/uml_generated_code/postgres/personne_coordonnees.sql b/uml_generated_code/postgres/personne_coordonnees.sql index 36c299b..483ddff 100644 --- a/uml_generated_code/postgres/personne_coordonnees.sql +++ b/uml_generated_code/postgres/personne_coordonnees.sql @@ -6,7 +6,8 @@ CREATE TABLE personne_coordonnees ( coord_id integer NOT NULL , - pers_id integer NOT NULL + pers_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/projet.sql b/uml_generated_code/postgres/projet.sql index 7a9e38f..64d4ee8 100644 --- a/uml_generated_code/postgres/projet.sql +++ b/uml_generated_code/postgres/projet.sql @@ -10,7 +10,7 @@ CREATE TABLE projet ( description character varying ); CREATE SEQUENCE projet_projet_id_seq START 1 INCREMENT 1 ; -ALTER TABLE projet ALTER COLUMN projet_id SET NOT NULL; +ALTER TABLE projet ALTER COLUMN projet_id SET NOT 0; ALTER TABLE projet ALTER COLUMN projet_id SET DEFAULT nextval('projet_projet_id_seq'); -- diff --git a/uml_generated_code/postgres/projet_association.sql b/uml_generated_code/postgres/projet_association.sql index 4ffd4fc..d495396 100644 --- a/uml_generated_code/postgres/projet_association.sql +++ b/uml_generated_code/postgres/projet_association.sql @@ -6,7 +6,8 @@ CREATE TABLE projet_association ( projet_id integer NOT NULL , - assoc_id integer NOT NULL + assoc_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/projet_coordonnees.sql b/uml_generated_code/postgres/projet_coordonnees.sql index 6926969..93ffb16 100644 --- a/uml_generated_code/postgres/projet_coordonnees.sql +++ b/uml_generated_code/postgres/projet_coordonnees.sql @@ -6,7 +6,8 @@ CREATE TABLE projet_coordonnees ( projet_id integer NOT NULL , - coord_id integer NOT NULL + coord_id integer NOT NULL , + description character varying NOT NULL ); -- diff --git a/uml_generated_code/postgres/projet_licence.sql b/uml_generated_code/postgres/projet_licence.sql index 26850f6..8d18881 100644 --- a/uml_generated_code/postgres/projet_licence.sql +++ b/uml_generated_code/postgres/projet_licence.sql @@ -6,7 +6,8 @@ CREATE TABLE projet_licence ( projet_id integer NOT NULL , - licence_id integer NOT NULL + licence_id integer NOT NULL , + description character varying NOT NULL ); --