Subversion Repositories Sites.tela-botanica.org

Rev

Rev 622 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
623 jpm 1
DELIMITER $$
2
DROP FUNCTION IF EXISTS legumino.HTML_UnEncode$$
3
CREATE DEFINER=`legumino`@`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
RETURN TextString ;
66
 
67
END$$
68
 
69
DELIMITER ;
70
 
71
DROP VIEW IF EXISTS legumino.legumino_tapir;
622 jpm 72
CREATE ALGORITHM=UNDEFINED DEFINER=`legumino`@`localhost` SQL SECURITY DEFINER VIEW `legumino_tapir` AS
73
	SELECT
623 jpm 74
		CONCAT('urn:lsid:tela-botanica.org:legumino:', c.id_contributions) AS guid,
75
		c.id_contributions AS observation_id,
76
		c.date AS observation_date,
77
		HTML_UnEncode(CONCAT_WS(' ',
78
			l.Genre,
79
			l.Espece,
80
			IF (TypeInfra3 != '', TypeInfra3, IF (TypeInfra2 != '', TypeInfra2, IF (TypeSousEspece != '', TypeSousEspece, NULL))),
81
			IF (Infra3 != '', Infra3, IF (Infra2 != '', Infra2, IF (SousEspece != '', SousEspece, NULL))),
82
			IF (AuteurInfra3 != '', AuteurInfra3, IF (AuteurInfra2 != '', AuteurInfra2, IF (AuteurSousEspece != '', AuteurSousEspece, IF (Auteur != '', Auteur, NULL)))))) AS nom_scientifique_complet,
83
		l.NumNomen AS nom_num_nomenclatural,
84
		l.NumTaxon AS nom_num_taxonomique,
85
		HTML_UnEncode(l.Famille) AS nom_famille,
86
		HTML_UnEncode(l.Genre) AS nom_genre,
87
		HTML_UnEncode(l.Espece) AS nom_espece,
88
		IF (TypeInfra3 != '', TypeInfra3, IF (TypeInfra2 != '', TypeInfra2, IF (TypeSousEspece != '', TypeSousEspece, NULL))) AS nom_type,
89
		HTML_UnEncode(IF (Infra3 != '', Infra3, IF (Infra2 != '', Infra2, IF (SousEspece != '', SousEspece, NULL)))) AS nom_infra_sp,
90
		HTML_UnEncode(IF (AuteurInfra3 != '', AuteurInfra3, IF (AuteurInfra2 != '', AuteurInfra2, IF (AuteurSousEspece != '', AuteurSousEspece, IF (Auteur != '', Auteur, NULL))))) AS nom_auteur,
91
		d.nom_departements AS lieu_departement_nom,
92
		CONCAT(CONVERT(cm.nom_communes USING UTF8), ' [INSEE:', SUBSTRING(cm.code_insee FROM 4), ']') AS lieu_commune_nom_complet,
93
		cm.nom_communes AS lieu_commune_nom,
94
		SUBSTRING(cm.code_insee FROM 4) AS lieu_commune_code_insee,
95
		cm.latitude AS lieu_commune_latitude,
96
		cm.longitude AS lieu_commune_longitude,
97
		HTML_UnEncode(CONCAT_WS(' ', ct.prenom_contributeurs, ct.nom_contributeurs , CONCAT('<', ct.mail, '>'))) AS observateur_nom_complet,
98
		HTML_UnEncode(CONCAT_WS(' ', ct.prenom_contributeurs, ct.nom_contributeurs)) AS observateur_nom,
99
		ct.mail AS observateur_courriel,
100
		HTML_UnEncode(c.commentaire) AS observation_commentaire,
101
		CONCAT(_utf8'<?xml version="1.0" encoding="UTF-8"?>',
102
			'<info>',
103
				'<nom_num_nomenclatural>',l.NumNomen,'</nom_num_nomenclatural>',
104
				'<nom_num_taxonomique>',l.NumTaxon,'</nom_num_taxonomique>',
105
			'</info>') AS observation_information_complement,
106
		c.date_saisie AS saisie_date_modification
107
	FROM contributions AS c
108
		LEFT JOIN communes AS cm ON (c.code_insee = cm.code_insee)
109
		LEFT JOIN departements AS d ON (cm.num_departements = d.num_departements)
110
		LEFT JOIN legumino AS l ON (c.NumTaxon = l.NumTaxon)
111
		LEFT JOIN contributeurs AS ct ON (c.id_contributeurs = ct.id_contributeurs);
112