Subversion Repositories eFlore/Applications.coel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
92 jpm 6
SET @idm = 795;# Identifiant pour les métadonnées
56 jpm 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
75 jpm 10
# coel_projet : la table d''historique des lignes
11
DELETE FROM tb_coel.coel_projet WHERE cpr_id_projet IN (2,3);
12
# coel_meta_historique_ligne : la table d''historique des lignes
56 jpm 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);
78 jpm 16
# coel_structure_a_personne
17
DELETE FROM tb_coel.coel_structure_a_personne WHERE csap_id_role IN ('2026', '2027');
18
# coel_personne
19
DELETE FROM tb_coel.coel_personne WHERE cp_ce_projet IN ('2', '3');
75 jpm 20
# coel_personne_a_relation
21
DELETE FROM tb_coel.coel_personne_a_relation WHERE cpar_id_projet = '2';
78 jpm 22
# coel_collection_botanique
23
DELETE FROM tb_coel.coel_collection_botanique WHERE ccb_id_collection IN (SELECT cc_id_collection FROM tb_coel.coel_collection WHERE cc_ce_projet IN ('2'));
24
# coel_collection_a_commentaire
25
DELETE FROM tb_coel.coel_collection_a_commentaire WHERE ccac_id_collection IN (SELECT cc_id_collection FROM tb_coel.coel_collection WHERE cc_ce_projet IN ('2'));
26
# coel_collection
27
DELETE FROM tb_coel.coel_collection WHERE cc_ce_projet IN ('2');
28
# coel_commentaire
29
DELETE FROM tb_coel.coel_commentaire WHERE ccm_ce_projet IN ('2');
56 jpm 30
 
31
#---------------------------------------------------------------------------------------------------------------------#
32
# EFLORE_PROJET vers coel_projet
33
# Insertion du projet Inventaire des Herbiers de France - Version 1
34
INSERT INTO tb_coel.coel_projet (cpr_id_projet, cpr_nom, cpr_abreviation, cpr_description, cpr_url, cpr_ce_meta)
35
	SELECT 2, EPR_INTITULE_PROJET, EPR_ABREVIATION_PROJET, EPR_DESCRIPTION_PROJET, EPR_LIEN_WEB, @idm
36
	FROM tb_herbiers.EFLORE_PROJET;
73 jpm 37
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)
78 jpm 38
	VALUES	(@idm := @idm+1, '115', '2', NULL , NOW( ) , 'Ajout du projet IHF', '1', '1', '162.38.234.1');
73 jpm 39
# Insertion du projet Utilisateur de l''application COEL - Version 1
40
INSERT INTO tb_coel.coel_projet (cpr_id_projet, cpr_nom, cpr_abreviation, cpr_description, cpr_url, cpr_ce_meta)
75 jpm 41
	VALUES (3, 'Utilisateurs', 'U', 'Les utilisateurs de l''application COEL.', NULL, @idm);
73 jpm 42
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)
78 jpm 43
	VALUES	(@idm := @idm+1, '115', '2', NULL , NOW( ) , 'Ajout du projet U', '1', '1', '162.38.234.1');
54 jpm 44
 
73 jpm 45
 
54 jpm 46
#------------------------------------------------------------------------------------------------------------------------
47
# HERBIERS_ORGANISATION vers coel_structure
48
ALTER TABLE tb_herbiers.HERBIERS_ORGANISATION  ORDER BY ID_ORG;# Classement des organisations par ID croissant
56 jpm 49
#ALTER TABLE tb_herbiers.HERBIERS_ORGANISATION  DROP NUM_COLLECTION,  DROP ADRESS_TEXT,  DROP TIME_ZONE ;# Suppression des champs inutiles
54 jpm 50
SET @idm_tmp = @idm;# Identifiant pour les métadonnées temporaire
51
INSERT INTO tb_coel.coel_structure
93 jpm 52
	(cs_id_structure, cs_ce_projet, cs_ce_mere, cs_guid, cs_truk_identifiant_alternatif,
56 jpm 53
	cs_nom, cs_adresse_01, cs_code_postal, cs_ville, cs_region, cs_pays, cs_telephone, cs_fax, cs_courriel,
54
	cs_description,
55
	cs_truk_url,
56
	cs_condition_acces,
57
	cs_ce_meta)
78 jpm 58
	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,
94 jpm 59
		CONVERT(INSTITUTION_NAME USING utf8), CONVERT(ADRESS_LINE USING utf8), ZIP, CONVERT(TOWN USING utf8), CONVERT(REGION USING utf8), IF(COUNTRY_CODE = 'fr', 'France', COUNTRY_CODE) AS PAYS, TEL, FAX, EMAIL,
93 jpm 60
		IF(SOURCE_DES_DONNEES != '', CONVERT(CONCAT("Source des données : ",SOURCE_DES_DONNEES) USING utf8), NULL) AS DESCRIPTION ,
56 jpm 61
		CONCAT(IF(HO_URL != 'http://', CONCAT('WEB#',HO_URL), ''),IF(HO_URL != 'http://' AND LOGO != '', ';', ''), IF(LOGO != '', CONCAT('LOGO#',LOGO),'')) AS URLS,
