Subversion Repositories eFlore/Applications.cel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 11 → Rev 12

/trunk/src/org/tela_botanica/client/modeles/ObservationAsynchroneDAO.java
File deleted
/trunk/src/org/tela_botanica/client/modeles/UtilisateurAsynchroneDAO.java
5,7 → 5,8
*
*/
 
import org.tela_botanica.client.interfaces.iRetourUtilisateur;
import org.tela_botanica.client.CarnetEnLigneModele;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONBoolean;
17,27 → 18,38
 
public class UtilisateurAsynchroneDAO {
 
/**
* Constructeur
* Le modèle associé au DAO
*/
 
public UtilisateurAsynchroneDAO() {
private CarnetEnLigneModele carnetEnLigneModele = null ;
/**
* Constructeur
*/
public UtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) {
this.carnetEnLigneModele=carnetEnLigneModele;
}
 
/**
* Methode de classe d'appel du service gestion identification
*
* @param baseURL :
* URL du service
* @param retour :
* methode appelle en retour d'appel
* Methode de classe d'appel du service gestion identification
* @param baseURL : URL du service
* @param retour : methode appelle en retour d'appel
*/
public void getEtatUtilisateur(final Rafraichissable r) {
 
public void getUtilisateur(String baseURL, final iRetourUtilisateur retour) {
 
// Recherche identifiant utilisateur identifie
 
HTTPRequest.asyncGet(baseURL + "/User/", new ResponseTextHandler() {
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/", new ResponseTextHandler() {
 
public void onCompletion(String str) {
JSONValue jsonValue = JSONParser.parse(str);
45,12 → 57,12
if ((jsonArray = jsonValue.isArray()) != null) {
String identifiant = ((JSONString) jsonArray.get(0))
.stringValue(); // Identifiant utilisateur ou
// identifiant de session si non
// identifie
// identifiant de session si non
// identifie
boolean identifie = ((JSONBoolean) jsonArray.get(1))
.booleanValue(); // Drapeau leve si utilisateur
// deja identifie
retour.onRetour(new Utilisateur(identifiant, identifie));
// deja identifie
r.rafraichir(new Utilisateur(identifiant, identifie),true);
}
}
});
57,58 → 69,55
 
}
 
public void deconnecterUtilisateur(String baseURL,
final iRetourUtilisateur retour, String user) {
 
HTTPRequest.asyncGet(baseURL + "/User/" + user,
 
public void deconnecterUtilisateur(final Rafraichissable r, String user) {
 
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl()+ "/User/" + user ,
new ResponseTextHandler() {
 
public void onCompletion(String str) {
 
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
String identifiant = ((JSONString) jsonArray.get(0))
.stringValue(); // Identifiant utilisateur
// ou
// identifiant de session si non
// identifie
boolean identifie = ((JSONBoolean) jsonArray.get(1))
.booleanValue(); // Drapeau leve si
// utilisateur
// deja identifie
 
retour.onRetour(new Utilisateur(identifiant,
identifie));
}
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
if ((jsonArray = jsonValue.isArray()) != null) {
String identifiant = ((JSONString) jsonArray.get(0))
.stringValue(); // Identifiant utilisateur ou
// identifiant de session si non
// identifie
boolean identifie = ((JSONBoolean) jsonArray.get(1))
.booleanValue(); // Drapeau leve si utilisateur
// deja identifie
r.rafraichir(new Utilisateur(identifiant, identifie),true);
}
}
});
});
}
 
