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;
|
|
|
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) VALUES
|
68 |
jpm |
24 |
(@idm := @idm+1, '113', '2', NULL , NOW( ) , 'Ajout du projet IHF', '1', '1', '162.38.234.1');
|
54 |
jpm |
25 |
|
|
|
26 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
27 |
# HERBIERS_ORGANISATION vers coel_structure
|
|
|
28 |
ALTER TABLE tb_herbiers.HERBIERS_ORGANISATION ORDER BY ID_ORG;# Classement des organisations par ID croissant
|
56 |
jpm |
29 |
#ALTER TABLE tb_herbiers.HERBIERS_ORGANISATION DROP NUM_COLLECTION, DROP ADRESS_TEXT, DROP TIME_ZONE ;# Suppression des champs inutiles
|
54 |
jpm |
30 |
SET @idm_tmp = @idm;# Identifiant pour les métadonnées temporaire
|
|
|
31 |
INSERT INTO tb_coel.coel_structure
|
56 |
jpm |
32 |
(cs_id_structure, cs_ce_projet, cs_ce_mere, cs_truk_identifiant_alternatif, cs_guid,
|
|
|
33 |
cs_nom, cs_adresse_01, cs_code_postal, cs_ville, cs_region, cs_pays, cs_telephone, cs_fax, cs_courriel,
|
|
|
34 |
cs_description,
|
|
|
35 |
cs_truk_url,
|
|
|
36 |
cs_condition_acces,
|
|
|
37 |
cs_ce_meta)
|
|
|
38 |
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,
|
|
|
39 |
INSTITUTION_NAME, ADRESS_LINE, ZIP, TOWN, REGION, IF(COUNTRY_CODE = 'fr', 'France', COUNTRY_CODE) AS PAYS, TEL, FAX, EMAIL,
|
|
|
40 |
IF(SOURCE_DES_DONNEES != '', CONCAT("Source des données : ",SOURCE_DES_DONNEES), NULL) AS DESCRIPTION,
|
|
|
41 |
CONCAT(IF(HO_URL != 'http://', CONCAT('WEB#',HO_URL), ''),IF(HO_URL != 'http://' AND LOGO != '', ';', ''), IF(LOGO != '', CONCAT('LOGO#',LOGO),'')) AS URLS,
|
|
|
42 |
ACCESS_RESTRICTION,
|
|
|
43 |
@idm := @idm+1
|
|
|
44 |
FROM tb_herbiers.HERBIERS_ORGANISATION
|
|
|
45 |
ORDER BY ID_ORG ASC;
|
|
|
46 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
47 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
|
|
|
48 |
cmhl_notes,
|
|
|
49 |
cmhl_ce_modifier_par, cmhl_ce_etat, cmhl_ip)
|
|
|
50 |
SELECT @idm_tmp := @idm_tmp+1, 117, ID_ORG, NULL, IF(DATE_DERNIERE_MODIF = '0000-00-00 00:00:00', NOW(), DATE_DERNIERE_MODIF),
|
|
|
51 |
CONCAT('Importation de l''enregistrement #',ID_ORG,' de la table HERBIERS_ORGANISATION.'),
|
|
|
52 |
IF(CE_MODIFIER_PAR = '0', 1, CE_MODIFIER_PAR), '1', '162.38.234.1'
|
|
|
53 |
FROM tb_herbiers.HERBIERS_ORGANISATION
|
68 |
jpm |
54 |
ORDER BY ID_ORG ASC;
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
65 |
#EFLORE_DROIT_POSSEDER vers coel_personne_a_relation
|
|
|
66 |
INSERT INTO tb_coel.coel_personne_a_relation
|
|
|
67 |
(cpar_id_personne_01, cpar_id_personne_02, cpar_id_projet, cpar_id_role, cpar_ce_meta)
|
|
|
68 |
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
|
|
|
69 |
FROM tb_herbiers.EFLORE_DROIT_POSSEDER
|
|
|
70 |
ORDER BY EDP_ID_UTILISATEUR ASC;
|
|
|
71 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
72 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
73 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
74 |
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'
|
|
|
75 |
FROM tb_herbiers.EFLORE_DROIT_POSSEDER
|
|
|
76 |
ORDER BY EDP_ID_UTILISATEUR ASC;
|
|
|
77 |
|
|
|
78 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
79 |
# HERBIER_COORDONNE vers coel_personne_a_relation
|
|
|
80 |
INSERT INTO tb_coel.coel_personne_a_relation
|
|
|
81 |
(cpar_id_personne_01, cpar_id_personne_02, cpar_id_projet, cpar_id_role, cpar_ce_meta)
|
|
|
82 |
SELECT HC_ID_COORDINATEUR, HC_ID_REDACTEUR, 2, 2025, @idm := @idm+1
|
|
|
83 |
FROM tb_herbiers.HERBIER_COORDONNE
|
|
|
84 |
ORDER BY HC_ID_COORDINATEUR, HC_ID_REDACTEUR ASC;
|
|
|
85 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
86 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
87 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
88 |
SELECT @idm_tmp := @idm_tmp+1, 112, CONCAT(HC_ID_COORDINATEUR, '-', HC_ID_REDACTEUR, '-2-2025'), NULL,
|
|
|
89 |
NOW(), CONCAT('Importation des relations de coordination de l''utilisateur #',HC_ID_COORDINATEUR,' de la table HERBIER_COORDONNE.'), '1', '1', '162.38.234.1'
|
|
|
90 |
FROM tb_herbiers.EFLORE_DROIT_POSSEDER
|
|
|
91 |
ORDER BY EDP_ID_UTILISATEUR ASC;
|
|
|
92 |
|
|
|
93 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
94 |
#annuaire_tela vers coel_personne
|
|
|
95 |
INSERT INTO tb_coel.coel_personne
|
|
|
96 |
(cp_id_personne, cp_ce_projet, cp_fmt_nom_complet, cp_prenom, cp_nom,
|
|
|
97 |
cp_adresse_01, cp_adresse_02, cp_region, cp_code_postal, cp_ville, cp_pays,
|
|
|
98 |
cp_truk_courriel, cp_truk_url,
|
|
|
99 |
cp_description,
|
|
|
100 |
cp_ce_truk_role,
|
|
|
101 |
cp_mot_de_passe, cp_login, cp_parametre,
|
|
|
102 |
cp_ce_meta)
|
|
|
103 |
SELECT U_ID, 2, CONCAT(U_SURNAME,'',U_NAME) AS NOM_COMPLET, U_SURNAME, U_NAME,
|
|
|
104 |
U_ADDR1, U_ADDR2, U_STATE, U_ZIP_CODE, U_CITY, CP.CP_Intitule_pays,
|
|
|
105 |
U_MAIL, U_WEB,
|
|
|
106 |
CONCAT('Spécialités systématiques : ', U_SPE, '\nSpécialités géographiques : ', U_GEO, '\nFonction : ', U_FONCTION, '\nStructure : ', U_TITLE),
|
|
|
107 |
IF(EDP_ID_DROIT = '1', 2022, IF(EDP_ID_DROIT = '2', 2023, IF(EDP_ID_DROIT = '3', 2024, 0))),
|
|
|
108 |
U_PASSWD, U_MAIL, CONCAT('<?xml version="1.0" encoding="UTF-8"><parametres><niveau_bota>', U_NIV,'</niveau_bota></parametres>'),
|
|
|
109 |
@idm := @idm+1
|
|
|
110 |
FROM tela_prod_v4.annuaire_tela AS AT, tb_herbiers.EFLORE_DROIT_POSSEDER AS EDP, tela_prod_v4.carto_PAYS AS CP
|
|
|
111 |
WHERE AT.U_ID = EDP.EDP_ID_UTILISATEUR
|
|
|
112 |
AND CP.CP_ID_Pays = AT.U_COUNTRY
|
|
|
113 |
ORDER BY U_ID ASC;
|
|
|
114 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
115 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement, cmhl_date_modification,
|
|
|
116 |
cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
117 |
SELECT @idm_tmp := @idm_tmp+1, '111', U_ID, NULL, U_DATE,
|
|
|
118 |
CONCAT('Importation de l''utilisateur #', U_ID,' de la table annuaire_tela.'), '1', '1', '162.38.234.1'
|
|
|
119 |
FROM tela_prod_v4.annuaire_tela AS AT, tb_herbiers.EFLORE_DROIT_POSSEDER AS EDP
|
|
|
120 |
WHERE AT.U_ID = EDP.EDP_ID_UTILISATEUR
|
|
|
121 |
ORDER BY U_ID ASC;
|
|
|
122 |
|
|
|
123 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
124 |
# HERBIER_ADMINISTRER vers coel_structure_a_personne
|
|
|
125 |
INSERT INTO tb_coel.coel_structure_a_personne
|
|
|
126 |
(csap_id_structure, csap_id_personne, csap_id_role, csap_ce_meta)
|
|
|
127 |
SELECT HA_ID_ORG, HA_ID_ANNUAIRE, '2026', @idm := @idm+1
|
|
|
128 |
FROM tb_herbiers.HERBIER_ADMINISTRER
|
|
|
129 |
ORDER BY HA_ID_ANNUAIRE, HA_ID_ORG ASC;
|
|
|
130 |
INSERT INTO tb_coel.coel_meta_historique_ligne
|
|
|
131 |
(cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
132 |
cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
133 |
SELECT @idm_tmp := @idm_tmp+1, '118', CONCAT(HA_ID_ORG, '-', HA_ID_ANNUAIRE, '-2026'), NULL,
|
|
|
134 |
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'
|
|
|
135 |
FROM tb_herbiers.HERBIER_ADMINISTRER
|
|
|
136 |
ORDER BY HA_ID_ANNUAIRE, HA_ID_ORG ASC;
|
|
|
137 |
|
|
|
138 |
#------------------------------------------------------------------------------------------------------------------------
|
|
|
139 |
#HERBIER_COLLECTION vers coel_collection
|
|
|
140 |
#INSERT INTO tb_coel.coel_collection
|
|
|
141 |
# (cc_id_collection, cc_ce_projet, cc_ce_mere, cc_truk_code, cc_nom, cc_description,
|
|
|
142 |
# cc_truk_url, cc_ce_type,
|
|
|
143 |
# cc_truk_conservation_statut, cc_truk_preservation,
|
|
|
144 |
# cc_ce_developpement, cc_truk_periode_constitution, cc_truk_couverture_lieu, cc_truk_coordonnee, cc_ce_specimen_type,
|
|
|
145 |
# cc_specimen_type_nbre, cc_mark_speciment_type_nbre_precision, cc_ce_specimen_type_classement, cc_expedition_nom,
|
|
|
146 |
# cc_truk_digital_medium, cc_truk_digital_format,
|
|
|
147 |
#
|
|
|
148 |
# cc_ce_meta)
|
|
|
149 |
# SELECT Id, 2, PARENT_ID, COLLECTION_CODE, NOM_COLLECTION, DESCRIPTION,
|
|
|
150 |
# URL, INCLUDED_TYPE, @idm
|
|
|
151 |
# FROM tb_herbiers.HERBIERS_COLLECTION
|
|
|
152 |
# ORDER BY Id ASC;
|
|
|
153 |
# INSERT INTO tb_coel.coel_meta_historique_ligne (cmhl_id_historique_ligne, cmhl_ce_table, cmhl_cle_ligne, cmhl_enregistrement,
|
|
|
154 |
# cmhl_date_modification, cmhl_notes, cmhl_ce_modifier_par, cmhl_ce_etat ,cmhl_ip)
|
|
|
155 |
# VALUES (@idm := @idm+1, '101', '2', NULL , NOW( ) , 'Ajout d''une collection', '1', '1', '162.38.234.1');
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|