93 jpm 62
		CONVERT(ACCESS_RESTRICTION USING utf8),
56 jpm 63
		@idm := @idm+1
64
	FROM tb_herbiers.HERBIERS_ORGANISATION
65
	ORDER BY ID_ORG ASC;
66
INSERT INTO tb_coel.coel_meta_historique_ligne
67
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
68
	cmhl_notes,
69
	cmhl_ce_modifier_par, cmhl_ce_etat, cmhl_ip)
78 jpm 70
	SELECT @idm_tmp := @idm_tmp+1, '119', ID_ORG, NULL, IF(DATE_DERNIERE_MODIF = '0000-00-00 00:00:00', NOW(), DATE_DERNIERE_MODIF),
56 jpm 71
		CONCAT('Importation de l''enregistrement #',ID_ORG,' de la table HERBIERS_ORGANISATION.'),
78 jpm 72
		IF(CE_MODIFIER_PAR = '0', '1', CE_MODIFIER_PAR), '1', '162.38.234.1'
56 jpm 73
	FROM tb_herbiers.HERBIERS_ORGANISATION
68 jpm 74
	ORDER BY ID_ORG ASC;
78 jpm 75
 
68 jpm 76
#------------------------------------------------------------------------------------------------------------------------
77
#EFLORE_DROIT_POSSEDER vers coel_personne_a_relation
78
INSERT INTO tb_coel.coel_personne_a_relation
79
	(cpar_id_personne_01, cpar_id_personne_02, cpar_id_projet, cpar_id_role, cpar_ce_meta)
78 jpm 80
	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 81
	FROM tb_herbiers.EFLORE_DROIT_POSSEDER
82
	ORDER BY EDP_ID_UTILISATEUR ASC;
83
INSERT INTO tb_coel.coel_meta_historique_ligne
84
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
85
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
92 jpm 86
	SELECT @idm_tmp := @idm_tmp+1, '114', 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(),
87
	CONCAT('Importation des droits l''utilisateur #',EDP_ID_UTILISATEUR,' de la table EFLORE_DROIT_POSSEDER.'), '1', '1', '162.38.234.1'
68 jpm 88
	FROM tb_herbiers.EFLORE_DROIT_POSSEDER
89
	ORDER BY EDP_ID_UTILISATEUR ASC;
90
 
91
#------------------------------------------------------------------------------------------------------------------------
75 jpm 92
# HERBIERS_COORDONNE vers coel_personne_a_relation
68 jpm 93
INSERT INTO tb_coel.coel_personne_a_relation
94
	(cpar_id_personne_01, cpar_id_personne_02, cpar_id_projet, cpar_id_role, cpar_ce_meta)
78 jpm 95
	SELECT HC_ID_COORDINATEUR, HC_ID_REDACTEUR, '2', '2025', @idm := @idm+1
75 jpm 96
	FROM tb_herbiers.HERBIERS_COORDONNE
68 jpm 97
	ORDER BY HC_ID_COORDINATEUR, HC_ID_REDACTEUR ASC;
98
INSERT INTO tb_coel.coel_meta_historique_ligne
99
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
100
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
78 jpm 101
	SELECT @idm_tmp := @idm_tmp+1, '114', CONCAT(HC_ID_COORDINATEUR, '-', HC_ID_REDACTEUR, '-2-2025'), NULL,
68 jpm 102
		NOW(), CONCAT('Importation des relations de coordination de l''utilisateur #',HC_ID_COORDINATEUR,' de la table HERBIER_COORDONNE.'), '1', '1', '162.38.234.1'
75 jpm 103
	FROM tb_herbiers.HERBIERS_COORDONNE
104
	ORDER BY HC_ID_COORDINATEUR, HC_ID_REDACTEUR ASC;
68 jpm 105
 
106
#------------------------------------------------------------------------------------------------------------------------
83 jpm 107
# EFLORE_DROIT_POSSEDER et annuaire_tela vers coel_personne
73 jpm 108
# Pour l''identifiant on garde celui de l''annuaire Tela. Les autres projets commenceront à partir de 100 000
68 jpm 109
INSERT INTO tb_coel.coel_personne
110
	(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
111
	 cp_adresse_01, cp_adresse_02, cp_region, cp_code_postal, cp_ville, cp_pays,
112
	 cp_truk_courriel, cp_truk_url,
113
	 cp_description,
114
	 cp_ce_truk_role,
73 jpm 115
	 cp_mot_de_passe, cp_login, cp_ce_annuaire_tela, cp_parametre,
68 jpm 116
	 cp_ce_meta)
94 jpm 117
	SELECT U_ID, '3', CONCAT(CONVERT(U_SURNAME USING utf8),' ',UPPER(CONVERT(U_NAME USING utf8))) AS NOM_COMPLET, CONVERT(U_SURNAME USING utf8), UPPER(CONVERT(U_NAME USING utf8)),
93 jpm 118
		   CONVERT(U_ADDR1 USING utf8), CONVERT(U_ADDR2 USING utf8), CONVERT(U_STATE USING utf8), U_ZIP_CODE, CONVERT(U_CITY USING utf8), CONVERT(CP.CP_Intitule_pays USING utf8),