public void connecteUtilisateur(String baseURL,
final iRetourUtilisateur retour, String login, String password) {
 
HTTPRequest.asyncGet(baseURL + "/User/" + login + "/" + password,
 
public void connecteUtilisateur (final Rafraichissable r, String login, String password) {
 
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/" + login + "/" + password ,
new ResponseTextHandler() {
 
public void onCompletion(String str) {
 
JSONValue jsonValue = JSONParser.parse(str);
JSONArray jsonArray;
 
if ((jsonArray = jsonValue.isArray()) != null) {
String identifiant = ((JSONString) jsonArray.get(0))
.stringValue(); // Identifiant utilisateur
// ou
// identifiant de session si non
// identifie
.stringValue(); // Identifiant utilisateur ou
// identifiant de session si non
// identifie
boolean identifie = ((JSONBoolean) jsonArray.get(1))
.booleanValue(); // Drapeau leve si
// utilisateur
// deja identifie
.booleanValue(); // Drapeau leve si utilisateur
// deja identifie
 
retour.onRetour(new Utilisateur(identifiant,
identifie));
r.rafraichir(new Utilisateur(identifiant, identifie),true);
}
}
});
115,4 → 124,7
 
}
 
 
 
 
}
/trunk/src/org/tela_botanica/client/modeles/ReferentielCommune.java
New file
0,0 → 1,47
package org.tela_botanica.client.modeles;
 
/**
*
* Classe representant un element du referentiel commune ou localite
*
*/
 
