176,7 → 176,7 |
} else { |
$e = 'Erreur dans votre requête </br> Ressources disponibles : <br/> |
<li> noms/#id/relations </li> <li> noms/#id/#champ+#champ </li> |
<li> noms/#id/relations/synonymie </li> <li> noms/#id/relations/flores </li> |
<li> noms/#id/relations/synonymie </li> |
<li> noms/#id/relations/homonymie </li>'; |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e); |
} |
196,8 → 196,8 |
$champ = "flore_$projet"."_num"; |
if (isset($this->ressources[3])) { |
$type = $this->ressources[3]; |
if (!in_array($type, array('homonymie', 'synonymie', 'flores'))) { |
$e = "Les types disponibles pour les noms sont homonymie, synonymie et flores"; |
if (!in_array($type, array('homonymie', 'synonymie'))) { |
$e = "Les types disponibles pour les noms sont homonymie, synonymie"; |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e); |
} |
} |
214,9 → 214,6 |
case 'synonymie' : |
$this->traiterRessourceIdSynonymie(); |
break; |
case 'flores' : |
$this->traiterRessourceIdFlores(); |
break; |
case 'homonymie' : |
$this->traiterRessourceIdHomonymie(); |
break; |
223,7 → 220,7 |
default : |
$e = 'Erreur dans votre requête </br> Ressources disponibles : <br/> |
<li> noms/#id/relations </li> <li> noms/#id/relations/synonymie </li> |
<li> noms/#id/relations/flores </li> <li> noms/#id/relations/homonymie </li>'; |
<li> noms/#id/relations/homonymie </li>'; |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e); |
break; |
} |
247,17 → 244,6 |
.' WHERE '.$this->requete_condition[0].')'; |
} |
|
public function traiterRessourceIdFlores() { |
$champ_flores = ''; |
foreach ($this->champs_table as $champ) { |
if (preg_match('/^flore_.*$/', $champ)) { |
$champ_flores .= ', '.$champ; |
} |
} |
$this->format_reponse .= '/flores'; |
$this->requete_champ = 'num_nom'.$champ_flores; |
} |
|
public function traiterRessourceStatsRangs() { |
// SELECT count(*) as nombre, rang FROM bdtfx_v2_00 [WHERE rang = 290] GROUP BY rang ORDER BY rang; |
$this->format_reponse .= '/rangs'; |
403,9 → 389,6 |
case 'noms/id/relations/homonymie' : |
$reponse = $this->formaterIdHomonymie($resultat); |
break; |
case 'noms/id/relations/flores' : //ds CommunsNomsTaxons |
$reponse = $this->formaterIdFlores($resultat[0]); |
break; |
case 'noms/stats/annees' : //ds CommunNomsTaxons |
$reponse = $this->formaterStatsAnnee($resultat); |
break; |
442,8 → 425,6 |
$retour_id_rel = array ('entete' => array()); //on initialise pr que l'entete apparaisse en premier lors de l'affichage |
|
//on recupère le resultat de chaque relation (appel du WS correspondant) |
$flores = $this->ajouterRelations('flores'); |
if (isset($flores)) $retour_id_rel['resultat']['flores'] = $flores; |
$homonymes = $this->ajouterRelations('homonymie'); |
if (isset($homonymes)) $retour_id_rel['resultat']['homonymes'] = $homonymes; |
$synonymes = $this->ajouterRelations('synonymie'); |
462,7 → 443,7 |
|
/** |
* Recupere les relations (type de la relation passée en paramètres :[type_relation] = synonymie, homonymie ou |
* flores) par l'appel du web service [version]/noms/#id/relations/[type_relation] |
* ) par l'appel du web service [version]/noms/#id/relations/[type_relation] |
*/ |
public function ajouterRelations($relation) { |
$version = str_replace(Config::get('bdd_table').'_', '', $this->table); |
553,72 → 534,6 |
return $this->getBdd()->recupererTous($requete); |
} |
|
public function formaterIdFlores($resultat) { |
$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp,noms_projets'); |
$this->resultat_req = $resultat; |
$id = array_shift($resultat); |
$reponse['entete']['id'] = $id; |
$synonymes_flores = $this->obtenirSynonymesParNumNomAvecInfosFlore($this->ressources[0]); |
if(is_array($synonymes_flores)) { |
foreach ($synonymes_flores as $synonyme) { |
$nom_sci = $synonyme['nom_sci']; |
$num_nom = $synonyme['num_nom']; |
unset($synonyme['nom_sci']); |
unset($synonyme['num_nom']); |
foreach ($synonyme as $flores => $valeur) { |
if ($valeur != '' && $valeur != '0') { |
$this->afficherInfosFlore($synonyme, $flores, $valeur, $nom_sci, $num_nom); |
} |
} |
} |
} |
|
if ($this->table_retour != array()) { |
$reponse['resultat'] = $this->table_retour; |
$this->table_retour = array(); |
} else { |
$reponse = null; |
} |
return $reponse; |
} |
|
public function getNomCompletFlore($flore) { |
return Config::get($flore.'_texte'); |
} |
|
public function afficherInfosFlore(&$resultat, $flores, $valeur, $nom_sci, $num_nom) { |
$flore = substr($flores,0,strrpos($flores, '_')); |
$projet = $this->noms_projets[$flore]; |
|
//TODO voir si l'on peut factoriser les affectations à la table retour |
// et simplifier ce gros pavé |
if (strrpos($flores, 'num') !== false) { |
if (preg_match('/^([0-9]+)(?:[.]syn[^a-z]*|(.*))?$/', $valeur, $match)) { |
$this->table_retour[$num_nom][$flore]['id'] = $match[1]; |
if ($projet == 'coste') { |
$this->table_retour[$num_nom][$flore]['href'] = $this->ajouterHrefAutreProjet('noms', 'nn_coste:', $match[1], $projet); |
} |
if (isset($match[2]) && $match[2] != '') $this->table_retour[$num_nom][$flore]['cle'] = $match[2]; |
$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore); |
$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci; |
} |
if (isset($resultat[$flore.'_rem']) && !empty($resultat[$flore.'_rem'])) { |
$this->table_retour[$num_nom][$flore]['remarque'] = $resultat[$flore.'_rem']; |
$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore); |
$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci; |
unset($resultat[$flore.'_rem']); |
} |
} elseif (strrpos($flores,'belge') !== false) { |
if (preg_match('/^([0-9]+) (R|S)?$/', $valeur, $match)) { |
if (isset($match[2])) $type = ($match[2] == 'R') ? 'taxons' : 'synonyme'; |
$this->table_retour[$num_nom][$flore]['page'] = $match[1]; |
$this->table_retour[$num_nom][$flore]['type'] = $type; |
$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore); |
$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci; |
} |
} |
} |
|
//+---------------------concerne les resultats pour des requetes de type /noms avec ou sans paramètres-------+ |
|
public function formaterNoms($resultat) { |