73 jpm 119
		   LOWER(U_MAIL), U_WEB,
94 jpm 120
		   CONCAT('Spécialités systématiques : ', CONVERT(U_SPE USING utf8), '\nSpécialités géographiques : ', CONVERT(U_GEO USING utf8), '\nFonction : ', CONVERT(U_FONCTION USING utf8), '\nStructure : ', CONVERT(U_TITLE USING utf8)),
78 jpm 121
		   IF(EDP_ID_DROIT = '1', '2022', IF(EDP_ID_DROIT = '2', '2023', IF(EDP_ID_DROIT = '3', '2024', 0))),
73 jpm 122
		   U_PASSWD, U_MAIL, U_ID, CONCAT('<?xml version="1.0" encoding="UTF-8"><parametres><niveau_bota>', U_NIV,'</niveau_bota></parametres>'),
68 jpm 123
		   @idm := @idm+1
83 jpm 124
	FROM tb_herbiers.EFLORE_DROIT_POSSEDER AS EDP
125
		LEFT JOIN tb_v4.annuaire_tela AS AT ON (EDP.EDP_ID_UTILISATEUR = AT.U_ID)
126
		LEFT JOIN tb_v4.carto_PAYS AS CP ON (AT.U_COUNTRY = CP.CP_ID_Pays)
68 jpm 127
	ORDER BY U_ID ASC;
128
INSERT INTO tb_coel.coel_meta_historique_ligne
129
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
130
	cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
78 jpm 131
	SELECT @idm_tmp := @idm_tmp+1, '113', U_ID, NULL, U_DATE,
92 jpm 132
		CONCAT('Importation de l''utilisateur #', U_ID,' de la table annuaire_tela liée à EFLORE_DROIT_POSSEDER.'), '1', '1', '162.38.234.1'
83 jpm 133
	FROM tb_herbiers.EFLORE_DROIT_POSSEDER AS EDP
134
		LEFT JOIN tb_v4.annuaire_tela AS AT ON (EDP.EDP_ID_UTILISATEUR = AT.U_ID)
68 jpm 135
	ORDER BY U_ID ASC;
136
 
83 jpm 137
#------------------------------------------------------------------------------------------------------------------------
138
# HERBIERS_ADMINISTRER et annuaire_tela vers coel_personne
139
# Pour l''identifiant on garde celui de l''annuaire Tela. Les autres projets commenceront à partir de 100 000
92 jpm 140
INSERT INTO tb_coel.coel_personne
83 jpm 141
	(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
142
	 cp_adresse_01, cp_adresse_02, cp_region, cp_code_postal, cp_ville, cp_pays,
143
	 cp_truk_courriel, cp_truk_url,
144
	 cp_description,
145
	 cp_mot_de_passe, cp_login, cp_ce_annuaire_tela, cp_parametre,
146
	 cp_ce_meta)
94 jpm 147
	SELECT DISTINCT U_ID, '3', CONCAT(CONVERT(U_SURNAME USING utf8),' ',UPPER(CONVERT(U_NAME USING utf8))) AS NOM_COMPLET, CONVERT(U_SURNAME USING utf8), UPPER(CONVERT(U_NAME USING utf8)),
93 jpm 148
		   CONVERT(U_ADDR1 USING utf8), CONVERT(U_ADDR2 USING utf8), CONVERT(U_STATE USING utf8), U_ZIP_CODE, CONVERT(U_CITY USING utf8), CONVERT(CP.CP_Intitule_pays USING utf8),
83 jpm 149
		   LOWER(U_MAIL), U_WEB,
94 jpm 150
		   CONCAT('Spécialités systématiques : ', CONVERT(U_SPE USING utf8), '\nSpécialités géographiques : ', CONVERT(U_GEO USING utf8), '\nFonction : ', CONVERT(U_FONCTION USING utf8), '\nStructure : ', CONVERT(U_TITLE USING utf8)),
83 jpm 151
		   U_PASSWD, U_MAIL, U_ID, CONCAT('<?xml version="1.0" encoding="UTF-8"><parametres><niveau_bota>', U_NIV,'</niveau_bota></parametres>'),
152
		   @idm := @idm+1
153
	FROM tb_herbiers.HERBIERS_ADMINISTRER AS HA
154
		LEFT JOIN tb_v4.annuaire_tela AS AT ON (HA.HA_ID_ANNUAIRE = AT.U_ID)
155
		LEFT JOIN tb_v4.carto_PAYS AS CP ON (AT.U_COUNTRY = CP.CP_ID_Pays)
92 jpm 156
	WHERE U_ID NOT IN (SELECT DISTINCT EDP_ID_UTILISATEUR FROM tb_herbiers.EFLORE_DROIT_POSSEDER)
83 jpm 157
	ORDER BY U_ID ASC;
158
INSERT INTO tb_coel.coel_meta_historique_ligne
159
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
160
	cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
161
	SELECT DISTINCT @idm_tmp := @idm_tmp+1, '113', U_ID, NULL, U_DATE,
