Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

No changes between revisions

Ignore whitespace Rev 842 → Rev 843

/tags/v0.1-20130829/donnees
New file
Property changes:
Added: svn:ignore
+*
/tags/v0.1-20130829/nettoyerBdd.sh
New file
0,0 → 1,67
#!/bin/bash
##############################################################################################################
# But : Script supprimant toutes les tables de la base de données eFlore.
# Auteur : Jean-Pascal Milcent <jpm@tela-botanica.org> (translate bat file to shell script)
# License : GPL v3
# Création : 15 avril 2013
# Version: 0.1
# 2013-04-15 - Création
# $Id$
##############################################################################################################
# Constante
APPDIR_ABSOLU=`pwd`;
#
CHEMIN_PHP="/opt/lampp/bin"
CHEMIN_TBF_CLI="$APPDIR_ABSOLU/scripts"
MEMORY_LIMIT="3500M"
echo -e "\033[31m`tput blink`ATTENTION :`tput sgr0` Nécessite la création préalable de la base de données \033[31mtb_eflore\033[00m"
echo "Nettoyage et chargement en cours...";
# BASEFLORE : doit être placé apèrs BDTFX (dépendance !)
echo "BASEVEG :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php baseveg -a supprimerTous
echo "BDNT :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdnt -a supprimerTous
echo "BDTFX :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdtfx -a supprimerTous
echo "BASEFLOR :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php baseflor -a supprimerTous
echo "BDTXA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdtxa -a supprimerTous
echo "BIBLIO_BOTA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php biblio_bota -a supprimerTous
# echo "BONNIER :";
# Pas encore utilisé !
echo "CHORODEP :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php chorodep -a supprimerTous
echo "COSTE :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php coste -a supprimerTous
echo "EFLORE :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php eflore -a supprimerTous
# echo "FOURNIER :";
# Pas encore utilisé !
echo "INSEE-D :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php insee_d -a supprimerTous
echo "ISO-3166-1 :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php iso_3166_1 -a supprimerTous
echo "ISO-639-1 :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php iso_639_1 -a supprimerTous
echo "NVJFL :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nvjfl -a supprimerTous
echo "NVPS :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nvps -a supprimerTous
echo "NVA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nva -a supprimerTous
echo "PHOTOFLORA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php photoflora -a supprimerTous
# echo "PROMETHEUS :";
# Ontologie botanique.
# Pas encore utilisé !
echo "SPTB :";
# Statut de protection Tela Botanica
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php sptb -a supprimerTous
echo "CEL :";
echo -e "\033[31m`tput blink`ATTENTION :`tput sgr0` Nécessite la création préalable de la base de données \033[31mtb_cel\033[00m"
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php cel -a supprimerTous
echo "TAPIRLINK :";
echo -e "\033[31m`tput blink`ATTENTION :`tput sgr0` Nécessite la création préalable de la base de données \033[31mtb_hit_indexation\033[00m"
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php tapirlink -a supprimerTous
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:eol-style
+native
\ No newline at end of property
/tags/v0.1-20130829/initialiserBdd.sh
New file
0,0 → 1,91
#!/bin/bash
##############################################################################################################
# But : Script permettant d'initialiser en une seule commande l'ensemble de la base de données eFlore.
# Auteur : Jean-Pascal Milcent <jpm@tela-botanica.org> (translate bat file to shell script)
# Exemple : /opt/lampp/bin/php -d memory_limit=3500M ./cli.php bdtxa -a supprimerTous
# License : GPL v3
# Création : 07 decembre 2011
# Version: 0.1
# 2011-12-07 - Création
# $Id$
##############################################################################################################
# Constante
APPDIR_ABSOLU=`pwd`;
#
CHEMIN_PHP="/opt/lampp/bin"
CHEMIN_TBF_CLI="$APPDIR_ABSOLU/scripts"
MEMORY_LIMIT="3500M"
echo -e "\033[31m`tput blink`ATTENTION :`tput sgr0` Nécessite la création préalable de la base de données \033[31mtb_eflore\033[00m"
echo "Nettoyage et chargement en cours...";
# BASEFLORE : doit être placé apèrs BDTFX (dépendance !)
echo "BASEVEG :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php baseveg -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php baseveg -a chargerTous
echo "BDNT :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdnt -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdnt -a chargerTous
echo "BDTFX :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdtfx -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdtfx -a chargerTous
echo "BASEFLOR :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php baseflor -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php baseflor -a chargerTous
echo "BDTXA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdtxa -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php bdtxa -a chargerTous
echo "BIBLIO_BOTA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php biblio_bota -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php biblio_bota -a chargerTous
# echo "BONNIER :";
# Pas encore utilisé !
echo "CHORODEP :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php chorodep -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php chorodep -a chargerTous
echo "COSTE :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php coste -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php coste -a chargerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php coste -a chargerTxt
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php coste -a chargerIndex
echo "EFLORE :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php eflore -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php eflore -a chargerTous
# echo "FOURNIER :";
# Pas encore utilisé !
echo "INSEE-D :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php insee_d -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php insee_d -a chargerTous
echo "ISO-3166-1 :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php iso_3166_1 -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php iso_3166_1 -a chargerTous
echo "ISO-639-1 :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php iso_639_1 -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php iso_639_1 -a chargerTous
echo "NVJFL :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nvjfl -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nvjfl -a chargerTous
echo "NVPS :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nvps -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nvps -a chargerTous
echo "NVA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nva -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php nva -a chargerTous
echo "PHOTOFLORA :";
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php photoflora -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php photoflora -a chargerTous
# echo "PROMETHEUS :";
# Ontologie botanique.
# Pas encore utilisé !
echo "SPTB :";
# Statut de protection Tela Botanica
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php sptb -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php sptb -a chargerTous
echo "CEL :";
echo -e "\033[31m`tput blink`ATTENTION :`tput sgr0` Nécessite la création préalable de la base de données \033[31mtb_cel\033[00m"
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php cel -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php cel -a chargerTous
echo "TAPIRLINK :";
echo -e "\033[31m`tput blink`ATTENTION :`tput sgr0` Nécessite la création préalable de la base de données \033[31mtb_hit_indexation\033[00m"
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php tapirlink -a supprimerTous
$CHEMIN_PHP/php -d memory_limit=$MEMORY_LIMIT $CHEMIN_TBF_CLI/cli.php tapirlink -a chargerTous
 
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:eol-style
+native
\ No newline at end of property
/tags/v0.1-20130829/livraison.sh
New file
0,0 → 1,21
#!/bin/bash
##############################################################################################################
# But : Script permettant d'initialiser en une seule commande l'ensemble de la base de données eFlore.
# Auteur : Jean-Pascal Milcent <jpm@tela-botanica.org> (translate bat file to shell script)
# License : GPL v3
# Création : 07 decembre 2011
# Version: 0.1
# 2011-12-07 - Création
# $Id$
##############################################################################################################
 
