626 |
jpm |
1 |
DELIMITER $$
|
|
|
2 |
DROP FUNCTION IF EXISTS pterido2.HTML_UnEncode$$
|
|
|
3 |
CREATE DEFINER=`pterido2`@`localhost` FUNCTION `HTML_UnEncode`(x VARCHAR(255)) RETURNS varchar(255) CHARSET latin1
|
|
|
4 |
BEGIN
|
|
|
5 |
|
|
|
6 |
DECLARE TextString VARCHAR(255) ;
|
|
|
7 |
SET TextString = x ;
|
|
|
8 |
|
|
|
9 |
IF INSTR( x , '"' )
|
|
|
10 |
THEN SET TextString = REPLACE(TextString, '"', '"') ;
|
|
|
11 |
END IF ;
|
|
|
12 |
|
|
|
13 |
IF INSTR( x , '&' )
|
|
|
14 |
THEN SET TextString = REPLACE(TextString, '&', '&') ;
|
|
|
15 |
END IF ;
|
|
|
16 |
|
|
|
17 |
IF INSTR( x , '<' )
|
|
|
18 |
THEN SET TextString = REPLACE(TextString, '<', '<') ;
|
|
|
19 |
END IF ;
|
|
|
20 |
|
|
|
21 |
IF INSTR( x , '>' )
|
|
|
22 |
THEN SET TextString = REPLACE(TextString, '>', '>') ;
|
|
|
23 |
END IF ;
|
|
|
24 |
|
|
|
25 |
IF INSTR( x , '‘' )
|
|
|
26 |
THEN SET TextString = REPLACE(TextString, '‘', '‘') ;
|
|
|
27 |
END IF ;
|
|
|
28 |
|
|
|
29 |
IF INSTR( x , '’' )
|
|
|
30 |
THEN SET TextString = REPLACE(TextString, '’', '''') ;
|
|
|
31 |
END IF ;
|
|
|
32 |
|
|
|
33 |
IF INSTR( x , '“' )
|
|
|
34 |
THEN SET TextString = REPLACE(TextString, '“', '“') ;
|
|
|
35 |
END IF ;
|
|
|
36 |
|
|
|
37 |
IF INSTR( x , '”' )
|
|
|
38 |
THEN SET TextString = REPLACE(TextString, '”', '”') ;
|
|
|
39 |
END IF ;
|
|
|
40 |
|
|
|
41 |
IF INSTR( x , 'œ' )
|
|
|
42 |
THEN SET TextString = REPLACE(TextString, 'œ', 'œ') ;
|
|
|
43 |
END IF ;
|
|
|
44 |
|
|
|
45 |
IF INSTR( x , '«' )
|
|
|
46 |
THEN SET TextString = REPLACE(TextString, '«', '«') ;
|
|
|
47 |
END IF ;
|
|
|
48 |
|
|
|
49 |
IF INSTR( x , '°' )
|
|
|
50 |
THEN SET TextString = REPLACE(TextString, '°', '°') ;
|
|
|
51 |
END IF ;
|
|
|
52 |
|
|
|
53 |
IF INSTR( x , '±' )
|
|
|
54 |
THEN SET TextString = REPLACE(TextString, '±', '±') ;
|
|
|
55 |
END IF ;
|
|
|
56 |
|
|
|
57 |
IF INSTR( x , '²' )
|
|
|
58 |
THEN SET TextString = REPLACE(TextString, '²', '²') ;
|
|
|
59 |
END IF ;
|
|
|
60 |
|
|
|
61 |
IF INSTR( x , '¹' )
|
|
|
62 |
THEN SET TextString = REPLACE(TextString, '¹', '¹') ;
|
|
|
63 |
END IF ;
|
|
|
64 |
|
|
|
65 |
IF INSTR( x , '»' )
|
|
|
66 |
THEN SET TextString = REPLACE(TextString, '»', '»') ;
|
|
|
67 |
END IF ;
|
|
|
68 |
|
|
|
69 |
IF INSTR( x , 'É' )
|
|
|
70 |
THEN SET TextString = REPLACE(TextString, 'É', 'É');
|
|
|
71 |
END IF ;
|
|
|
72 |
|
|
|
73 |
IF INSTR( x , 'Î' )
|
|
|
74 |
THEN SET TextString = REPLACE(TextString, 'Î', 'Î');
|
|
|
75 |
END IF ;
|
|
|
76 |
|
|
|
77 |
IF INSTR( x , 'á' )
|
|
|
78 |
THEN SET TextString = REPLACE(TextString, 'á', 'á');
|
|
|
79 |
END IF ;
|
|
|
80 |
|
|
|
81 |
IF INSTR( x , 'à' )
|
|
|
82 |
THEN SET TextString = REPLACE(TextString, 'à', 'à');
|
|
|
83 |
END IF ;
|
|
|
84 |
|
|
|
85 |
IF INSTR( x , 'â' )
|
|
|
86 |
THEN SET TextString = REPLACE(TextString, 'â', 'â');
|
|
|
87 |
END IF ;
|
|
|
88 |
|
|
|
89 |
IF INSTR( x , 'ä' )
|
|
|
90 |
THEN SET TextString = REPLACE(TextString, 'ä', 'ä');
|
|
|
91 |
END IF ;
|
|
|
92 |
|
|
|
93 |
IF INSTR( x , 'ç' )
|
|
|
94 |
THEN SET TextString = REPLACE(TextString, 'ç', 'ç');
|
|
|
95 |
END IF ;
|
|
|
96 |
|
|
|
97 |
IF INSTR( x , 'è' )
|
|
|
98 |
THEN SET TextString = REPLACE(TextString, 'è', 'è');
|
|
|
99 |
END IF ;
|
|
|
100 |
|
|
|
101 |
IF INSTR( x , 'é' )
|
|
|
102 |
THEN SET TextString = REPLACE(TextString, 'é', 'é');
|
|
|
103 |
END IF ;
|
|
|
104 |
|
|
|
105 |
IF INSTR( x , 'ê' )
|
|
|
106 |
THEN SET TextString = REPLACE(TextString, 'ê', 'ê');
|
|
|
107 |
END IF ;
|
|
|
108 |
|
|
|
109 |
IF INSTR( x , 'ë' )
|
|
|
110 |
THEN SET TextString = REPLACE(TextString, 'ë', 'ë');
|
|
|
111 |
END IF ;
|
|
|
112 |
|
|
|
113 |
IF INSTR( x , 'í' )
|
|
|
114 |
THEN SET TextString = REPLACE(TextString, 'í', 'í');
|
|
|
115 |
END IF ;
|
|
|
116 |
|
|
|
117 |
IF INSTR( x , 'î' )
|
|
|
118 |
THEN SET TextString = REPLACE(TextString, 'î', 'î');
|
|
|
119 |
END IF ;
|
|
|
120 |
|
|
|
121 |
IF INSTR( x , 'ï' )
|
|
|
122 |
THEN SET TextString = REPLACE(TextString, 'ï', 'ï');
|
|
|
123 |
END IF ;
|
|
|
124 |
|
|
|
125 |
IF INSTR( x , 'ò' )
|
|
|
126 |
THEN SET TextString = REPLACE(TextString, 'ò', 'ò');
|
|
|
127 |
END IF ;
|
|
|
128 |
|
|
|
129 |
IF INSTR( x , 'ô' )
|
|
|
130 |
THEN SET TextString = REPLACE(TextString, 'ô', 'ô');
|
|
|
131 |
END IF ;
|
|
|
132 |
|
|
|
133 |
IF INSTR( x , 'ö' )
|
|
|
134 |
THEN SET TextString = REPLACE(TextString, 'ö', 'ö');
|
|
|
135 |
END IF ;
|
|
|
136 |
|
|
|
137 |
IF INSTR( x , 'ù' )
|
|
|
138 |
THEN SET TextString = REPLACE(TextString, 'ù', 'ù');
|
|
|
139 |
END IF ;
|
|
|
140 |
|
|
|
141 |
IF INSTR( x , 'û' )
|
|
|
142 |
THEN SET TextString = REPLACE(TextString, 'û', 'û');
|
|
|
143 |
END IF ;
|
|
|
144 |
|
|
|
145 |
IF INSTR( x , 'ü' )
|
|
|
146 |
THEN SET TextString = REPLACE(TextString, 'ü', 'ü');
|
|
|
147 |
END IF ;
|
|
|
148 |
|
|
|
149 |
IF INSTR( x , 'ÿ' )
|
|
|
150 |
THEN SET TextString = REPLACE(TextString, 'ÿ', 'ÿ');
|
|
|
151 |
END IF ;
|
|
|
152 |
|
|
|
153 |
RETURN TextString ;
|
|
|
154 |
|
|
|
155 |
END$$
|
|
|
156 |
|
|
|
157 |
DELIMITER ;
|
|
|
158 |
|
|
|
159 |
DROP VIEW IF EXISTS pterido2.pterido_tapir;
|
|
|
160 |
CREATE ALGORITHM=UNDEFINED DEFINER=`pterido2`@`localhost` SQL SECURITY DEFINER VIEW `pterido_tapir` AS
|
|
|
161 |
SELECT
|
|
|
162 |
CONCAT('urn:lsid:tela-botanica.org:pterido:', c.id_contributions) AS guid,
|
|
|
163 |
c.id_contributions AS observation_id,
|
|
|
164 |
c.date AS observation_date,
|
|
|
165 |
HTML_UnEncode(CONCAT_WS(' ',
|
|
|
166 |
l.Genre,
|
|
|
167 |
l.Espece,
|
|
|
168 |
IF (TypeInfra3 != '', TypeInfra3, IF (TypeInfra2 != '', TypeInfra2, IF (TypeSousEspece != '', TypeSousEspece, NULL))),
|
|
|
169 |
IF (Infra3 != '', Infra3, IF (Infra2 != '', Infra2, IF (SousEspece != '', SousEspece, NULL))),
|
|
|
170 |
IF (AuteurInfra3 != '', AuteurInfra3, IF (AuteurInfra2 != '', AuteurInfra2, IF (AuteurSousEspece != '', AuteurSousEspece, IF (Auteur != '', Auteur, NULL)))))) AS nom_scientifique_complet,
|
|
|
171 |
l.NumNomen AS nom_num_nomenclatural,
|
|
|
172 |
l.NumTaxon AS nom_num_taxonomique,
|
|
|
173 |
HTML_UnEncode(l.Famille) AS nom_famille,
|
|
|
174 |
HTML_UnEncode(l.Genre) AS nom_genre,
|
|
|
175 |
HTML_UnEncode(l.Espece) AS nom_espece,
|
|
|
176 |
IF (TypeInfra3 != '', TypeInfra3, IF (TypeInfra2 != '', TypeInfra2, IF (TypeSousEspece != '', TypeSousEspece, NULL))) AS nom_type,
|
|
|
177 |
HTML_UnEncode(IF (Infra3 != '', Infra3, IF (Infra2 != '', Infra2, IF (SousEspece != '', SousEspece, NULL)))) AS nom_infra_sp,
|
|
|
178 |
HTML_UnEncode(IF (AuteurInfra3 != '', AuteurInfra3, IF (AuteurInfra2 != '', AuteurInfra2, IF (AuteurSousEspece != '', AuteurSousEspece, IF (Auteur != '', Auteur, NULL))))) AS nom_auteur,
|
|
|
179 |
d.nom_departements AS lieu_departement_nom,
|
|
|
180 |
CONCAT(CONVERT(cm.nom_communes USING UTF8), ' [INSEE:', SUBSTRING(cm.code_insee FROM 4), ']') AS lieu_commune_nom_complet,
|
|
|
181 |
cm.nom_communes AS lieu_commune_nom,
|
|
|
182 |
SUBSTRING(cm.code_insee FROM 4) AS lieu_commune_code_insee,
|
|
|
183 |
cm.latitude AS lieu_commune_latitude,
|
|
|
184 |
cm.longitude AS lieu_commune_longitude,
|
|
|
185 |
HTML_UnEncode(CONCAT_WS(' ', ct.prenom_contributeurs, ct.nom_contributeurs , CONCAT('<', ct.mail, '>'))) AS observateur_nom_complet,
|
|
|
186 |
HTML_UnEncode(CONCAT_WS(' ', ct.prenom_contributeurs, ct.nom_contributeurs)) AS observateur_nom,
|
|
|
187 |
ct.mail AS observateur_courriel,
|
|
|
188 |
HTML_UnEncode(c.commentaire) AS observation_commentaire,
|
|
|
189 |
CONCAT(_utf8'<?xml version="1.0" encoding="UTF-8"?>',
|
|
|
190 |
'<info>',
|
|
|
191 |
'<nom_num_nomenclatural>',l.NumNomen,'</nom_num_nomenclatural>',
|
|
|
192 |
'<nom_num_taxonomique>',l.NumTaxon,'</nom_num_taxonomique>',
|
|
|
193 |
'</info>') AS observation_information_complement,
|
|
|
194 |
DATE_FORMAT(c.date_saisie, '%Y-%m-%d 00:00:00') AS saisie_date_modification
|
|
|
195 |
FROM contributions AS c
|
|
|
196 |
LEFT JOIN communes AS cm ON (c.code_insee = cm.code_insee)
|
|
|
197 |
LEFT JOIN departements AS d ON (cm.num_departements = d.num_departements)
|
|
|
198 |
LEFT JOIN pterido AS l ON (c.NumTaxon = l.NumTaxon)
|
|
|
199 |
LEFT JOIN contributeurs AS ct ON (c.id_contributeurs = ct.id_contributeurs);
|
|
|
200 |
|