92 jpm 162
		CONCAT('Importation de l''utilisateur #', U_ID,' de la table annuaire_tela liée à HERBIERS_ADMINISTRER.'), '1', '1', '162.38.234.1'
163
	FROM tb_herbiers.HERBIERS_ADMINISTRER AS HA
164
		LEFT JOIN tb_v4.annuaire_tela AS AT ON (HA.HA_ID_ANNUAIRE = AT.U_ID)
165
	WHERE U_ID NOT IN (SELECT DISTINCT EDP_ID_UTILISATEUR FROM tb_herbiers.EFLORE_DROIT_POSSEDER)
83 jpm 166
	ORDER BY U_ID ASC;
167
 
68 jpm 168
#------------------------------------------------------------------------------------------------------------------------
75 jpm 169
# HERBIERS_ADMINISTRER vers coel_structure_a_personne
68 jpm 170
INSERT INTO tb_coel.coel_structure_a_personne
171
	(csap_id_structure, csap_id_personne, csap_id_role, csap_ce_meta)
172
	SELECT HA_ID_ORG, HA_ID_ANNUAIRE, '2026', @idm := @idm+1
75 jpm 173
	FROM tb_herbiers.HERBIERS_ADMINISTRER
68 jpm 174
	ORDER BY HA_ID_ANNUAIRE, HA_ID_ORG 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)
78 jpm 178
	SELECT @idm_tmp := @idm_tmp+1, '120', CONCAT(HA_ID_ORG, '-', HA_ID_ANNUAIRE, '-2026'), NULL,
83 jpm 179
		NOW(), CONCAT('Importation de l''administrateur #',HA_ID_ANNUAIRE,' de la structure #', HA_ID_ORG,' de la table HERBIER_ADMINISTRER.'), '1', '1', '162.38.234.1'
75 jpm 180
	FROM tb_herbiers.HERBIERS_ADMINISTRER
68 jpm 181
	ORDER BY HA_ID_ANNUAIRE, HA_ID_ORG ASC;
73 jpm 182
 
183
 
184
#------------------------------------------------------------------------------------------------------------------------
185
#HERBIERS_STAFF vers coel_personne
186
INSERT INTO tb_coel.coel_personne
187
	(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,
188
	cp_truk_telephone, cp_truk_fax, cp_ce_meta)
94 jpm 189
	SELECT 100000+ID_STAFF, '2', CONCAT(CONVERT(PRENOM USING utf8),' ', UPPER(CONVERT(NOM USING utf8))) AS NOM_COMPLET, UPPER(CONVERT(NOM USING utf8)), CONVERT(PRENOM USING utf8), CONVERT(ADRESSE1 USING utf8), CONVERT(ADRESSE2 USING utf8), CP, CONVERT(VILLE USING utf8), LOWER(MAIL),
75 jpm 190
		   IF(TEL != '', CONCAT('+33', TRIM(LEADING '0' FROM REPLACE(TEL,'[33]',''))), NULL), IF(FAX != '', CONCAT('+33', TRIM(LEADING '0' FROM REPLACE(FAX,'[33]',''))), NULL), @idm := @idm+1
73 jpm 191
	FROM tb_herbiers.HERBIERS_STAFF
192
	ORDER BY ID_STAFF ASC;
75 jpm 193
INSERT INTO tb_coel.coel_meta_historique_ligne
73 jpm 194
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
195
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
81 jpm 196
	SELECT @idm_tmp := @idm_tmp+1, '113', 100000+ID_STAFF, NULL, IF(DATE_DERNIERE_MODIF != '0000-00-00 00:00:00', DATE_DERNIERE_MODIF, NOW()),
92 jpm 197
		CONCAT('Importation de l''utilisateur #', 100000+ID_STAFF,' de la table HERBIERS_STAFF'), '1', '1', '162.38.234.1'
73 jpm 198
	FROM tb_herbiers.HERBIERS_STAFF
199
	ORDER BY ID_STAFF ASC;
68 jpm 200
 
75 jpm 201
UPDATE tb_coel.coel_personne SET cp_truk_telephone = REPLACE(cp_truk_telephone, '.', '') WHERE cp_truk_telephone LIKE '%.%';
202
UPDATE tb_coel.coel_personne SET cp_truk_telephone = REPLACE(cp_truk_telephone, ' ', '') WHERE cp_truk_telephone LIKE '% %';
203
UPDATE tb_coel.coel_personne SET cp_truk_telephone = REPLACE(cp_truk_telephone, '+33(0)', '') WHERE cp_truk_telephone LIKE '%+33(0)%';
204
UPDATE tb_coel.coel_personne SET cp_truk_telephone = IF(cp_truk_telephone LIKE '%;%', REPLACE(cp_truk_telephone, ';0', '; +33'),cp_truk_telephone);
205
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));
206
UPDATE tb_coel.coel_personne SET cp_truk_telephone = IF(cp_truk_telephone LIKE '%+330%', REPLACE(cp_truk_telephone, '+330', '+33'),cp_truk_telephone);
207
UPDATE tb_coel.coel_personne SET cp_truk_telephone = IF(cp_truk_telephone LIKE '%; +336%', REPLACE(cp_truk_telephone, '; +33', '; GSM#+33'), REPLACE(cp_truk_telephone, '; +33', '; FIX#+33')) WHERE cp_truk_telephone LIKE '%;%';
208
 