# ATTENTION NE PAS UTILISER !!!
 
# compresser les services en excluant les fichiers svn et les fichiers de config et framework
#tar cvzf services.tar.gz services/ --exclude=".svn" --exclude="*.ini" --exclude="framework.php" --exclude="*.sh"
# envoyer sur tela
#scp services.tar.gz root@tela-botanica.org:/home/telabotap/www/eflore-test/.
 
# se connecter sur tela botanica en ssh et effectuer le déploiement
#ssh root@tela-botanica.org "cd /home/telabotap/www/eflore-test/; cd services; tar cvzf ../backup/services.tar.gz .; cd ../; rm -Rf services; tar xvzf services.tar.gz; cd services; cp ../configurations/services/* . -R; chown #telabotap:users /home/telabotap/www/eflore-test/services -R; chmod 755 /home/telabotap/www/eflore-test/services -R; exit";
#echo "Done !"
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:eol-style
+native
\ No newline at end of property
/tags/v0.1-20130829/chargerDonnees.sh
New file
0,0 → 1,50
#!/bin/bash
##############################################################################################################
# But : téléchargement automatique en local des données des projets depuis le serveur de Tela Botanica par ftp
# Auteur : Jean-Pascal Milcent <jpm@tela-botanica.org> (translate bat file to shell script)
# License : GPL v3
# Création : 07 decembre 2011
# Version: 0.1
# 2011-12-07 - Création
# $Id$
##############################################################################################################
# Constante
NBREPARAM=$#
APPDIR_ABSOLU=`pwd`;
DOSSIER_LOCAL="$APPDIR_ABSOLU/donnees/"
DOSSIER_DISTANT="/www/eflore/donnees/"
# Aide
E_OPTERR=65
if [ "$1" = '--help' ]
then # Le script a besoin d'au moins un argument sur la ligne de commande
echo "Usage $0 -[parameters -u, -p ]"
echo "Paramétres : "
echo " -h: indiquer l'hote ftp"
echo " -u: indiquer le nom de l'utilisateur ftp"
echo " -p: indiquer le mot de passe de l'utilisateur ftp"
exit $E_OPTERR
fi
 