public class ReferentielCommune {
 
 
private String commune=null;
private String departement=null;
public ReferentielCommune() {
}
 
/**
* @param commune
* @param departement
*/
public ReferentielCommune(String commune, String departement) {
this.commune = commune;
this.departement = departement;
 
}
 
 
 
public String getCommune() {
return commune;
}
 
 
public String getDepartement() {
return departement;
}
 
 
 
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/src/org/tela_botanica/client/modeles/ListeReferentielCommune.java
New file
0,0 → 1,50
package org.tela_botanica.client.modeles;
 
import java.util.HashMap;
 
/**
* table de hachage composée d'observation, renvoyé par les objets de type DAO
* pour les images.
* La clé est l'identifiant de l'observation dans la base de données, et la valeur un objet
* de type Observation
* GWT ne supporte pas encore les type paramètres mais quand il le fera il faudra créer la HashMap
* avec <String,Observation>
* @author david delon
*
*/
public class ListeReferentielCommune extends HashMap {
/**
* Constructeur sans paramètres
*/
public ListeReferentielCommune()
{
super();
}
/**
* Constructeur avec paramètre
* @param taille la taille de la table de hachage
*/
public ListeReferentielCommune(int taille)
{
super(taille);
}
/**
* Constructeur avec paramètre
* @param ic un tableau d'ImageCarnet
*/
public ListeReferentielCommune(ReferentielCommune[] com)
{
super() ;
for (int i = 0; i < com.length; i++)
{
if(com[i] != null && com[i] instanceof ReferentielCommune)
{
this.put(com[i].getCommune()+com[i].getDepartement(),com[i]);
}
}
}
 
}
/trunk/src/org/tela_botanica/client/modeles/Observation.java
1,42 → 1,30
package org.tela_botanica.client.modeles;
 
 
public class Observation {
 
private int nombreObservations = 0;
private Observation[] listeObservation = null;
 
private String transmis = null;
private String nomSaisi = null;
private String nomRetenu = null;
private String numeroNomenclatural = null;
private String numeroTaxonomique = null;
private String famille = null;
private String localite = null;
private String lieudit = null;
private String station = null;
private String milieu = null;
private String commentaire = null;
private String date = null;
private String numeroOrdre = null;
private String transmis=null;
private String nomSaisi=null;
private String nomRetenu=null;
private String numeroNomenclatural=null;
private String numeroTaxonomique=null;
private String famille=null;
private String localite=null;
private String lieudit=null;
private String station=null;
private String milieu=null;
private String commentaire=null;
private String date=null;
private String numeroOrdre=null;
 
 
public Observation() {
}
 
/**
* Constructeur nombre total d'observations
*
* @param i
*/
 
public Observation(int i) {
nombreObservations = i;
}
 
public int getNombreObservations() {
return nombreObservations;
}
 
/**
* @param transmis
* @param nomSaisi
* @param nomRetenu
51,11 → 39,8
* @param date
* @param numeroOrdre
*/
public Observation(String transmis, String nomSaisi, String nomRetenu,
String numeroNomenclatural, String numeroTaxonomique,
String famille, String localite, String lieudit, String station,
String milieu, String commentaire, String date, String numeroOrdre) {
 
public Observation(String transmis, String nomSaisi, String nomRetenu, String numeroNomenclatural, String numeroTaxonomique, String famille, String localite, String lieudit, String station, String milieu, String commentaire, String date, String numeroOrdre) {
this.transmis = transmis;
this.nomSaisi = nomSaisi;
this.nomRetenu = nomRetenu;
69,19 → 54,74
this.commentaire = commentaire;
this.date = date;
this.numeroOrdre = numeroOrdre;
}
 
 
 
public String getNomSaisi() {
return nomSaisi;
}
 
public Observation(Observation[] listeObservation) {
this.listeObservation = listeObservation;
 
public String getNumeroOrdre() {
return numeroOrdre;
}
 
public Observation[] getListeObservation() {
return listeObservation;
 
public String getCommentaire() {
return commentaire;
}
 
public String getNomSaisi() {
return nomSaisi;
 
public String getDate() {
return date;
}
 
 
public String getFamille() {
return famille;
}
 
 
public String getLieudit() {
return lieudit;
}
 
 
public String getLocalite() {
return localite;
}
 
 
public String getMilieu() {
return milieu;
}
 
 
public String getNomRetenu() {
return nomRetenu;
}
 
 
public String getNumeroNomenclatural() {
return numeroNomenclatural;
}
 
 
public String getNumeroTaxonomique() {
return numeroTaxonomique;
}
 
 
public String getStation() {
return station;
}
 
 
public String getTransmis() {
return transmis;
}
 
}
/trunk/src/org/tela_botanica/client/modeles/ListeObservation.java
New file
0,0 → 1,50
package org.tela_botanica.client.modeles;
 
import java.util.HashMap;
 
/**
* table de hachage composée d'observation, renvoyé par les objets de type DAO
* pour les images.
* La clé est l'identifiant de l'observation dans la base de données, et la valeur un objet
* de type Observation
* GWT ne supporte pas encore les type paramètres mais quand il le fera il faudra créer la HashMap
* avec <String,Observation>
* @author david delon
*
*/
public class ListeObservation extends HashMap {
/**
* Constructeur sans paramètres
*/
public ListeObservation()
{
super();
}
/**
* Constructeur avec paramètre
* @param taille la taille de la table de hachage
*/
public ListeObservation(int taille)
{
super(taille);
}
/**
* Constructeur avec paramètre
* @param ic un tableau d'ImageCarnet
*/
public ListeObservation(Observation[] obs)
{
super() ;
for (int i = 0; i < obs.length; i++)
{
if(obs[i] != null && obs[i] instanceof Observation)
{
this.put(obs[i].getNumeroOrdre(),obs[i]);
}
}
}
 
}
/trunk/src/org/tela_botanica/client/modeles/ListeReferentielCommuneAsynchroneDAO.java
New file
0,0 → 1,98
package org.tela_botanica.client.modeles;
 
import org.tela_botanica.client.Util;
import org.tela_botanica.client.interfaces.FournisseurListe;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.observation.ObservationModele;
 
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
 
/**
* DAO la liste des observations attachées a un observateur
* @author David Delon
*
*/
public class ListeReferentielCommuneAsynchroneDAO implements FournisseurListe {
 
/**
* Le modèle associé au DAO
*/
private ObservationModele observationModele = null ;
public ListeReferentielCommuneAsynchroneDAO(ObservationModele observationModele)
{
this.observationModele=observationModele;
}
/**
* Envoie une requete au serveur jrest pour obtenir les communes correspondant
* à des critères données en paramètres
* @param r le rafraichissable qui demande la mise à jour
* @param criteres un string contenant le terme a rechercher
*/
public void obtenirListeDonnees(final Rafraichissable r, String critere)
{
// on envoie le get asynchrone
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/LocationSearch/"+critere, new ResponseTextHandler() {
 
// si tout se passe bien on reçoit une réponse JSON
public void onCompletion(String responseText) {
 
final ListeReferentielCommune referentielCommuneData ;
final JSONValue responseValue = JSONParser.parse(responseText);
JSONArray reponse=null;
// si c'est un tableau
if ((reponse=responseValue.isArray()) != null) {
JSONArray communes;
final int taillemax = reponse.size();
referentielCommuneData = new ListeReferentielCommune(taillemax);
for (int i = 0; i < taillemax; i++) {
if ((communes=reponse.get(i).isArray()) != null) {
String commune=((JSONString) communes.get(0)).stringValue();
String departement=((JSONString) communes.get(0)).stringValue();
ReferentielCommune com=new ReferentielCommune(commune, departement);
referentielCommuneData.put(com.getCommune()+com.getDepartement(),com);
}
}
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est
// le premier à les recevoir
r.rafraichir(referentielCommuneData,true);
}
}
});
}
}
/trunk/src/org/tela_botanica/client/modeles/Utilisateur.java
2,21 → 2,21
 
public class Utilisateur {
 
private String identifiant = null;
private boolean identifie = false;
private String identifiant=null;
private boolean identifie=false;
 
public Utilisateur(String identifiant, boolean identifie) {
this.identifiant = identifiant;
this.identifie = identifie;
this.identifiant=identifiant;
this.identifie=identifie;
}
 
/**
* Retourne l'identifiant de l'utilisateur identifie ou un identifiant de
* session
*
* Retourne l'identifiant de l'utilisateur identifie ou un identifiant de session
* @return String identifiant
*/
 
public String getIdentifiant() {
return identifiant;
}
23,12 → 23,11
 
/**
* Retourne vrai si utilisateur identifie
*
* @return boolean
*/
 
public boolean isIdentifie() {
return identifie;
}
 
}
/trunk/src/org/tela_botanica/client/modeles/ListeObservationAsynchroneDAO.java
New file
0,0 → 1,121
package org.tela_botanica.client.modeles;
 
import org.tela_botanica.client.Util;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.observation.ObservationModele;
 
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
 
/**
* DAO la liste des observations attachées a un observateur
* @author David Delon
*
*/
public class ListeObservationAsynchroneDAO {
 
/**
* Le modèle associé au DAO
*/
private ObservationModele observationModele = null ;
public ListeObservationAsynchroneDAO(ObservationModele observationModele)
{
this.observationModele=observationModele;
}
/**
* Envoie une requete au serveur jrest pour obtenir le nombre d'observation correspondant
* à des critères données en paramètres
* @param r le rafraichissable qui demande la mise à jour
* @param criteres un tableau nom/valeur des critères pour les observations
*/
public void obtenirListeObservation(final Rafraichissable r, String utilisateur, String[][] criteres)
{
String requete = "" ;
if(criteres != null)
{
// on construit les paramètres du get avec les critères (&critere1=valeur1&critere2=valeur2 etc...)
// ils contiennent limite et taille page
for (int i = 0; i < criteres.length; i++) {
if(!criteres[i][1].equals(""))
{
if(i!= 0)
{
requete += "&";
}
requete += criteres[i][0]+"="+criteres[i][1] ;
}
}
}
// on envoie le get asynchrone
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationList/"+utilisateur+"/"+requete, new ResponseTextHandler() {
// si tout se passe bien on reçoit une réponse JSON
public void onCompletion(String responseText) {
final ListeObservation observationData ;
final JSONValue responseValue = JSONParser.parse(responseText);
JSONArray reponse=null;
// si c'est un tableau
if ((reponse=responseValue.isArray()) != null) {
JSONArray observation;
final int taillemax = reponse.size();
observationData = new ListeObservation(taillemax);
for (int i = 0; i < taillemax; i++) {
if ((observation=reponse.get(i).isArray()) != null) {
String transmis=((JSONString) observation.get(13)).stringValue();
String nomSaisi=Util.toCelString(((JSONString) observation.get(0)).toString());
String nomRetenu=Util.toCelString(((JSONString) observation.get(2)).toString());
String numeroNomenclatural=((JSONString) observation.get(3)).stringValue();
String numeroTaxonomique=((JSONString) observation.get(4)).stringValue();
String famille=Util.toCelString(((JSONString) observation .get(5)).toString());
String localite=Util.toCelString(((JSONString) observation .get(6)).toString());
String lieudit=Util.toCelString(((JSONString) observation .get(9)).toString());
String station=Util.toCelString(((JSONString) observation .get(10)).toString());
String milieu=Util.toCelString(((JSONString) observation .get(11)).toString());
String commentaire=Util.toCelString(((JSONString) observation .get(12)).toString());
String date=((JSONString) observation .get(8)).stringValue();
String numeroOrdre=((JSONString) observation.get(7)).stringValue();
Observation obs=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclatural, numeroTaxonomique, famille, localite, lieudit, station, milieu, commentaire, date, numeroOrdre);
observationData.put(obs.getNumeroOrdre(),obs);
}
}
// dans tous les cas on transmet la liste crée au rafraichissable en lui demandant de répandre les données car il est
// le premier à les recevoir
r.rafraichir(observationData,true);
}
}
});
}
}
/trunk/src/org/tela_botanica/client/modeles/NombreObservationAsynchroneDAO.java
New file
0,0 → 1,83
package org.tela_botanica.client.modeles;
 
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.observation.ObservationModele;
 
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
 