209
UPDATE tb_coel.coel_personne SET cp_truk_fax = REPLACE(cp_truk_fax, '.', '') WHERE cp_truk_fax LIKE '%.%';
210
UPDATE tb_coel.coel_personne SET cp_truk_fax = REPLACE(cp_truk_fax, '+33 (0)', '') WHERE cp_truk_fax LIKE '%+33 (0)%';
211
UPDATE tb_coel.coel_personne SET cp_truk_fax = REPLACE(cp_truk_fax, ' ', '') WHERE cp_truk_fax LIKE '% %';
212
UPDATE tb_coel.coel_personne SET cp_truk_fax = IF(cp_truk_fax LIKE '%+330%', REPLACE(cp_truk_fax, '+330', '+33'),cp_truk_fax);
213
 
83 jpm 214
ALTER TABLE tb_coel.coel_personne  ORDER BY cp_id_personne;
75 jpm 215
 
68 jpm 216
#------------------------------------------------------------------------------------------------------------------------
73 jpm 217
# HERBIERS_ont_un_staff vers coel_structure_a_personne
218
INSERT INTO tb_coel.coel_structure_a_personne
219
	(csap_id_structure, csap_id_personne, csap_id_role, csap_mark_contact, csap_ce_truk_fonction, csap_ce_meta)
93 jpm 220
	SELECT ID_ORG, 100000+hous.ID_STAFF, '2027', IF(LOWER(CONTACT) = 'oui', 1, 0) AS CONTACT, IF(FONCTION != '', CONCAT('AUTRE#', CONVERT(FONCTION USING utf8)), NULL) AS FONCTION, @idm := @idm+1
73 jpm 221
	FROM tb_herbiers.HERBIERS_ont_un_staff AS hous LEFT JOIN tb_herbiers.HERBIERS_STAFF AS hs ON (hous.ID_STAFF = hs.ID_STAFF)
222
	WHERE hous.ID_ORG != 0
223
	ORDER BY hous.ID_ORG, hous.ID_STAFF ASC;
224
INSERT INTO tb_coel.coel_meta_historique_ligne
225
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
226
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
92 jpm 227
	SELECT @idm_tmp := @idm_tmp+1, '120', CONCAT(ID_ORG, '-', 100000+ID_STAFF, '-2027'), NULL,
228
		NOW(), CONCAT('Importation de la personne #',100000+ID_STAFF,' de la structure #', ID_ORG,' de la table HERBIERS_ont_un_staff.'), '1', '1', '162.38.234.1'
73 jpm 229
	FROM tb_herbiers.HERBIERS_ont_un_staff
75 jpm 230
	WHERE ID_ORG != 0
73 jpm 231
	ORDER BY ID_ORG, ID_STAFF ASC;
232
 
75 jpm 233
UPDATE tb_coel.coel_structure_a_personne
234
SET csap_ce_truk_fonction = IF(csap_ce_truk_fonction IS NOT NULL, IF(csap_ce_truk_fonction LIKE '%irecteur%', '2028',
235
	IF(csap_ce_truk_fonction LIKE '%onservateur%', '2029', IF(csap_ce_truk_fonction LIKE '%echnicien%', '2030', csap_ce_truk_fonction))), NULL)
236
WHERE csap_id_role = '2027'	;
237
 
73 jpm 238
 
239
#------------------------------------------------------------------------------------------------------------------------
68 jpm 240
#HERBIER_COLLECTION vers coel_collection
75 jpm 241
INSERT INTO tb_coel.coel_collection
242
	(cc_id_collection, cc_ce_projet, cc_ce_structure, cc_guid, cc_truk_code, cc_nom, cc_description, cc_truk_type_depot, cc_ce_specimen_type,
78 jpm 243
	 cc_description_specialiste, cc_truk_url,
75 jpm 244
	 cc_specimen_type_nbre,
78 jpm 245
	 cc_truk_preservation,
75 jpm 246
    cc_ce_meta)
93 jpm 247
	SELECT hc.ID, '2', PARENT_ID, CONCAT("URN:tela-botanica.org:ihf:col",hc.ID) AS GUID, COLLECTION_CODE, CONVERT(NOM_COLLECTION USING utf8), CONVERT(DESCRIPTION USING utf8), CONVERT(STATUT USING utf8), IF(INCLUDED_TYPE = '0', '2239', IF (INCLUDED_TYPE = '1', '2242', IF (INCLUDED_TYPE = '2', '2241', NULL))) AS INCLUDED_TYPE,
94 jpm 248
	   CONCAT(IF(DOC_STATE = '', '', IF(DOC_STATE IS NULL, '', CONCAT('Etat documentation : \n', CONVERT(DOC_STATE USING utf8)))),IF(COLLECTEURS = '', '', IF(COLLECTEURS IS NULL, '', CONCAT('\nCollecteurs : \n', CONVERT(COLLECTEURS USING utf8))))) AS DESCRIPTION_SPECIALISTE, IF(URL = '', NULL, URL) AS URL,
