Subversion Repositories eFlore/Applications.moissonnage

Compare Revisions

Ignore whitespace Rev 30 → Rev 31

/trunk/services/modules/0.1/commun/Commun.php
12,27 → 12,25
public function consulter($ressources, $parametres) {
$this->recupererRessourcesEtParametres($ressources, $parametres);
$retour = null;
try {
if (!$this->verifierExistenceSourcesDonnees()) {
$message = "Source de donnees indisponible";
throw new Exception($message, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
} else {
$this->chargerNomSource();
$this->verifierParametres();
$this->chargerNomService();
$objetTraitement = new $this->nomService($this->parametresRecherche);
$methode = $this->genererNomMethodeAExecuter();
$retour = $objetTraitement->$methode();
if ($this->ressources[0] == 'mailles') {
$retour = $this->recupererMaillage();
} else {
$this->chargerNomSource();
$this->chargerNomService();
$retour = $this->executerServicePourSource();
}
}
} catch (Exception $erreur) {
$retour = $erreur;
}
return $retour;
}
41,15 → 39,6
$this->parametres = $parametres;
}
private function chargerNomService() {
$this->nomService = ucfirst($this->parametres['source']) . 'Formateur';
Projets::chargerConfigurationSource($this->parametres['source']);
}
private function genererNomMethodeAExecuter() {
return 'recuperer' . ucfirst($this->ressources[0]);
}
private function verifierExistenceSourcesDonnees() {
$sourcesDisponibles = explode(',', Config::get('sources_dispo'));
$estDisponible = false;
64,14 → 53,6
return $estDisponible;
}
private function chargerNomSource() {
if (isset($this->parametres['source'])) {
$this->nomSource = $this->parametres['source'];
} else {
$this->nomSource = Config::get('source_defaut');
}
}
private function verifierParametres() {
$this->verificateur = new VerificateurParametres($this->parametres);
$this->verificateur->verifierParametres();
86,7 → 67,36
$this->parametresRecherche = $this->verificateur->renvoyerResultatVerification();
}
private function chargerNomSource() {
if (isset($this->parametres['source'])) {
$this->nomSource = $this->parametres['source'];
} else {
$this->nomSource = Config::get('source_defaut');
}
}
private function chargerNomService() {
$this->nomService = ucfirst($this->parametres['source']) . 'Formateur';
Projets::chargerConfigurationSource($this->parametres['source']);
}
private function recupererMaillage() {
$maillage = new Maillage($this->parametresRecherche->bbox, $this->parametresRecherche->zoom);
$maillage->genererMaillesVides();
$formateurJSON = new FormateurJson();
return $formateurJSON->formaterMaillesVides($maillage->formaterSortie(true));
}
private function executerServicePourSource() {
$objetTraitement = new $this->nomService($this->parametresRecherche);
$methode = $this->genererNomMethodeAExecuter();
return $objetTraitement->$methode();
}
private function genererNomMethodeAExecuter() {
return 'recuperer' . ucfirst($this->ressources[0]);
}
}
 
?>