54 |
jpm |
1 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
2 |
# SCRIPT de MIGRATION de HERBIERS vers COEL v1.0
|
|
|
3 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
4 |
# TODO : remplacer les valeurs vides par NULL -> utiliser le script remplacer_vide_par_null.php
|
|
|
5 |
|
56 |
jpm |
6 |
SET @idm = 761;# Identifiant pour les métadonnées
|
|
|
7 |
SET @idm_max = 99999;# Identifiant pour les métadonnées maximum si déjà des données dans la base
|
54 |
jpm |
8 |
#---------------------------------------------------------------------------------------------------------------------#
|
56 |
jpm |
9 |
# Nettoyage des tables
|
|
|
10 |
# coel_projet : la table d'historique des lignes
|
|
|
11 |
DELETE FROM tb_coel.coel_projet WHERE cpr_id_projet = 2;
|
|
|
12 |
# coel_meta_historique_ligne : la table d'historique des lignes
|
|
|
13 |
DELETE FROM tb_coel.coel_meta_historique_ligne WHERE cmhl_id_historique_ligne >= @idm AND cmhl_id_historique_ligne < @idm_max;
|
|
|
14 |
# coel_structure : la table contenant les structures
|
|
|
15 |
DELETE FROM tb_coel.coel_structure WHERE cs_id_structure IN (SELECT ID_ORG FROM tb_herbiers.HERBIERS_ORGANISATION ORDER BY ID_ORG ASC);
|
|
|
16 |
|
|
|
17 |
#---------------------------------------------------------------------------------------------------------------------#
|
|
|
18 |
# EFLORE_PROJET vers coel_projet
|
|
|
19 |
# Insertion du projet Inventaire des Herbiers de France - Version 1
|
|
|
20 |
INSERT INTO tb_coel.coel_projet (cpr_id_projet, cpr_nom, cpr_abreviation, cpr_description, cpr_url, cpr_ce_meta)
|
|
|
21 |
SELECT 2, EPR_INTITULE_PROJET, EPR_ABREVIATION_PROJET, EPR_DESCRIPTION_PROJET, EPR_LIEN_WEB, @idm
|
|
|
22 |
FROM tb_herbiers.EFLORE_PROJET;
|
73 |
jpm |
23 |
INSERT INTO tb_coel.coel_meta_historique_ligne (cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
24 |
VALUES (@idm := @idm+1, '113', '2', NULL , NOW( ) , 'Ajout du projet IHF', '1', '1', '162.38.234.1');
|
|
|
25 |
# Insertion du projet Utilisateur de l''application COEL - Version 1
|
|
|
26 |
INSERT INTO tb_coel.coel_projet (cpr_id_projet, cpr_nom, cpr_abreviation, cpr_description, cpr_url, cpr_ce_meta)
|
|
|
27 |
VALUES 3, 'Utilisateurs', 'U', 'Les utilisateurs de l''application COEL.', NULL, @idm;
|
|
|
28 |
INSERT INTO tb_coel.coel_meta_historique_ligne (cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
29 |
VALUES (@idm := @idm+1, '113', '2', NULL , NOW( ) , 'Ajout du projet U', '1', '1', '162.38.234.1');
|
54 |
jpm |
30 |
|
73 |
jpm |
31 |
|
54 |
jpm |
32 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
33 |
# HERBIERS_ORGANISATION vers coel_structure
|
|
|
34 |
ALTER TABLE tb_herbiers.HERBIERS_ORGANISATION ORDER BY ID_ORG;# Classement des organisations par ID croissant
|
56 |
jpm |
35 |
#ALTER TABLE tb_herbiers.HERBIERS_ORGANISATION DROP NUM_COLLECTION, DROP ADRESS_TEXT, DROP TIME_ZONE ;# Suppression des champs inutiles
|
54 |
jpm |
36 |
SET @idm_tmp = @idm;# Identifiant pour les métadonnées temporaire
|
|
|
37 |
INSERT INTO tb_coel.coel_structure
|
56 |
jpm |
38 |
(cs_id_structure, cs_ce_projet, cs_ce_mere, cs_truk_identifiant_alternatif, cs_guid,
|
|
|
39 |
cs_nom, cs_adresse_01, cs_code_postal, cs_ville, cs_region, cs_pays, cs_telephone, cs_fax, cs_courriel,
|
|
|
40 |
cs_description,
|
|
|
41 |
cs_truk_url,
|
|
|
42 |
cs_condition_acces,
|
|
|
43 |
cs_ce_meta)
|
|
|
44 |
SELECT ID_ORG, 2, 0, CONCAT("URN:tela-botanica.org:ihf:str",ID_ORG) AS GUID, IF(INDEX_HERB != '', CONCAT('IH#',INDEX_HERB), NULL) AS IDENTIFIANT_ALTERNATIF,
|
|
|
45 |
INSTITUTION_NAME, ADRESS_LINE, ZIP, TOWN, REGION, IF(COUNTRY_CODE = 'fr', 'France', COUNTRY_CODE) AS PAYS, TEL, FAX, EMAIL,
|
|
|
46 |
IF(SOURCE_DES_DONNEES != '', CONCAT("Source des données : ",SOURCE_DES_DONNEES), NULL) AS DESCRIPTION,
|
|
|
47 |
CONCAT(IF(HO_URL != 'http://', CONCAT('WEB#',HO_URL), ''),IF(HO_URL != 'http://' AND LOGO != '', ';', ''), IF(LOGO != '', CONCAT('LOGO#',LOGO),'')) AS URLS,
|
|
|
48 |
ACCESS_RESTRICTION,
|
|
|
49 |
@idm := @idm+1
|
|
|
50 |
FROM tb_herbiers.HERBIERS_ORGANISATION
|
|
|
51 |
ORDER BY ID_ORG ASC;
|
|
|
52 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
53 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
|
|
|
54 |
cmhl_notes,
|
|
|
55 |
cmhl_ce_modifier_par, cmhl_ce_etat, cmhl_ip)
|
|
|
56 |
SELECT @idm_tmp := @idm_tmp+1, 117, ID_ORG, NULL, IF(DATE_DERNIERE_MODIF = '0000-00-00 00:00:00', NOW(), DATE_DERNIERE_MODIF),
|
|
|
57 |
CONCAT('Importation de l''enregistrement #',ID_ORG,' de la table HERBIERS_ORGANISATION.'),
|
|
|
58 |
IF(CE_MODIFIER_PAR = '0', 1, CE_MODIFIER_PAR), '1', '162.38.234.1'
|
|
|
59 |
FROM tb_herbiers.HERBIERS_ORGANISATION
|
68 |
jpm |
60 |
ORDER BY ID_ORG ASC;
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
71 |
#EFLORE_DROIT_POSSEDER vers coel_personne_a_relation
|
|
|
72 |
INSERT INTO tb_coel.coel_personne_a_relation
|
|
|
73 |
(cpar_id_personne_01, cpar_id_personne_02, cpar_id_projet, cpar_id_role, cpar_ce_meta)
|
73 |
jpm |
74 |
SELECT EDP_ID_UTILISATEUR, EDP_ID_UTILISATEUR, '2', IF(EDP_ID_DROIT = '1', 2022, IF(EDP_ID_DROIT = '2', 2023, IF(EDP_ID_DROIT = '3', 2024, 0))), @idm := @idm+1
|
68 |
jpm |
75 |
FROM tb_herbiers.EFLORE_DROIT_POSSEDER
|
|
|
76 |
ORDER BY EDP_ID_UTILISATEUR ASC;
|
|
|
77 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
78 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
79 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
73 |
jpm |
80 |
SELECT @idm_tmp := @idm_tmp+1, '112', CONCAT(EDP_ID_UTILISATEUR, '-', EDP_ID_UTILISATEUR, '-2-', IF(EDP_ID_DROIT = '1', 2022, IF(EDP_ID_DROIT = '2', 2023, IF(EDP_ID_DROIT = '3', 2024, 0)))), NULL, NOW(), CONCAT('Importation des droits l''utilisateur #',EDP_ID_UTILISATEUR,' de la table EFLORE_DROIT_POSSEDER.'), '1', '1', '162.38.234.1'
|
68 |
jpm |
81 |
FROM tb_herbiers.EFLORE_DROIT_POSSEDER
|
|
|
82 |
ORDER BY EDP_ID_UTILISATEUR ASC;
|
|
|
83 |
|
|
|
84 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
85 |
# HERBIER_COORDONNE vers coel_personne_a_relation
|
|
|
86 |
INSERT INTO tb_coel.coel_personne_a_relation
|
|
|
87 |
(cpar_id_personne_01, cpar_id_personne_02, cpar_id_projet, cpar_id_role, cpar_ce_meta)
|
|
|
88 |
SELECT HC_ID_COORDINATEUR, HC_ID_REDACTEUR, 2, 2025, @idm := @idm+1
|
|
|
89 |
FROM tb_herbiers.HERBIER_COORDONNE
|
|
|
90 |
ORDER BY HC_ID_COORDINATEUR, HC_ID_REDACTEUR ASC;
|
|
|
91 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
92 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
93 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
73 |
jpm |
94 |
SELECT @idm_tmp := @idm_tmp+1, '112', CONCAT(HC_ID_COORDINATEUR, '-', HC_ID_REDACTEUR, '-2-2025'), NULL,
|
68 |
jpm |
95 |
NOW(), CONCAT('Importation des relations de coordination de l''utilisateur #',HC_ID_COORDINATEUR,' de la table HERBIER_COORDONNE.'), '1', '1', '162.38.234.1'
|
|
|
96 |
FROM tb_herbiers.EFLORE_DROIT_POSSEDER
|
|
|
97 |
ORDER BY EDP_ID_UTILISATEUR ASC;
|
|
|
98 |
|
|
|
99 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
100 |
#annuaire_tela vers coel_personne
|
73 |
jpm |
101 |
# Pour l''identifiant on garde celui de l''annuaire Tela. Les autres projets commenceront à partir de 100 000
|
68 |
jpm |
102 |
INSERT INTO tb_coel.coel_personne
|
|
|
103 |
(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
|
|
|
104 |
cp_adresse_01, cp_adresse_02, cp_region, cp_code_postal, cp_ville, cp_pays,
|
|
|
105 |
cp_truk_courriel, cp_truk_url,
|
|
|
106 |
cp_description,
|
|
|
107 |
cp_ce_truk_role,
|
73 |
jpm |
108 |
cp_mot_de_passe, cp_login, cp_ce_annuaire_tela, cp_parametre,
|
68 |
jpm |
109 |
cp_ce_meta)
|
73 |
jpm |
110 |
SELECT U_ID, '3', CONCAT(U_SURNAME,'',U_NAME) AS NOM_COMPLET, U_SURNAME, U_NAME,
|
68 |
jpm |
111 |
U_ADDR1, U_ADDR2, U_STATE, U_ZIP_CODE, U_CITY, CP.CP_Intitule_pays,
|
73 |
jpm |
112 |
LOWER(U_MAIL), U_WEB,
|
68 |
jpm |
113 |
CONCAT('Spécialités systématiques : ', U_SPE, '\nSpécialités géographiques : ', U_GEO, '\nFonction : ', U_FONCTION, '\nStructure : ', U_TITLE),
|
|
|
114 |
IF(EDP_ID_DROIT = '1', 2022, IF(EDP_ID_DROIT = '2', 2023, IF(EDP_ID_DROIT = '3', 2024, 0))),
|
73 |
jpm |
115 |
U_PASSWD, U_MAIL, U_ID, CONCAT('<?xml version="1.0" encoding="UTF-8"><parametres><niveau_bota>', U_NIV,'</niveau_bota></parametres>'),
|
68 |
jpm |
116 |
@idm := @idm+1
|
|
|
117 |
FROM tela_prod_v4.annuaire_tela AS AT, tb_herbiers.EFLORE_DROIT_POSSEDER AS EDP, tela_prod_v4.carto_PAYS AS CP
|
|
|
118 |
WHERE AT.U_ID = EDP.EDP_ID_UTILISATEUR
|
|
|
119 |
AND CP.CP_ID_Pays = AT.U_COUNTRY
|
|
|
120 |
ORDER BY U_ID ASC;
|
|
|
121 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
122 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
|
|
|
123 |
cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
124 |
SELECT @idm_tmp := @idm_tmp+1, '111', U_ID, NULL, U_DATE,
|
|
|
125 |
CONCAT('Importation de l''utilisateur #', U_ID,' de la table annuaire_tela.'), '1', '1', '162.38.234.1'
|
|
|
126 |
FROM tela_prod_v4.annuaire_tela AS AT, tb_herbiers.EFLORE_DROIT_POSSEDER AS EDP
|
|
|
127 |
WHERE AT.U_ID = EDP.EDP_ID_UTILISATEUR
|
|
|
128 |
ORDER BY U_ID ASC;
|
|
|
129 |
|
|
|
130 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
131 |
# HERBIER_ADMINISTRER vers coel_structure_a_personne
|
|
|
132 |
INSERT INTO tb_coel.coel_structure_a_personne
|
|
|
133 |
(csap_id_structure, csap_id_personne, csap_id_role, csap_ce_meta)
|
|
|
134 |
SELECT HA_ID_ORG, HA_ID_ANNUAIRE, '2026', @idm := @idm+1
|
|
|
135 |
FROM tb_herbiers.HERBIER_ADMINISTRER
|
|
|
136 |
ORDER BY HA_ID_ANNUAIRE, HA_ID_ORG ASC;
|
|
|
137 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
138 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
139 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
140 |
SELECT @idm_tmp := @idm_tmp+1, '118', CONCAT(HA_ID_ORG, '-', HA_ID_ANNUAIRE, '-2026'), NULL,
|
|
|
141 |
NOW(), CONCAT('Importation des de l''administrateur #',HA_ID_ANNUAIRE,' de la structure #', HA_ID_ORG,'de la table HERBIER_ADMINISTRER.'), '1', '1', '162.38.234.1'
|
|
|
142 |
FROM tb_herbiers.HERBIER_ADMINISTRER
|
|
|
143 |
ORDER BY HA_ID_ANNUAIRE, HA_ID_ORG ASC;
|
73 |
jpm |
144 |
|
|
|
145 |
|
|
|
146 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
147 |
#HERBIERS_STAFF vers coel_personne
|
|
|
148 |
INSERT INTO tb_coel.coel_personne
|
|
|
149 |
(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_nom, cp_prenom, cp_adresse_01, cp_adresse_02, cp_code_postal, cp_ville, cp_truk_courriel,
|
|
|
150 |
cp_truk_telephone, cp_truk_fax, cp_ce_meta)
|
|
|
151 |
SELECT 100000+ID_STAFF, '2', CONCAT(PRENOM,'', NOM) AS NOM_COMPLET, NOM, PRENOM, ADRESSE1, ADRESSE2, CP, VILLE, LOWER(MAIL),
|
|
|
152 |
IF(TEL != NULL, CONCAT('+33', TRIM(LEADING '0' FROM REPLACE(TEL,'[33]',''))), NULL), CONCAT('+33', TRIM(LEADING '0' FROM REPLACE(FAX,'[33]',''))), @idm := @idm+1
|
|
|
153 |
FROM tb_herbiers.HERBIERS_STAFF
|
|
|
154 |
ORDER BY ID_STAFF ASC;
|
|
|
155 |
INSERT INTO tb_coel.coel_metal_historique_ligne
|
|
|
156 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
157 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
158 |
SELECT @idm_tmp := @idm_tmp+1, '111', , NULL, DATE_DERNIERE_MODIF,
|
|
|
159 |
CONCAT('Importation de l''utilisateur #', ID_STAFF,'de la table HERBIERS_STAFF'), '1', '1', '162.38.234.1'
|
|
|
160 |
FROM tb_herbiers.HERBIERS_STAFF
|
|
|
161 |
ORDER BY ID_STAFF ASC;
|
|
|
162 |
UPDATE tb_coel.coel_personne SET cp_truk_telephone = IF(cp_truk_telephone LIKE (+336%), CONCAT('GSM#', cp_truk_telephone), CONCAT('FIX#', cp_truk_telephone)));
|
|
|
163 |
UPDATE tb_coel.coel_personne SET cp_truk_telephone = REPLACE(cp_truk_telephone, '.', ' ') WHERE cp_truk_telephone LIKE '%.%';
|
|
|
164 |
UPDATE tb_coel.coel_personne SET cp_truk_telephone = REPLACE(cp_truk_telephone, '+33 (0)', '') WHERE cp_truk_telephone LIKE '%+33 (0)%';
|
|
|
165 |
# TODO : faire les fax
|
68 |
jpm |
166 |
|
|
|
167 |
#------------------------------------------------------------------------------------------------------------------------
|
73 |
jpm |
168 |
# HERBIERS_ont_un_staff vers coel_structure_a_personne
|
|
|
169 |
INSERT INTO tb_coel.coel_structure_a_personne
|
|
|
170 |
(csap_id_structure, csap_id_personne, csap_id_role, csap_mark_contact, csap_ce_truk_fonction, csap_ce_meta)
|
|
|
171 |
SELECT ID_ORG, hous.ID_STAFF, '2027', IF(LOWER(CONTACT) = 'oui', 1, 0) AS CONTACT, IF(FONCTION != '', CONCAT('AUTRE#', FONCTION), NULL) AS FONCTION, @idm := @idm+1
|
|
|
172 |
FROM tb_herbiers.HERBIERS_ont_un_staff AS hous LEFT JOIN tb_herbiers.HERBIERS_STAFF AS hs ON (hous.ID_STAFF = hs.ID_STAFF)
|
|
|
173 |
WHERE hous.ID_ORG != 0
|
|
|
174 |
ORDER BY hous.ID_ORG, hous.ID_STAFF ASC;
|
|
|
175 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
176 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
177 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
178 |
SELECT @idm_tmp := @idm_tmp+1, '118', CONCAT(ID_ORG, '-', ID_STAFF, '-2027'), NULL,
|
|
|
179 |
NOW(), CONCAT('Importation de la personne #',ID_STAFF,' de la structure #', ID_ORG,'de la table HERBIERS_ont_un_staff.'), '1', '1', '162.38.234.1'
|
|
|
180 |
FROM tb_herbiers.HERBIERS_ont_un_staff
|
|
|
181 |
WHERE hous.ID_ORG != 0
|
|
|
182 |
ORDER BY ID_ORG, ID_STAFF ASC;
|
|
|
183 |
# TODO : ajouter une requête d''update pour mettre à jour la fonction...
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
#------------------------------------------------------------------------------------------------------------------------
|
68 |
jpm |
187 |
#HERBIER_COLLECTION vers coel_collection
|
|
|
188 |
#INSERT INTO tb_coel.coel_collection
|
|
|
189 |
# (cc_id_collection, cc_ce_projet, cc_ce_mere, cc_truk_code, cc_nom, cc_description,
|
|
|
190 |
# cc_truk_url, cc_ce_type,
|
73 |
jpm |
191 |
# cc_specimen_type_nbre,
|
|
|
192 |
# cc_ce_meta)
|
|
|
193 |
# SELECT Id, 2, PARENT_ID, COLLECTION_CODE, NOM_COLLECTION, DESCRIPTION,
|
|
|
194 |
# URL, INCLUDED_TYPE,
|
|
|
195 |
count (distinct NUM_SPECIMENS),
|
|
|
196 |
# @idm := @idm+1
|
|
|
197 |
# FROM tb_herbiers.HERBIERS_COLLECTION
|
|
|
198 |
# ORDER BY Id ASC;
|
|
|
199 |
#INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
200 |
# (cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
201 |
# cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
202 |
# SELECT @idm_tmp := @idm_tmp+1, '101', '2', NULL,
|
|
|
203 |
# NOW( ) , CONCAT('Ajout de la collection #',Id,'de la table HERBIER_COLLECTION.') '1', '1', '162.38.234.1';
|
|
|
204 |
# FROM tb.herbiers.HERBIERS_COLLECTION
|
|
|
205 |
# ORDER BY Id ASC;
|
68 |
jpm |
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|