Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2095 Rev 2149
Line 315... Line 315...
315
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (3, 'Capitalisation d\'images', 'photographier en extérieur les organes (feuille, fruit, tronc, etc.) de plantes et transmettre les photos via le Carnet en ligne.', 'Plantnet', 'port,fleur,fruit,feuille,plantscan_new,ecorce,rameau,planche', '0');
315
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (3, 'Capitalisation d\'images', 'photographier en extérieur les organes (feuille, fruit, tronc, etc.) de plantes et transmettre les photos via le Carnet en ligne.', 'Plantnet', 'port,fleur,fruit,feuille,plantscan_new,ecorce,rameau,planche', '0');
316
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (1, 'Aide à l\'identification', 'Choisissez les photos les plus utiles pour vérifier la détermination d\'une espèce', 'caractere', '', '0');
316
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (1, 'Aide à l\'identification', 'Choisissez les photos les plus utiles pour vérifier la détermination d\'une espèce', 'caractere', '', '0');
317
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (4, 'Défi Photo', 'Choisissez les lauréats du défi photo', '', '', '1');
317
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (4, 'Défi Photo', 'Choisissez les lauréats du défi photo', '', '', '1');
318
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (5, 'Enquête Gentiane-Azuré', 'Participez à la localisation des Gentianes Croisette, témoins et actrices du cycle de vie du papillon Azuré de la Croisette\r\n', 'GentianeAzure', '', '0');
318
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (5, 'Enquête Gentiane-Azuré', 'Participez à la localisation des Gentianes Croisette, témoins et actrices du cycle de vie du papillon Azuré de la Croisette\r\n', 'GentianeAzure', '', '0');
Line -... Line 319...
-
 
319
 
-
 
320
 
-
 
321
-- -----------------------------------------------------
-
 
322
-- Table de données calculées pour le service d'export
-
 
323
-- PlantNet
-
 
324
--
-
 
325
-- Comporte la date dernière mise à jour d'une obs et
-
 
326
-- des données liées
-
 
327
-- -----------------------------------------------------
-
 
328
CREATE TABLE del_observation_modif_date
-
 
329
(
-
 
330
  id_observation BIGINT NOT NULL,
-
 
331
  modif_date datetime,
-
 
332
 
-
 
333
  UNIQUE (id_observation)
-
 
334
)
-
 
335
 
-
 
336
 
-
 
337
-- -----------------------------------------------------
-
 
338
-- Initialisation des dates de dernière màj d'une obs et
-
 
339
-- de ses données liées
-
 
340
-- -----------------------------------------------------
-
 
341
INSERT INTO del_observation_modif_date (id_observation, modif_date)
-
 
342
SELECT DISTINCT p.id_observation,
-
 
343
       GREATEST(IFNULL(p.date_creation, '1900-01-01'), IFNULL(p.date_modification, '1900-01-01'), IFNULL(MAX(image_tag.date), '1900-01-01'), IFNULL(MAX(image_tag.date_modification), '1900-01-01'), IFNULL(MAX(image_vote.date), '1900-01-01'), IFNULL(MAX(commentaire.date), '1900-01-01'), IFNULL(MAX(commentaire_vote.date), '1900-01-01')) AS modif_date
-
 
344
FROM del_plantnet AS p
-
 
345
LEFT JOIN del_image_vote AS image_vote ON (id_image = image_vote.ce_image
-
 
346
                                   AND image_vote.ce_protocole = 3)
-
 
347
LEFT JOIN del_image_tag AS image_tag ON (id_image = image_tag.ce_image
-
 
348
                                  AND image_tag.actif = 1)
-
 
349
LEFT JOIN del_commentaire AS commentaire ON (id_observation = commentaire.ce_observation)
-
 
350
LEFT JOIN del_commentaire_vote AS commentaire_vote ON (commentaire.id_commentaire = commentaire_vote.ce_proposition)
-
 
351
GROUP BY id_observation
-
 
352
HAVING MAX(p.date_creation) >= '1900-01-01'
-
 
353
OR MAX(p.date_modification) >= '1900-01-01'
-
 
354
OR MAX(image_tag.date) >= '1900-01-01'
-
 
355
OR MAX(image_tag.date_modification) >= '1900-01-01'
-
 
356
OR MAX(image_vote.date) >= '1900-01-01'
-
 
357
OR MAX(commentaire.date) >= '1900-01-01'
-
 
358
OR MAX(commentaire_vote.date) >= '1900-01-01'
-
 
359
 
-
 