75 jpm 249
	   NUM_SPECIMENS,
78 jpm 250
	   CAST(GROUP_CONCAT(DISTINCT CASE ID_PRES WHEN '1' THEN '2204' WHEN '2' THEN '2222' WHEN '3' THEN '2215' WHEN '4' THEN '2203' WHEN '5' THEN '2211' WHEN '6' THEN '2223' WHEN '7' THEN '2207' WHEN '8' THEN '2209' WHEN '9' THEN '2224' WHEN '10' THEN '2218' WHEN '12' THEN '2212' WHEN '13' THEN 'AUTRE#non précisé' ELSE ID_PRES END SEPARATOR ";") AS CHAR)  AS PRESENTATION,
75 jpm 251
	   @idm := @idm+1
78 jpm 252
	FROM tb_herbiers.HERBIERS_COLLECTION AS hc LEFT JOIN tb_herbiers.HERBIERS_ont_pres AS hop ON (hc.ID = hop.ID)
92 jpm 253
	WHERE hc.ID != 4
78 jpm 254
	GROUP BY hc.ID
255
	ORDER BY hc.ID ASC;
75 jpm 256
INSERT INTO tb_coel.coel_collection_botanique
257
	(ccb_id_collection, ccb_truk_unite_base,
258
	ccb_recolte_date_debut, ccb_ce_recolte_date_debut_type, ccb_recolte_date_fin, ccb_ce_recolte_date_fin_type,
259
	ccb_inventaire_digital_pourcent, ccb_ce_classement_etat,
260
	ccb_truk_degradation_specimen,
261
	ccb_truk_degradation_presentation,
262
	ccb_annotation_classement)
263
	SELECT ID, CONCAT('TOTAL#0|NULL|NULL|',NUM_SPECIMENS,'|', IF(PREC_SPECIMENS = '1', '0', IF(PREC_SPECIMENS = '2', '1', IF(PREC_SPECIMENS = '3', '?', 'NULL'))), '|', NUM_SPECIES, '|', IF(PREC_SPECIES = '1', '0', IF(PREC_SPECIES = '2', '1', IF(PREC_SPECIES = '3', '?', 'NULL')))),
78 jpm 264
		DATE_DEBUT, IF(DATE_DEBUT_CARAC = '1', '2316', IF (DATE_DEBUT_CARAC = '2', '2317', IF (DATE_DEBUT_CARAC = '3', '2318', IF(DATE_DEBUT_CARAC = '4', '2319', IF (DATE_DEBUT_CARAC = '5', '2320', NULL))))),
265
		DATE_FIN, IF( DATE_FIN_CARAC = '1', '2321', IF (DATE_FIN_CARAC = '2', '2322', IF(DATE_FIN_CARAC = '3', '2323', IF (DATE_FIN_CARAC = '4', '2325', IF(DATE_FIN_CARAC = '5', '2324', IF (DATE_FIN_CARAC = '6', '2326', NULL)))))),
266
		PERCENT_DATABASED, IF(ETAT_CLASSEMENT = 1, '2328', IF(ETAT_CLASSEMENT = 2, '2329', IF(ETAT_CLASSEMENT = 3, '2330', IF(ETAT_CLASSEMENT = 4, '2331', NULL)))),
267
		CONCAT('TOTAL#',IF(ETAT_SPECIMENS = 1, '2328', IF(ETAT_SPECIMENS = 2, '2329', IF(ETAT_SPECIMENS = 3, '2330', IF(ETAT_SPECIMENS = 4, '2331', NULL))))),
268
		CONCAT('TOTAL#',IF(ETAT_PRESENTATION = 1, '2328', IF(ETAT_PRESENTATION = 2, '2329', IF(ETAT_PRESENTATION = 3, '2330', IF(ETAT_PRESENTATION = 4, '2331', NULL))))),
93 jpm 269
		IF(MODE_CLASSEMENT IS NOT NULL, IF(MODE_CLASSEMENT != '', CONVERT(MODE_CLASSEMENT USING utf8), NULL), NULL)
92 jpm 270
	FROM tb_herbiers.HERBIERS_COLLECTION
271
	WHERE ID != 4
75 jpm 272
	ORDER BY ID ASC;
273
INSERT INTO tb_coel.coel_meta_historique_ligne
274
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
275
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat, cmhl_ip)
276
	SELECT @idm_tmp := @idm_tmp+1, '101', ID, NULL,
78 jpm 277
		IF(DATE_DERNIERE_MODIF != '0000-00-00 00:00:00', DATE_DERNIERE_MODIF, NOW()) , CONCAT('Ajout de la collection #',ID,' de la table HERBIER_COLLECTION.'), IF(CE_MODIFIER_PAR != '0', CE_MODIFIER_PAR, '1'), '1', IF(CE_MODIFIER_PAR != '0', NULL, '162.38.234.1')
278
	FROM tb_herbiers.HERBIERS_COLLECTION
