Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2128 Rev 2148
Line 318... Line 318...
318
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');
318
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');
319
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');
319
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');
320
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');
320
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');
321
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');
321
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 322...
-
 
322
 
-
 
323
 
-
 
324
-- -----------------------------------------------------
-
 
325
-- Table de données calculées pour le service d'export
-
 
326
-- PlantNet
-
 
327
--
-
 
328
-- Comporte la date dernière mise à jour d'une obs et
-
 
329
-- des données liées
-
 
330
-- -----------------------------------------------------
-
 
331
CREATE TABLE del_observation_modif_date
-
 
332
(
-
 
333
  id_observation BIGINT NOT NULL,
-
 
334
  modif_date datetime,
-
 
335
 
-
 
336
  UNIQUE (id_observation)
-
 
337
)
-
 
338
 
-
 
339
 
-
 
340
-- -----------------------------------------------------
-
 
341
-- Initialisation des dates de dernière màj d'une obs et
-
 
342
-- de ses données liées
-
 
343
-- -----------------------------------------------------
-
 
344
INSERT INTO del_observation_modif_date (id_observation, modif_date)
-
 
345
SELECT DISTINCT p.id_observation,
-
 
346
       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
-
 
347
FROM del_plantnet AS p
-
 
348
LEFT JOIN del_image_vote AS image_vote ON (id_image = image_vote.ce_image
-
 
349
                                   AND image_vote.ce_protocole = 3)
-
 
350
LEFT JOIN del_image_tag AS image_tag ON (id_image = image_tag.ce_image
-
 
351
                                  AND image_tag.actif = 1)
-
 
352
LEFT JOIN del_commentaire AS commentaire ON (id_observation = commentaire.ce_observation)
-
 
353
LEFT JOIN del_commentaire_vote AS commentaire_vote ON (commentaire.id_commentaire = commentaire_vote.ce_proposition)
-
 
354
GROUP BY id_observation
-
 
355
HAVING MAX(p.date_creation) >= '1900-01-01'
-
 
356
OR MAX(p.date_modification) >= '1900-01-01'
-
 
357
OR MAX(image_tag.date) >= '1900-01-01'
-
 
358
OR MAX(image_tag.date_modification) >= '1900-01-01'
-
 
359
OR MAX(image_vote.date) >= '1900-01-01'
-
 
360
OR MAX(commentaire.date) >= '1900-01-01'
-
 
361
OR MAX(commentaire_vote.date) >= '1900-01-01'
-
 
362
 
-
 
363
-- -----------------------------------------------------
-
 
364
-- Triggers pour garder à jour les dates de dernière màj
-
 
365
-- d'une obs et de ses données liées
-
 
366
-- -----------------------------------------------------
-
 
367
-- cel_obs INSERT trigger --
-
 
368
DROP TRIGGER IF EXISTS tb_cel.TRIGGER_celObs_dateModif_INSERT
-
 
369
CREATE TRIGGER tb_cel.TRIGGER_celObs_dateModif_INSERT
-
 
370
AFTER INSERT ON tb_cel.cel_obs FOR EACH ROW
-
 
371
INSERT INTO tb_del.del_observation_modif_date (id_observation, modif_date)
-
 
372
VALUES (NEW.id_observation, NEW.date_creation);
-
 
373
 
-
 
374
-- cel_obs UPDATE trigger --
-
 
375
CREATE TRIGGER tb_cel.TRIGGER_celObs_dateModif_UPDATE
-
 
376
AFTER UPDATE ON tb_cel.cel_obs FOR EACH ROW
-
 
377
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.date_modification
-
 
378
WHERE id_observation = NEW.id_observation;
-
 
379
 
-
 
380
 
-
 
381
 
-
 
382
-- del_commentaire INSERT trigger --
-
 
383
CREATE TRIGGER tb_del.TRIGGER_delCommentaire_dateModif_INSERT
-
 
384
AFTER INSERT ON tb_del.del_commentaire FOR EACH ROW
-
 
385
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
386
WHERE id_observation = NEW.ce_observation;
-
 
387
 
-
 
388
-- del_commentaire UPDATE trigger --
-
 
389
CREATE TRIGGER tb_del.TRIGGER_delCommentaire_dateModif_UPDATE
-
 
390
AFTER UPDATE ON tb_del.del_commentaire FOR EACH ROW
-
 
391
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
392
WHERE id_observation = NEW.ce_observation;
-
 
393
 
-
 
394
 
-
 
395
 
-
 
396
-- del_commentaire_vote INSERT trigger --
-
 
397
CREATE TRIGGER tb_del.TRIGGER_delCommentaireVote_dateModif_INSERT
-
 
398
AFTER INSERT ON tb_del.del_commentaire_vote FOR EACH ROW
-
 
399
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
400
WHERE id_observation = (SELECT ce_observation FROM tb_del.del_commentaire WHERE id_commentaire = NEW.ce_proposition);
-
 
401
 
-
 
402
-- del_commentaire_vote UPDATE trigger --
-
 
403
CREATE TRIGGER tb_del.TRIGGER_delCommentaireVote_dateModif_UPDATE
-
 
404
AFTER UPDATE ON tb_del.del_commentaire_vote FOR EACH ROW
-
 
405
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
406
WHERE id_observation = (SELECT ce_observation FROM tb_del.del_commentaire WHERE id_commentaire = NEW.ce_proposition);
-
 
407
 
-
 
408
 
-
 
409
 
-
 
410
-- del_image_vote INSERT trigger --
-
 
411
CREATE TRIGGER tb_del.TRIGGER_delImageVote_dateModif_INSERT
-
 
412
AFTER INSERT ON tb_del.del_image_vote FOR EACH ROW
-
 
413
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
414
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
415
 
-
 
416
-- del_image_vote UPDATE trigger --
-
 
417
CREATE TRIGGER tb_del.TRIGGER_delImageVote_dateModif_UPDATE
-
 
418
AFTER UPDATE ON tb_del.del_image_vote FOR EACH ROW
-
 
419
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
420
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
421
 
-
 
422
 
-
 
423
 
-
 
424
-- del_image_tag INSERT trigger --
-
 
425
CREATE TRIGGER tb_del.TRIGGER_delImageTag_dateModif_INSERT
-
 
426
AFTER INSERT ON tb_del.del_image_tag FOR EACH ROW
-
 
427
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
428
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
429
 
-
 
430
-- del_image_tag UPDATE trigger --
-
 
431
CREATE TRIGGER tb_del.TRIGGER_delImageTag_dateModif_UPDATE
-
 
432
AFTER UPDATE ON tb_del.del_image_tag FOR EACH ROW
-
 
433
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
-
 
434
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
-
 
435
 
-
 
436
-- -----------------------------------------------------
-
 
437
-- Fin des triggers pour garder à jour les dates de
-
 
438
-- dernière màj d'une obs et de ses données liées
-
 
439
-- -----------------------------------------------------
-
 
440
 
322
 
441