/**
* DAO qui renvoie le nombre d'image associées à différents critères donnés (utile pour la pagination)
* @author aurelien
*
*/
public class NombreObservationAsynchroneDAO {
 
 
/**
* Le modèle associé au DAO
*/
private ObservationModele observationModele = null ;
public NombreObservationAsynchroneDAO(ObservationModele observationModele)
{
this.observationModele=observationModele;
}
/**
* Envoie une requete au serveur jrest pour obtenir le nombre d'observation correspondant
* à des critères données en paramètres
* @param r le rafraichissable qui demande la mise à jour
* @param criteres un tableau nom/valeur des critères pour les images
*/
public void obtenirNombreObservation(final Rafraichissable r, String utilisateur, String[][] criteres)
{
String requete = "" ;
if(criteres != null)
{
// on construit les paramètres du get avec les critères (&critere1=valeur1&critere2=valeur2 etc...)
for (int i = 0; i < criteres.length; i++) {
if(!criteres[i][1].equals(""))
{
if(i!= 0)
{
requete += "&";
}
requete += criteres[i][0]+"="+criteres[i][1] ;
}
}
}
// on fait un get asynchrone
HTTPRequest.asyncGet(observationModele.getConfig().getServiceBaseUrl()+"/InventoryObservationCount/"+utilisateur+"/"+requete, new ResponseTextHandler() {
public void onCompletion(String responseText) {
final JSONValue responseValue = JSONParser.parse(responseText);
// si la requete se passe bien on reçoit un tableau JSON
if(responseValue.isArray() != null)
{
// qui contient une valeur : le nombre d'images correspondant au critères
JSONValue res = responseValue.isArray().get(0) ;
JSONString reponseNombre = res.isString() ;
int maxObservations = Integer.parseInt(reponseNombre.stringValue()) ;
int[] nbObservations = {maxObservations} ;
// on le met dans un tableau d'entiers qu'on tranmset au demandeur de la mise à jour
r.rafraichir(nbObservations, true) ;
}
}
}) ;
}
}