92 jpm 279
	WHERE ID != 4
78 jpm 280
	ORDER BY ID ASC;
281
 
75 jpm 282
#------------------------------------------------------------------------------------------------------------------------
78 jpm 283
#HERBIERS_INDIC vers coel_commentaires
284
INSERT INTO tb_coel.coel_commentaire
285
	(ccm_id_commentaire, ccm_ce_projet, ccm_titre,
286
	ccm_texte, ccm_ponderation, ccm_ce_meta)
94 jpm 287
	SELECT ID_INDIC, '2', IF(REM_INDIC IS NOT NULL, IF(REM_INDIC != '', CONVERT(REM_INDIC USING utf8), CONCAT(SUBSTRING(REPLACE(REPLACE(CONVERT(TXT_INDIC USING utf8),'<i>',''),'</i>',''), 1, 50),'...')),  CONCAT(SUBSTRING(REPLACE(REPLACE(CONVERT(TXT_INDIC USING utf8),'<i>',''),'</i>',''), 1, 50),'...')) AS TITRE,
288
		CONVERT(TXT_INDIC USING utf8), 0, @idm := @idm+1
78 jpm 289
	FROM tb_herbiers.HERBIERS_INDIC
290
	ORDER BY ID_INDIC ASC;
291
INSERT INTO tb_coel.coel_meta_historique_ligne
292
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
293
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat, cmhl_ip)
294
	SELECT @idm_tmp := @idm_tmp+1, '107', hi.ID_INDIC, NULL,
295
		FROM_UNIXTIME(MAJ_INDIC) , CONCAT('Ajout du commentaire #',hi.ID_INDIC,' de la table HERBIER_INDIC.'), IF(ID_INDICATEUR != '0', ID_INDICATEUR, '1'), '1', IF(ID_INDICATEUR != '0', NULL, '162.38.234.1')
296
	FROM tb_herbiers.HERBIERS_INDIC AS hi LEFT JOIN tb_herbiers.HERBIERS_INDIC_HISTORIQUE AS hih ON (hi.ID_INDIC = hih.ID_INDIC)
297
	ORDER BY hi.ID_INDIC ASC;
68 jpm 298
 
78 jpm 299
#------------------------------------------------------------------------------------------------------------------------
79 jpm 300
# HERBIERS_A_UN_TYPE vers coel_collection_a_commentaire
78 jpm 301
INSERT INTO tb_coel.coel_collection_a_commentaire
302
	(ccac_id_collection, ccac_id_commentaire,
303
	ccac_truk_type,
304
	ccac_ce_meta)
305
	SELECT hi.ID_INDIC, ID,
306
		CAST(GROUP_CONCAT(DISTINCT CASE ID_TYPE WHEN '1' THEN '2368' WHEN '2' THEN '2369' WHEN '3' THEN '2370' WHEN '4' THEN '2371' WHEN '5' THEN '2372' WHEN '6' THEN '2373' ELSE NULL END SEPARATOR ";") AS CHAR)  AS TYPE,
307
		@idm := @idm+1
87 jpm 308
	FROM tb_herbiers.HERBIERS_INDIC AS hi LEFT JOIN tb_herbiers.HERBIERS_A_UN_TYPE AS haut ON (hi.ID_INDIC = haut.ID_INDIC)
309
	WHERE ID IN (SELECT ccm_id_commentaire FROM tb_coel.coel_commentaire)
78 jpm 310
	GROUP BY hi.ID_INDIC
311
	ORDER BY hi.ID_INDIC ASC;
312
INSERT INTO tb_coel.coel_meta_historique_ligne
313
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
314
	cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat, cmhl_ip)
315
	SELECT @idm_tmp := @idm_tmp+1, '102', hi.ID_INDIC, NULL,
316
		FROM_UNIXTIME(MAJ_INDIC) , CONCAT('Ajout des types du commentaire #',hi.ID_INDIC,' de la table HERBIERS_A_UN_TYPE.'), IF(ID_INDICATEUR != '0', ID_INDICATEUR, '1'), '1', IF(ID_INDICATEUR != '0', NULL, '162.38.234.1')
87 jpm 317
	FROM tb_herbiers.HERBIERS_INDIC AS hi LEFT JOIN tb_herbiers.HERBIERS_A_UN_TYPE AS haut ON (hi.ID_INDIC = haut.ID_INDIC) LEFT JOIN tb_herbiers.HERBIERS_INDIC_HISTORIQUE AS hih ON (hi.ID_INDIC = hih.ID_INDIC)
318
	WHERE ID IN (SELECT ccm_id_commentaire FROM tb_coel.coel_commentaire)
78 jpm 319
	GROUP BY hi.ID_INDIC
320
	ORDER BY hi.ID_INDIC ASC;
321
 
79 jpm 322
#------------------------------------------------------------------------------------------------------------------------
83 jpm 323
# Mise à jour des id de personne inexistant dans l''annuaire Tela
324
# dans la table : coel_meta_historique_ligne
325
INSERT IGNORE INTO tb_coel.coel_personne
326
	(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
327
	 cp_description, cp_ce_annuaire_tela,
328
	 cp_ce_meta)
