Subversion Repositories Sites.tela-botanica.org

Rev

Rev 622 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 622 Rev 623
Line -... Line 1...
-
 
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;
1
CREATE ALGORITHM=UNDEFINED DEFINER=`legumino`@`localhost` SQL SECURITY DEFINER VIEW `legumino_tapir` AS 
72
CREATE ALGORITHM=UNDEFINED DEFINER=`legumino`@`localhost` SQL SECURITY DEFINER VIEW `legumino_tapir` AS 
2
	SELECT 
73
	SELECT 
3
		concat(_utf8'urn:lsid:tela-botanica.org:legumino:', c.id_contributions) AS guid,	
74
		CONCAT('urn:lsid:tela-botanica.org:legumino:', c.id_contributions) AS guid,
-
 
75
		c.id_contributions AS observation_id,
4
		c.date AS date_observation, 
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,
5
		c.commentaire AS commentaire,
83
		l.NumNomen AS nom_num_nomenclatural,
6
		c.date_saisie AS date_modification,
84
		l.NumTaxon AS nom_num_taxonomique,
-
 
85
		HTML_UnEncode(l.Famille) AS nom_famille,
7
		SUBSTRING(cm.code_insee FROM 4) AS commune_code_insee,
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,
8
		cm.nom_communes AS commune_nom,
93
		cm.nom_communes AS lieu_commune_nom,
-
 
94
		SUBSTRING(cm.code_insee FROM 4) AS lieu_commune_code_insee,
9
		cm.latitude AS commune_latitude,
95
		cm.latitude AS lieu_commune_latitude,
10
		cm.longitude AS commune_longitude,
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,
11
		l.NumNomen AS num_nomenclatural,
99
		ct.mail AS observateur_courriel,
12
		l.NumTaxon AS num_taxonomique,
100
		HTML_UnEncode(c.commentaire) AS observation_commentaire,
13
		l.Famille AS nom_famille,
101
		CONCAT(_utf8'<?xml version="1.0" encoding="UTF-8"?>', 
14
		l.Genre AS nom_genre,
102
			'<info>',
15
		l.Espece AS nom_espece,
103
				'<nom_num_nomenclatural>',l.NumNomen,'</nom_num_nomenclatural>',
16
		
-
 
-
 
104
				'<nom_num_taxonomique>',l.NumTaxon,'</nom_num_taxonomique>',
17
		l.Auteur AS nom_auteur,
105
			'</info>') AS observation_information_complement,
18
		`i`.`num_nom_sel` AS `num_nom_sel`,`i`.`famille` AS `famille`,`l`.`code` AS `code`,`l`.`name` AS `name`,`i`.`date_observation` AS `date_observation`,`i`.`identifiant` AS `identifiant`,concat(`l`.`sector`,' ',`l`.`x_utm`,'m E ',`l`.`y_utm`,'m N') AS `coordonnees_bruts`,`l`.`sector` AS `sector`,`l`.`x_utm` AS `x_utm`,`l`.`y_utm` AS `y_utm`,`i`.`date_transmission` AS `date_transmission`,concat(_utf8'<?xml version="1.0" encoding="UTF-8"?>','<info>','<ordre>',`i`.`ordre`,'</ordre>','<num_nom_sel>',`i`.`num_nom_sel`,'</num_nom_sel>','<nom_ret>',`i`.`nom_ret`,'</nom_ret>','<num_nom_ret>',`i`.`num_nom_ret`,'</num_nom_ret>','<num_taxon>',`i`.`num_taxon`,'</num_taxon>','<lieudit>',`i`.`lieudit`,'</lieudit>','<station>',`i`.`station`,'</station>','<milieu>',`i`.`milieu`,'</milieu>','<commentaire>',`i`.`commentaire`,'</commentaire>','<transmission>',`i`.`transmission`,'</transmission>','<date_creation>',`i`.`date_creation`,'</date_creation>','<maj_name>',`l`.`maj_name`,'</maj_name>','<sector>',`l`.`sector`,'</sector>','<update_date>',`l`.`update_date`,'</update_date>','</info>') AS `related_information`,`i`.`num_taxon` AS `num_taxon` 
106
		c.date_saisie AS saisie_date_modification
19
		 
-
 
20
	FROM (contributions AS c 
107
	FROM contributions AS c 
21
		LEFT JOIN communes AS cm ON (c.code_insee = cm.code_insee) 
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)
22
		LEFT JOIN legumino AS l (c.NumTaxon = l.NumTaxon) 
110
		LEFT JOIN legumino AS l ON (c.NumTaxon = l.NumTaxon) 
23
		LEFT JOIN contributeurs AS ct (c.id_contributeurs = ct.mail) 
111
		LEFT JOIN contributeurs AS ct ON (c.id_contributeurs = ct.id_contributeurs);
24
	WHERE (`i`.`transmission` = 1);
-
 
-
 
112