# Récupération des paramètres et des options de la ligne de commande
TEMP=`getopt -o u:p:h: -l help: -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
while [ ! -z "$1" ] ; do
#echo $1" # "$2
case "$1" in
-h) HOST=$2;;
-u) FTP_USER=$2;;
-p) FTP_PASSWD=$2;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
shift 2
done
 
# Transfert sur le serveur par FTP
if [ $NBREPARAM -eq 0 ]; then
echo "Pas de transfert sur le serveur. Utiliser --help pour voir les options de transfert."
else
echo "Téléchargement en cours :";
lftp ftp://$FTP_USER:$FTP_PASSWD@$HOST -e "set ftp:passive off; mirror -e --no-symlinks -x '.*cel\/images\/.*' -x '.*osm\/.*' -x '.*plantscan\/.*' -x '.*coste\/cles\/.*' -x '.*coste\/descriptions\/.*' -x '.*coste\/images\/.*' -x '.*coste\/ressources\/.*' $DOSSIER_DISTANT $DOSSIER_LOCAL ; quit"
fi;
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:eol-style
+native
\ No newline at end of property
/tags/v0.1-20130829/services/modules/0.1/baseflor/Graphiques.php
New file
0,0 → 1,42
<?php
/**
* Classe Graphiques.php détermine le type de graphiques à afficher en fonction des données des tables
* baseflor et baseflor_rang_sup_ecologie
* fin d'url possibles :
* graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie une graphique avec les données connues
*
*
* @package eflore-projets
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version 1.0
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
*/
 
class Graphiques extends Commun{
 
 
private $Graph_tables = array('GraphiquesBaseflor', 'GraphiquesTaxonsSup');
public function consulter($ressources, $parametres) {
$versionResultat = null;
foreach ($this->Graph_tables as $graph_tab) {
$Graph = new $graph_tab();
$versionResultat = $Graph->consulter($ressources, $parametres);
if($versionResultat != null) {break;}
}
if ($versionResultat == null) {
$message = 'Les données recherchées sont introuvables.';
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
throw new Exception($message, $code);
}
return $versionResultat;
}
 
}
?>
/tags/v0.1-20130829/services/modules/0.1/baseflor/Informations.php
New file
0,0 → 1,290
<?php
 
/**
* Classe Informations.php interroge la table Index
* et redirige vers une autre classe si besoin
* d'interroger une autre table (comme baseflor ou baseflor_rang_sup)
* elle traite également le retour du web service : /informations
*
* Encodage en entrée : utf8
* Encodage en sortie : utf8
* @package eflore-projets
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version 1.0
* @copyright 1999-2012 Tela Botanica (accueil@tela-botanica.org)
*
*
*/
 
 
 
class Informations extends Commun {
protected $limite_requete = array( 'depart' => 0, 'limite' => 10);
private $tables;
private $champs_recherches = '*';
private $requete_jointure = "";
private $requete_condition = "";
private $total_resultat;
protected $serviceNom = 'informations';
private $masque;
public function consulter($ressources, $parametres) {
$this->ressources = $ressources;
$this->parametres = $parametres;
$versionResultat = null;
if (empty($this->ressources)){
$this->traiterParametres();
}
$this->definirTables(array ('index' => config::get('bdd_table_index'),
'baseflor' => config::get('bdd_table'),
'rangSup' => config::get('bdd_table_rang_sup')
)
);
$this->traiterRessources();
$requete = $this->assemblerLaRequete();
// exemple:
// SELECT * FROM baseflor_index_v2012_12_31 WHERE `bdnt.nn` = 'bdtfx.nn:XXXXX';
$resultat = $this->Bdd->recupererTous($requete . ' -- ' . __FILE__ . ':' .__LINE__);
$versionResultat = $this->renvoyerResultat($resultat);
if ($versionResultat == null) {
$message = 'Les données recherchées sont introuvables.';
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
throw new Exception($message, $code);
}
return $versionResultat;
}
 
public function __construct() {
$Conteneur = new Conteneur();
$this->Bdd = $Conteneur ->getBdd();
}
public function renvoyerResultat($resultat) {
$res_formate = array();
if (empty($this->ressources)) {
$res_formate = $this->retournerResultatFormate($resultat);
} else {
$classe = empty($resultat[0]['baseflor']) ? 'InformationsTaxonsSup' : 'InformationsBaseflor';
$info = new $classe(new Conteneur());
$res_formate = $info->consulter($this->ressources, $this->parametres);
}
return $res_formate;
}
//+--------------------------traitement ressources ou paramètres -------------------------------------+
 
public function traiterRessources() {
if (empty($this->ressources)) {
$this->requete_jointure = array(
'LEFT JOIN '. $this->tables['baseflor'].' ON '
.$this->tables['baseflor'].".cle =".$this->tables['index'].".baseflor",
'LEFT JOIN '. $this->tables['rangSup'].' ON '
.$this->tables['rangSup'].".cle = ".$this->tables['index'].".RangSup");
$this->champs_recherches = " {$this->tables['baseflor']}.num_nomen as 'baseflor.nn',
{$this->tables['baseflor']}.BDNT as 'baseflor.bdnt',
{$this->tables['baseflor']}.catminat_code,
{$this->tables['baseflor']}.num_taxon ,
{$this->tables['baseflor']}.idiotaxon ,
{$this->tables['rangSup']}.num_nomen as 'rangSup.nn',
{$this->tables['rangSup']}.bdnt as 'rangSup.bdnt',
{$this->tables['index']}.cle as 'index.cle' ";
} else {
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)){
$this->champs_recherches = " baseflor, rangSup ";
$this->requete_condition[] = " `bdnt.nn` = '{$retour[0]}' ";
} else {
$e = 'Erreur dans l\'url de votre requête : </br> La ressource demandée n\'existe pas.';
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
break;
}
}
}
public function traiterParametres() {
if (isset($this->parametres) && !empty($this->parametres) ) {
foreach ($this->parametres as $param => $valeur) {
switch ($param) {
case 'navigation.depart' :
if(!isset($this->parametres['navigation.limite']))
throw new Exception("indiquez également la valeur pour le paramètre navigation.limite.",
RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
$this->definirNavigationDepart($valeur);
break;
case 'navigation.limite' :
if(!isset($this->parametres['navigation.depart']))
throw new Exception("indiquez également la valeur pour le paramètre navigation.depart.",
RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
$this->definirNavigationLimite($valeur);
break;
case 'version.projet' :
$this->traiterVersion($valeur);
break;
case 'masque.cat' :
$this->masque = 'catminat='.str_replace('-','/',$valeur);
$this->requete_condition[] = " catminat_code = '".str_replace('-','/',$valeur)."' ";
break;
default :
$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
.$param.' " n\'existe pas.';
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e); break;
}
}
}
}
//+++------------------------------traitement des versions----------------------------------------++
public function traiterVersion($valeur) {
if (preg_match('/^[0-9]+(?:[._][0-9]+)*$/', $valeur) || $valeur == '*' || $valeur == '+') {
$this->version_projet = $valeur;
} else {
$e = "Erreur : La version est inconnue.";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
if ($this->version_projet == '*' && empty($this->ressources)) {
$message = "L'affichage de plusieurs versions ne fonctionne que pour les ressources de type /ressources/#id";
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
throw new Exception($message, $code);
}
}
public function definirTables($prefixe_table) {
$table_num_version = $this->recupererVersionDisponible();
foreach ($prefixe_table as $nom => $prefixe ) {
if ( in_array($this->version_projet,$table_num_version) ) {
$tables[$nom] = $prefixe.'_v'.$this->version_projet;
} elseif ($this->version_projet == '+') {
$derniere_version = $table_num_version[count($table_num_version) - 1];
$tables[$nom] = $prefixe.'_v'.str_replace('.', '_', $derniere_version);
} else {
$e = "Erreur : La version est inconnue.";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
}
$this->tables = $tables;
}
 
//+--------------------------formatages de resultats -------------------------------------------+
 
public function retournerResultatFormate($resultat) {
$resultat_json = array();
$resultat_json['entete'] = $this->ajouterEnteteResultat();
$resultat_json['resultats'] = array();
foreach ($resultat as $ligne => $tab) {
$num = $tab['index.cle'];
$resultat_json['resultats'][$num]['num_nomen'] =
(empty ($tab['baseflor.nn'])) ? $tab['rangSup.nn'] : $tab['baseflor.nn'];
$resultat_json['resultats'][$num]['bdnt'] =
(empty ($tab['baseflor.bdnt'])) ? $tab['rangSup.bdnt'] : $tab['baseflor.bdnt'];
$resultat_json['resultats'][$num]['catminat_code'] =
(empty ($tab['catminat_code'])) ? '' : $tab['catminat_code'];
$resultat_json['resultats'][$num]['idiotaxon'] =
(empty ($tab['idiotaxon'])) ? '' : $tab['idiotaxon'];
$resultat_json['resultats'][$num]['num_taxon'] =
(empty ($tab['num_taxon'])) ? '' : $tab['num_taxon'];
if ($resultat_json['resultats'][$num]['num_nomen'] != 0) {
$bdnt = strtolower($resultat_json['resultats'][$num]['bdnt']);
$nn = $resultat_json['resultats'][$num]['num_nomen'];
$resultat_json['resultats'][$num]['href'] =
$this->ajouterHref('informations',$bdnt.".nn:".$nn);
}
}
return $resultat_json;
}
public function ajouterEnteteResultat() {
$entete['depart'] = $this->limite_requete['depart'];
$entete['limite'] = $this->limite_requete['limite'];
$entete['total'] = $this->total_resultat;
if ($this->masque) {
$entete['masque'] = $this->masque;
}
$entete['version'] = $this->version_projet;
$url = $this->formulerUrl($this->total_resultat, '/informations');
if (isset($url['precedent']) && $url['precedent'] != '') {
$entete['href.precedent'] = $url['precedent'];
}
if (isset($url['suivant']) && $url['suivant'] != '') {
$entete['href.suivant'] = $url['suivant'];
}
return $entete;
}
//+-------------------------------------assemblage de requête------------------------------------//
public function assemblerLaRequete() {
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->tables['index'].' '
.$this->retournerRequeteJointure().' '.$this->retournerRequeteCondition().
' '.$this->delimiterResultatsRequete();
return $requete;
}
public function retournerRequeteCondition() {
$condition = '';
if ($this->requete_condition !== "") {
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
}
return $condition;
}
public function calculerTotalResultat() {
$requete = 'SELECT count(*) as nombre FROM '.$this->tables['index'].' '
.$this->retournerRequeteJointure().' '.$this->retournerRequeteCondition();
$res = $this->getBdd()->recuperer($requete);
if ($res) {
$this->total_resultat = $res['nombre'];
} else {
$this->total_resultat = 0;
$e = 'Données introuvables dans la base';
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
}
}
public function delimiterResultatsRequete() {
$this->calculerTotalResultat();
$requete_limite = '';
if (($this->limite_requete['depart'] <= $this->total_resultat) ){
if ( $this->limite_requete['depart'] < $this->total_resultat ){
$requete_limite = 'LIMIT '.$this->limite_requete['depart'].', '
.$this->limite_requete['limite'];
}
} else {
$e = "Erreur : la valeur pour le paramètre navigation.départ est supérieure".
" au nombre total de résultats.";
throw new Exception($e, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
}
return $requete_limite;
}
public function retournerRequeteJointure() {
$jointure = '';
if ($this->requete_jointure !== "") {
$jointure = implode(' ', $this->requete_jointure);
}
return $jointure;
}
}
/tags/v0.1-20130829/services/modules/0.1/baseflor/GraphiquesTaxonsSup.php
New file
0,0 → 1,146
<?php
/**
* Classe GraphiquesTaxonsSup.php transforme les données écologiques de la table baseflor_rang_sup_ecologie
* en graphique svg
* graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie un graphique avec les données connues
*
*
* @package eflore-projets
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version 1.0
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
*/
 
class GraphiquesTaxonsSup extends CommunGraphiques{
 
 
public function definirTable($version){
$this->table = Config::get('bdd_table_rang_sup')."_v".$version;
}
//+---- ressources ----+
public function traiterReferentieletNum(){
if (!empty($this->ressources[1])) {
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[1], $retour) == 1){
switch ($retour[1]) {
case 'bdtfx' : // pour le moment un seul referentiel disponible
$this->requete_condition[]= "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
break;
default :
$e = "Le référentiel {$retour[1]} n'existe pas.";
throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
break;
}
}else {
$e = "Erreur dans l'url de votre requête :".
" précisez le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.";
throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
} else {
throw new Exception( "Erreur dans l'url de votre requête :".
" précisez le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.",
RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
}
public function traiterTypeGraphique(){
if (!empty($this->ressources[0])) {
switch ($this->ressources[0]) {
case 'climat' :
$this->requete_champs = ' ve_lumiere_min, ve_lumiere_max, ve_temperature_min,'.
' ve_temperature_max, ve_continentalite_min,'.
' ve_continentalite_max, ve_humidite_atmos_min,'.
' ve_humidite_atmos_max' ;
$this->nomGraphique= 'climat_min_max';
break;
case 'sol' :
$this->requete_champs = ' ve_humidite_edaph_min , ve_humidite_edaph_max,'.
' ve_reaction_sol_min, ve_reaction_sol_max, '.
' ve_nutriments_sol_min, ve_nutriments_sol_max,'.
' ve_salinite_min, ve_salinite_max,'.
' ve_texture_sol_min, ve_texture_sol_max,'.
've_mat_org_sol_min,ve_mat_org_sol_max ' ;
$this->nomGraphique = 'sol_min_max';
break;
default :
$e = "Erreur dans l'url de votre requête :".
"</br> précisez le graphique -> \"sol\" ou \"climat\".";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
break;
}
}else {
throw new Exception("Erreur dans l'url de votre requête :".
"</br> precisez le graphique -> \"sol\" ou \"climat\".", RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
}
//+-------------------------- formatage du résultat -------------------------------------------+
public function changerValeursSVG(){
$this->ajouterValeursIntermediaires();
$Dompath = new DOMXPath($this->dom);
foreach ($this->valeurs_en_pourcentage as $cle => $val){
$val = preg_replace('/,/','.', $val);
$grad_id = array_search($val,$this->graduations_id);
$champs = preg_replace('/_min|_max|_[0-9]/','', $cle);
// dans le cas de mauvaises données, pour ne pas que tout le graphique
$case = $Dompath->query("//*[@id='".$grad_id."_".$champs."']")->item(0);
if($case != null) {
$case->setAttribute('fill','#EA6624');
$case->setAttribute('stroke','#EA6624');
$this->ajouterInfoAuSurvol($champs,$case);
}
$changement = true;
}
$this->ajusterFormatSVG();
}
public function ajouterValeursIntermediaires(){
$champs_ecolo = array_keys($this->champs_ontologiques);
foreach ($champs_ecolo as $chps ){
$min = !empty($this->valeurs_en_pourcentage[$chps.'_min']) ? $this->valeurs_en_pourcentage[$chps.'_min'] : -1;
$max = !empty($this->valeurs_en_pourcentage[$chps.'_max']) ? $this->valeurs_en_pourcentage[$chps.'_max'] : -1;
if ($min < ($max-0.1) ){
$i = $min + 0.1;
$num = 1;
for ($i ; $i < $max; $i += 0.1) {
$this->valeurs_en_pourcentage[$chps.'_'.$num] = $i;
$num++;
}
}
}
}
public function ajouterInfoAuSurvol($champs, $case){
$min = $this->valeurs_champs[$champs."_min"];
$max = $this->valeurs_champs[$champs."_max"];
if ($min != $max){
$valeurMin = $this->recupererOntologies($min, $champs );
$valeurMax = $this->recupererOntologies($max, $champs );
$valeurMin = $this->traiterIntermediaires($valeurMin->nom, $champs, $champs.'_min');
$valeurMax = $this->traiterIntermediaires($valeurMax->nom, $champs, $champs.'_max');
$case->setAttribute('title',"de $min: $valeurMin à $max: $valeurMax " );
} else {
$valeurMin = $this->recupererOntologies($min, $champs );
$valeurMin = $this->traiterIntermediaires($valeurMin->nom, $champs, $champs.'_min');
$case->setAttribute('title',"$min: $valeurMin" );
}
}
}
?>
/tags/v0.1-20130829/services/modules/0.1/baseflor/InformationsTaxonsSup.php
New file
0,0 → 1,268
<?php
 
/**
* Classe InformationsTaxonsSup.php permet de faire des requetes pour les rangs superieurs de baseflor
* du référentiel BDTFX et avec un numéro nomenclatural ( différent de 0 ).
* fin d'url possibles :
*
* /informations/#bdnt.nn:#num_nomen?champs=ecologie --> retourne champs ecologiques pour un BDNT et un num_nomen
*
*
* Encodage en entrée : utf8
* Encodage en sortie : utf8
* @package eflore-projets
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version 1.0
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
*/
 
class InformationsTaxonsSup extends Commun{
protected $table = "";
private $champs_ontologiques = array();
private $format_reponse = 'informations';
protected $serviceNom = 'informations';
private $retour_format = 'max';
private $Bdd;
private $requete_condition = "";
private $champs_recherches = '*';
public function consulter($ressources, $parametres) {
$this->ressources = $ressources;
$this->parametres = $parametres;
$this->traiterParametres();
$this->definirTables();
$this->traiterRessources();
$resultats = '';
foreach ($this->table_version as $version) {
$this->table = $version;
$requete = $this->assemblerLaRequete();
$resultat = $this->Bdd->recupererTous($requete);
$versionResultat = $this->analyserResultat($resultat);
if (count($this->table_version) > 1) {
$resultats[$version] = $versionResultat;
} else {
$resultats = $versionResultat;
}
}
return $resultats;
}
public function analyserResultat($resultat) {
$versionResultat = null;
if ($resultat == '') {
$message = 'La requête SQL formée comporte une erreur!';
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
throw new Exception($message, $code);
} elseif ($resultat) {
$versionResultat = $this->retournerResultatFormate($resultat);
}
return $versionResultat;
}
public function __construct(Conteneur $Conteneur) {
$this->Bdd = $Conteneur->getBdd();
}
//+--------------------------traitement ressources ou paramètres -------------------------------------------+
public function traiterRessources() {
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)==1){
switch ($retour[1]) {
case 'bdtfx' :
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
break;
default :
$e = 'Erreur dans l\'url de votre requête : </br> Le référentiel " '
.$retour[1].' " n\'existe pas.';
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
break;
}
}
}
//+---- paramètres ----+
public function traiterParametres() {
if (isset($this->parametres) && !empty($this->parametres) ) {
foreach ($this->parametres as $param => $valeur) {
switch ($param) {
case 'categorie' :
if ($valeur == "ecologie"){
$this->champs_recherches = ' num_nomen, bdnt, ve_lumiere_min , ve_lumiere_max,'
.' ve_temperature_min, ve_temperature_max, ve_continentalite_min,'
.' ve_continentalite_max, ve_humidite_atmos_min, ve_humidite_atmos_max,'
.' ve_humidite_edaph_min, ve_humidite_edaph_max, ve_reaction_sol_min,'
.' ve_reaction_sol_max, ve_nutriments_sol_min, ve_nutriments_sol_max,'
.' ve_salinite_min, ve_salinite_max, ve_texture_sol_min,ve_texture_sol_max,'
.' ve_mat_org_sol_min, ve_mat_org_sol_max ';
} else {
$e = "Valeur de paramètre inconnue pour 'categorie'. Ce paramètre n'est pas autorisé pour informations/#id";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
break;
case 'retour.format' :
if ($valeur == 'min' || $valeur == 'max') {
$this->retour_format = $valeur;
break;
} else {
$e = "Valeur de paramètre inconnue pour 'retour.format'. Ce paramètre n'est pas autorisé pour informations/#id";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
case 'version.projet' :
$this->traiterVersion($valeur);
break;
default :
$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
.$param.' " n\'existe pas.';
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE); break;
}
}
}
}
 
//+++------------------------------traitement des versions----------------------------------------++
public function traiterVersion($valeur) {
if (preg_match('/^[0-9]+(?:[._][0-9]+)*$/', $valeur) || $valeur == '*' || $valeur == '+') {
$this->version_projet = $valeur;
} else {
$e = "Erreur : La version est inconnue.";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
if ($this->version_projet == '*' && $this->ressources == array()) {
$message = "L'affichage de plusieurs versions ne fonctionne que pour les ressources de type /ressources/#id";
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
throw new Exception($message, $code);
}
}
 
public function definirTables() {
$table_num_version = $this->recupererVersionDisponible();
$prefixe_table = config::get('bdd_table_rang_sup');
if ( in_array($this->version_projet,$table_num_version) ) {
$this->table_version[] = $prefixe_table.'_v'.$this->version_projet;
} elseif ($this->version_projet == '+') {
$derniere_version = $table_num_version[count($table_num_version) - 1];
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $derniere_version);
} elseif ($this->version_projet == '*') {
foreach ($table_num_version as $num_version) {
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $num_version);
}
} else {
$e = "Erreur : La version est inconnue.";
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
}
}
//+--------------------------formatages de resultats -------------------------------------------+
public function retournerResultatFormate($resultat) {
$this->resultat_json = $resultat[0];
if ($this->retour_format == 'max') {
$graphique_presence = $this->traiterEcologie() ;
if ($graphique_presence) {
$this->ajouterLiensGraphique($graphique_presence);
}
}
return $this->resultat_json ;
}
public function traiterEcologie() {
$donnees_presence = false;
$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
foreach ($this->champs_ontologiques as $cle => $valeur){
/* Les deux tests commentés ci-dessous étaient présents dans eflore-test (uniquement) jusqu'à juin 2013.
La valeur 0 pose question.
cf baseflor_v2012_12_31
cf services/modules/0.1/baseflor/CommunGraphiques.php traiterValeursEcologiques() */
if ($this->resultat_json[$cle.'_min'] != "") { // && $this->resultat_json[$cle.'_min'] != 0) {
$donnees_presence[$this->getNomGraphique($valeur)] = true;
$tab_ontologie = $this->recupererOntologies($this->resultat_json[$cle.'_min'], $cle.'_min');
unset($this->resultat_json[$cle.'_min']);
}
if ($this->resultat_json[$cle.'_max'] != "") { // && $this->resultat_json[$cle.'_max'] != 0) {
$this->recupererOntologies($this->resultat_json[$cle.'_max'], $cle.'_max');
unset($this->resultat_json[$cle.'_max']);
}
}
return $donnees_presence;
}
//donne le nom du graphique correspondant à un champ écologique
public function getNomGraphique($code_ecolo) {
$graphique = null;
if (in_array($code_ecolo, explode(',',Config::get('Paramètres.climat')))) {
$graphique = 'climat';
} elseif (in_array($code_ecolo, explode(',', Config::get('Paramètres.sol')) )) {
$graphique = 'sol';
}
return $graphique;
}
public function ajouterLiensGraphique($graphique_presence) {
if ($graphique_presence['climat']) {
$this->resultat_json['graphique_climat']['libelle'] = 'climat';
$this->resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat',
strtolower($this->resultat_json['bdnt']).'.nn:'.$this->resultat_json['num_nomen']);
}
if ($graphique_presence['sol']) {
$this->resultat_json['graphique_sol']['libelle'] = 'sol';
$this->resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol',
strtolower($this->resultat_json['bdnt']).'.nn:'.$this->resultat_json['num_nomen']);
}
}
//+--------------------------traitement ontologies -------------------------------------------+
public function recupererOntologies($valeur, $champs){
$chps_sans = preg_replace("/_min|_max/", '', $champs);
$url = Config::get('url_service_base').Config::get('nom_projet').
'/ontologies/'.$this->champs_ontologiques[$chps_sans].':'.urlencode(urlencode($valeur));
try {
$val = $this->getBdd()->recuperer(sprintf(
"SELECT a.nom FROM baseflor_ontologies a LEFT JOIN baseflor_ontologies b ON a.id = b.id LEFT JOIN baseflor_ontologies c ON b.classe_id = c.id WHERE".
" b.code = BINARY '%s' AND c.code = BINARY '%s' LIMIT 0, 100",
$valeur,
$this->champs_ontologiques[$chps_sans]),
Bdd::MODE_OBJET);
$this->resultat_json[$champs.'.libelle'] = $val->nom;
$this->resultat_json[$champs.'.code'] = $valeur;
$this->resultat_json[$champs.'.href'] = $url;
} catch (Exception $e) {
$this->resultat_json[$champs.'.libelle'] = '';
$this->resultat_json[$champs.'.code'] = '';
$this->resultat_json[$champs.'.href'] = '';
}
}
//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
public function assemblerLaRequete() {
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
.$this->retournerRequeteCondition();
return $requete;
}
public function retournerRequeteCondition() {
$condition = '';
if (empty($this->requete_condition) == false) {
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
}
return $condition;
}
}
?>