360
-- -----------------------------------------------------
-
 
361
-- Triggers pour garder à jour les dates de dernière màj
-
 
362
-- d'une obs et de ses données liées
-
 
363
-- -----------------------------------------------------
-
 
364
-- cel_obs INSERT trigger --
-
 
365
DROP TRIGGER IF EXISTS tb_cel.TRIGGER_celObs_dateModif_INSERT
-
 
366
CREATE TRIGGER tb_cel.TRIGGER_celObs_dateModif_INSERT
-
 
367
AFTER INSERT ON tb_cel.cel_obs FOR EACH ROW
-
 
368
INSERT INTO tb_del.del_observation_modif_date (id_observation, modif_date)
-
 
369
VALUES (NEW.id_observation, NEW.date_creation);
-
 
370
 
-
 
371
-- cel_obs UPDATE trigger --
-
 
372
CREATE TRIGGER tb_cel.TRIGGER_celObs_dateModif_UPDATE
-
 
373
AFTER UPDATE ON tb_cel.cel_obs FOR EACH ROW
-
 
374
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.date_modification
-
 
375
WHERE id_observation = NEW.id_observation;
-
 
376
 
-
 
377
 
-
 
378
 
-
 
379
-- del_commentaire INSERT trigger --
-
 
380
CREATE TRIGGER tb_del.TRIGGER_delCommentaire_dateModif_INSERT
-
 
381
AFTER INSERT ON tb_del.del_commentaire FOR EACH ROW
-
 
382
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
383
WHERE id_observation = NEW.ce_observation;
-
 
384
 
-
 
385
-- del_commentaire UPDATE trigger --
-
 
386
CREATE TRIGGER tb_del.TRIGGER_delCommentaire_dateModif_UPDATE
-
 
387
AFTER UPDATE ON tb_del.del_commentaire FOR EACH ROW
-
 
388
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
389
WHERE id_observation = NEW.ce_observation;
-
 
390
 
-
 
391
 
-
 
392
 
-
 
393
-- del_commentaire_vote INSERT trigger --
-
 
394
CREATE TRIGGER tb_del.TRIGGER_delCommentaireVote_dateModif_INSERT
-
 
395
AFTER INSERT ON tb_del.del_commentaire_vote FOR EACH ROW
-
 
396
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
397
WHERE id_observation = (SELECT ce_observation FROM tb_del.del_commentaire WHERE id_commentaire = NEW.ce_proposition);
-
 
398
 
-
 
399
-- del_commentaire_vote UPDATE trigger --
-
 
400
CREATE TRIGGER tb_del.TRIGGER_delCommentaireVote_dateModif_UPDATE
-
 
401
AFTER UPDATE ON tb_del.del_commentaire_vote FOR EACH ROW
-
 
402
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
403
WHERE id_observation = (SELECT ce_observation FROM tb_del.del_commentaire WHERE id_commentaire = NEW.ce_proposition);
-
 
404
 
-
 
405
 
-
 
406
 
-
 
407
-- del_image_vote INSERT trigger --
-
 
408
CREATE TRIGGER tb_del.TRIGGER_delImageVote_dateModif_INSERT
-
 
409
AFTER INSERT ON tb_del.del_image_vote FOR EACH ROW
-
 
410
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
411
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
412
 
-
 
413
-- del_image_vote UPDATE trigger --
-
 
414
CREATE TRIGGER tb_del.TRIGGER_delImageVote_dateModif_UPDATE
-
 
415
AFTER UPDATE ON tb_del.del_image_vote FOR EACH ROW
-
 
416
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
417
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
418
 
-
 
419
 
-
 
420
 
-
 
421
-- del_image_tag INSERT trigger --
-
 
422
CREATE TRIGGER tb_del.TRIGGER_delImageTag_dateModif_INSERT
-
 
423
AFTER INSERT ON tb_del.del_image_tag FOR EACH ROW
-
 
424
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
425
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
426
 
-
 
427
-- del_image_tag UPDATE trigger --
-
 
428
CREATE TRIGGER tb_del.TRIGGER_delImageTag_dateModif_UPDATE
-
 
429
AFTER UPDATE ON tb_del.del_image_tag FOR EACH ROW
-
 
430
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
431
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
432
 
-
 
433
-- -----------------------------------------------------
-
 
434
-- Fin des triggers pour garder à jour les dates de
-
 
435
-- dernière màj d'une obs et de ses données liées
-
 
436
-- -----------------------------------------------------
-
 
437
 
319
 
438