329
	SELECT DISTINCT cmhl_ce_modifier_par, '3', CONCAT('Inconnu #', cmhl_ce_modifier_par) AS NOM_COMPLET, 'Inconnu', 'INCONNU',
330
		   'Individu non présent dans l''annuaire Tela Botanica.', cmhl_ce_modifier_par,
331
		   @idm := @idm+1
332
	FROM tb_coel.coel_meta_historique_ligne
333
	WHERE cmhl_ce_modifier_par NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
334
	ORDER BY cmhl_ce_modifier_par ASC;
335
INSERT IGNORE INTO tb_coel.coel_meta_historique_ligne
336
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
337
	cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
338
	SELECT DISTINCT @idm_tmp := @idm_tmp+1, '113', cmhl_ce_modifier_par, NULL, NOW(),
339
		CONCAT('Création de l''utilisateur inconnu #', cmhl_ce_modifier_par,' non présent la table annuaire_tela.'), '1', '1', '162.38.234.1'
340
	FROM tb_coel.coel_meta_historique_ligne
341
	WHERE cmhl_ce_modifier_par NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
342
	ORDER BY cmhl_ce_modifier_par ASC;
343
# dans la table : coel_structure_a_personne
344
INSERT IGNORE INTO tb_coel.coel_personne
345
	(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
346
	 cp_description, cp_ce_annuaire_tela,
347
	 cp_ce_meta)
348
	SELECT DISTINCT csap_id_personne, '3', CONCAT('Inconnu #', csap_id_personne) AS NOM_COMPLET, 'Inconnu', 'INCONNU',
349
		   'Individu non présent dans l''annuaire Tela Botanica.', csap_id_personne,
350
		   @idm := @idm+1
351
	FROM tb_coel.coel_structure_a_personne
352
	WHERE csap_id_personne NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
353
	ORDER BY csap_id_personne ASC;
354
INSERT IGNORE INTO tb_coel.coel_meta_historique_ligne
355
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
356
	cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
357
	SELECT DISTINCT @idm_tmp := @idm_tmp+1, '113', csap_id_personne, NULL, NOW(),
358
		CONCAT('Création de l''utilisateur inconnu #', csap_id_personne,' non présent la table annuaire_tela.'), '1', '1', '162.38.234.1'
359
	FROM tb_coel.coel_structure_a_personne
360
	WHERE csap_id_personne NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
361
	ORDER BY csap_id_personne ASC;
362
# dans la table : coel_personne_a_relation
363
INSERT IGNORE INTO tb_coel.coel_personne
364
	(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
365
	 cp_description, cp_ce_annuaire_tela,
366
	 cp_ce_meta)
367
	SELECT DISTINCT cpar_id_personne_01, '3', CONCAT('Inconnu #', cpar_id_personne_01) AS NOM_COMPLET, 'Inconnu', 'INCONNU',
368
		   'Individu non présent dans l''annuaire Tela Botanica.', cpar_id_personne_01,
369
		   @idm := @idm+1
370
	FROM tb_coel.coel_personne_a_relation
371
	WHERE cpar_id_personne_01 NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
372
	ORDER BY cpar_id_personne_01 ASC;
373
INSERT IGNORE INTO tb_coel.coel_meta_historique_ligne
374
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
375
	cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
376
	SELECT DISTINCT @idm_tmp := @idm_tmp+1, '113', cpar_id_personne_01, NULL, NOW(),
377
		CONCAT('Création de l''utilisateur inconnu #', cpar_id_personne_01,' non présent la table annuaire_tela.'), '1', '1', '162.38.234.1'
378
	FROM tb_coel.coel_personne_a_relation
379
	WHERE cpar_id_personne_01 NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
380
	ORDER BY cpar_id_personne_01 ASC;
381
INSERT IGNORE INTO tb_coel.coel_personne
382
	(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
383
	 cp_description, cp_ce_annuaire_tela,
384
	 cp_ce_meta)
385
	SELECT DISTINCT cpar_id_personne_02, '3', CONCAT('Inconnu #', cpar_id_personne_02) AS NOM_COMPLET, 'Inconnu', 'INCONNU',
386
		   'Individu non présent dans l''annuaire Tela Botanica.', cpar_id_personne_02,
387
		   @idm := @idm+1
388
	FROM tb_coel.coel_personne_a_relation
389
	WHERE cpar_id_personne_02 NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
390
	ORDER BY cpar_id_personne_02 ASC;
391
INSERT IGNORE INTO tb_coel.coel_meta_historique_ligne
392
	(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
393
	cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
394
	SELECT DISTINCT @idm_tmp := @idm_tmp+1, '113', cpar_id_personne_02, NULL, NOW(),
395
		CONCAT('Création de l''utilisateur inconnu #', cpar_id_personne_02,' non présent la table annuaire_tela.'), '1', '1', '162.38.234.1'
396
	FROM tb_coel.coel_personne_a_relation
397
	WHERE cpar_id_personne_02 NOT IN (SELECT U_ID FROM tb_v4.annuaire_tela)
398
	ORDER BY cpar_id_personne_02 ASC;