Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 230 Rev 232
Line 1... Line 1...
1
<?php
1
<?php
2
/**
2
/**
3
 * Exemple de lancement du script : /opt/lampp/bin/php cli.php ontologie -a analyser
3
 * Exemple de lancement du script : /opt/lampp/bin/php cli.php ontologie -a analyser
4
 *
4
 *
5
 */
5
 */
6
class Prometheus extends Script {
6
class Prometheus extends EfloreScript {
Line 7... Line 7...
7
 
7
 
8
	private $lecteur = null;
8
	private $lecteur = null;
9
	private $fichier = '';
9
	private $fichier = '';
10
	private $lotsTermes = array();
10
	private $lotsTermes = array();
Line 33... Line 33...
33
		'REGION_TERMS' => 16,
33
		'REGION_TERMS' => 16,
34
		'GENERIC_STRUCTURES' => 17);
34
		'GENERIC_STRUCTURES' => 17);
Line 35... Line 35...
35
 
35
 
36
	public function executer() {
36
	public function executer() {
37
		try {
37
		try {
-
 
38
			$this->initialiserProjet('prometheus');
38
			$this->bdd = new Bdd();
39
 
39
			$this->fichier = realpath(dirname(__FILE__)).'/../../../donnees/prometheus/v1.00_2003-02-18/Ontology.xml';
40
			$this->fichier = realpath(dirname(__FILE__)).'/../../../donnees/prometheus/v1.00_2003-02-18/Ontology.xml';
40
			// Lancement de l'action demandée
41
			// Lancement de l'action demandée
41
			$cmd = $this->getParametre('a');
42
			$cmd = $this->getParametre('a');
-
 
43
		    switch ($cmd) {
-
 
44
		    	case 'chargerTous' :
-
 
45
		    		$this->chargerStructureSql();
-
 
46
		    		$this->lireFichierXml();
-
 
47
		    		break;
-
 
48
		    	case 'chargerStructureSql' :
-
 
49
		    		$this->chargerStructureSql();
42
		    switch ($cmd) {
50
		    		break;
43
		    	case 'analyser' :
51
		    	case 'analyser' :
44
					$this->vider();
52
					$this->vider();
45
		    		$this->lireFichierXml();
53
		    		$this->lireFichierXml();
46
					break;
54
					break;
47
		    	case 'vider' :
55
		    	case 'vider' :
-
 
56
		    		$this->vider();
-
 
57
		    	case 'supprimerTous' :
-
 
58
		    		$this->supprimerTous();
48
		    		$this->vider();
59
		    		break;
49
				default :
60
				default :
50
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
61
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
51
			}
62
			}
52
		} catch (Exception $e) {
63
		} catch (Exception $e) {
Line 436... Line 447...
436
		$valeur[] = (int) $noeud->attributes()->TermID;
447
		$valeur[] = (int) $noeud->attributes()->TermID;
437
		$this->lotsHierarchie[] = $valeur;
448
		$this->lotsHierarchie[] = $valeur;
438
	}
449
	}
Line 439... Line 450...
439
 
450
 
440
	private function insererLotDeTermes() {
451
	private function insererLotDeTermes() {
441
		$champs = implode(',', array('id_terme', 'ce_type', 'terme', 'definition', 'preference', 'ce_auteur', 'ce_publication', 'ce_image'));
452
		$champs = implode(',', array('id_terme', 'ce_type', 'nom_en', 'description_en', 'preference', 'ce_auteur', 'ce_publication', 'ce_image'));
442
		$values = $this->creerValues($this->lotsTermes);
453
		$values = $this->creerValues($this->lotsTermes);
443
		$requete = "INSERT INTO prometheus_ontologie_terme_v1_00 ($champs) VALUES $values";
454
		$requete = "INSERT INTO prometheus_ontologies_terme_v1_00 ($champs) VALUES $values";
444
		$this->executerSql($requete);
455
		$this->executerSql($requete);
Line 445... Line 456...
445
	}
456
	}
446
 
457
 
447
	private function insererLotDeRelations() {
458
	private function insererLotDeRelations() {
448
		$champs = implode(',', array('id_terme_01', 'id_terme_02', 'relation'));
459
		$champs = implode(',', array('id_terme_01', 'id_terme_02', 'relation'));
449
		$values = $this->creerValues($this->lotsRelations);
460
		$values = $this->creerValues($this->lotsRelations);
450
		$requete = "INSERT INTO prometheus_ontologie_relation_v1_00 ($champs) VALUES $values";
461
		$requete = "INSERT INTO prometheus_ontologies_relation_v1_00 ($champs) VALUES $values";
Line 451... Line 462...
451
		$this->executerSql($requete);
462
		$this->executerSql($requete);
452
	}
463
	}
453
 
464
 
454
	private function insererLotImages() {
465
	private function insererLotImages() {
455
		$champs = implode(',', array('id_image', 'uri', 'ce_publication'));
466
		$champs = implode(',', array('id_image', 'uri', 'ce_publication'));
456
		$values = $this->creerValues($this->lotsImages);
467
		$values = $this->creerValues($this->lotsImages);
Line 457... Line 468...
457
		$requete = "INSERT INTO prometheus_ontologie_image_v1_00 ($champs) VALUES $values";
468
		$requete = "INSERT INTO prometheus_ontologies_image_v1_00 ($champs) VALUES $values";
458
		$this->executerSql($requete);
469
		$this->executerSql($requete);
459
	}
470
	}
460
 
471
 
461
	private function insererLotDePublications() {
472
	private function insererLotDePublications() {
462
		$champs = implode(',', array('id_publication', 'ce_auteur_principal', 'titre', 'date', 'uri'));
473
		$champs = implode(',', array('id_publication', 'ce_auteur_principal', 'titre', 'date', 'uri'));
Line 463... Line 474...
463
		$values = $this->creerValues($this->lotsPublications);
474
		$values = $this->creerValues($this->lotsPublications);
464
		$requete = "INSERT INTO prometheus_ontologie_publication_v1_00 ($champs) VALUES $values";
475
		$requete = "INSERT INTO prometheus_ontologies_publication_v1_00 ($champs) VALUES $values";
465
		$this->executerSql($requete);
476
		$this->executerSql($requete);
466
	}
477
	}
467
 
478
 
468
	private function insererLotAuteurs() {
479
	private function insererLotAuteurs() {
Line 469... Line 480...
469
		$champs = implode(',', array('id_auteur', 'prenom', 'nom', 'naissance_date', 'deces_date'));
480
		$champs = implode(',', array('id_auteur', 'prenom', 'nom', 'naissance_date', 'deces_date'));
470
		$values = $this->creerValues($this->lotsAuteurs);
481
		$values = $this->creerValues($this->lotsAuteurs);
471
		$requete = "INSERT INTO prometheus_ontologie_auteur_v1_00 ($champs) VALUES $values";
482
		$requete = "INSERT INTO prometheus_ontologies_auteur_v1_00 ($champs) VALUES $values";
472
		$this->executerSql($requete);
483
		$this->executerSql($requete);
473
	}
484
	}
474
 
485
 
Line 475... Line 486...
475
	private function insererLotHierarchie() {
486
	private function insererLotHierarchie() {
476
		$champs = implode(',', array('id_noeud', 'id_noeud_parent', 'chemin_noms', 'chemin_ids', 'ce_terme'));
487
		$champs = implode(',', array('id_noeud', 'id_noeud_parent', 'chemin_noms', 'chemin_ids', 'ce_terme'));
Line 495... Line 506...
495
		$vide = ($val === null || trim($val) === '') ? true : false;
506
		$vide = ($val === null || trim($val) === '') ? true : false;
496
		return $vide;
507
		return $vide;
497
	}
508
	}
Line 498... Line 509...
498
 
509
 
499
	private function executerSql($requete) {
510
	private function executerSql($requete) {
500
		$this->bdd->requeter($requete);
511
		$this->getBdd()->requeter($requete);
Line 501... Line 512...
501
	}
512
	}
502
 
513
 
503
	private function proteger($chaine) {
514
	private function proteger($chaine) {
Line 504... Line 515...
504
		return $this->bdd->proteger($chaine);
515
		return $this->getBdd()->proteger($chaine);
505
	}
516
	}
506
 
517
 
507
	private function vider() {
518
	private function vider() {
508
		$requete = 'TRUNCATE TABLE prometheus_ontologie_auteur_v1_00';
519
		$requete = 'TRUNCATE TABLE prometheus_ontologies_auteur_v1_00';
509
		$this->executerSql($requete);
520
		$this->executerSql($requete);
510
		$requete = 'TRUNCATE TABLE prometheus_ontologie_hierarchie_v1_00';
521
		$requete = 'TRUNCATE TABLE prometheus_ontologies_hierarchie_v1_00';
511
		$this->executerSql($requete);
522
		$this->executerSql($requete);
512
		$requete = 'TRUNCATE TABLE prometheus_ontologie_image_v1_00';
523
		$requete = 'TRUNCATE TABLE prometheus_ontologies_image_v1_00';
513
		$this->executerSql($requete);
524
		$this->executerSql($requete);
514
		$requete = 'TRUNCATE TABLE prometheus_ontologie_publication_v1_00';
525
		$requete = 'TRUNCATE TABLE prometheus_ontologies_publication_v1_00';
515
		$this->executerSql($requete);
526
		$this->executerSql($requete);
516
		$requete = 'TRUNCATE TABLE prometheus_ontologie_relation_v1_00';
527
		$requete = 'TRUNCATE TABLE prometheus_ontologies_relation_v1_00';
517
		$this->executerSql($requete);
528
		$this->executerSql($requete);
-
 
529
		$requete = 'TRUNCATE TABLE prometheus_ontologies_terme_v1_00';
-
 
530
		$this->executerSql($requete);
-
 
531
	}
-
 
532
 
-
 
533
	private function supprimerTous() {
-
 
534
		$requete = "DROP TABLE prometheus_meta, prometheus_ontologies_auteur_v1_00, prometheus_ontologies_hierarchie_v1_00,
-
 
535
			prometheus_ontologies_image_v1_00, prometheus_ontologies_publication_v1_00, prometheus_ontologies_relation_v1_00,
518
		$requete = 'TRUNCATE TABLE prometheus_ontologie_terme_v1_00';
536
			prometheus_ontologies_terme_v1_00, prometheus_ontologies_type_v1_00";
519
		$this->executerSql($requete);
537
		$this->getBdd()->requeter($requete);