/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; |
19,15 → 20,25 |
/** |
* Le modèle associé au DAO |
*/ |
private CarnetEnLigneModele carnetEnLigneModele = null ; |
/** |
* Constructeur |
*/ |
public UtilisateurAsynchroneDAO() { |
public UtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) { |
this.carnetEnLigneModele=carnetEnLigneModele; |
} |
/** |
* Methode de classe d'appel du service gestion identification |
* @param baseURL : URL du service |
34,11 → 45,11 |
* @param retour : methode appelle en retour d'appel |
*/ |
public void getUtilisateur(String baseURL, final iRetourUtilisateur retour) { |
public void getEtatUtilisateur(final Rafraichissable r) { |
// 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); |
51,7 → 62,7 |
boolean identifie = ((JSONBoolean) jsonArray.get(1)) |
.booleanValue(); // Drapeau leve si utilisateur |
// deja identifie |
retour.onRetour(new Utilisateur(identifiant, identifie)); |
r.rafraichir(new Utilisateur(identifiant, identifie),true); |
} |
} |
}); |
60,9 → 71,9 |
public void deconnecterUtilisateur(String baseURL, final iRetourUtilisateur retour, String user) { |
public void deconnecterUtilisateur(final Rafraichissable r, String user) { |
HTTPRequest.asyncGet(baseURL + "/User/" + user , |
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl()+ "/User/" + user , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
78,8 → 89,7 |
.booleanValue(); // Drapeau leve si utilisateur |
// deja identifie |
retour.onRetour(new Utilisateur(identifiant, identifie)); |
r.rafraichir(new Utilisateur(identifiant, identifie),true); |
} |
} |
}); |
87,9 → 97,9 |
public void connecteUtilisateur(String baseURL,final iRetourUtilisateur retour, String login, String password) { |
public void connecteUtilisateur (final Rafraichissable r, String login, String password) { |
HTTPRequest.asyncGet(baseURL + "/User/" + login + "/" + password , |
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/" + login + "/" + password , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
107,7 → 117,7 |
// deja identifie |
retour.onRetour(new Utilisateur(identifiant, identifie)); |
r.rafraichir(new Utilisateur(identifiant, identifie),true); |
} |
} |
}); |
114,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; |
} |
} |
/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 |
---|
4,9 → 4,6 |
public class Observation { |
private int nombreObservations=0; |
private Observation [] listeObservation=null; |
private String transmis=null; |
private String nomSaisi=null; |
private String nomRetenu=null; |
28,22 → 25,6 |
/** |
* Constructeur nombre total d'observations |
* @param i |
*/ |
public Observation(int i) { |
nombreObservations=i; |
} |
public int getNombreObservations() { |
return nombreObservations; |
} |
/** |
* @param transmis |
* @param nomSaisi |
* @param nomRetenu |
77,19 → 58,70 |
} |
public Observation(Observation[] listeObservation) { |
this.listeObservation=listeObservation; |
public String getNomSaisi() { |
return nomSaisi; |
} |
public Observation[] getListeObservation() { |
return listeObservation; |
public String getNumeroOrdre() { |
return numeroOrdre; |
} |
public String getNomSaisi() { |
return nomSaisi; |
public String getCommentaire() { |
return commentaire; |
} |
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/Configuration.java |
---|
New file |
0,0 → 1,43 |
package org.tela_botanica.client.modeles; |
import com.google.gwt.i18n.client.Dictionary; |
/** |
* Classe chargeant certains paramètres de configuration à partir d'un fichier |
* javascript (config.js) |
* |
* @author aurelien |
* |
*/ |
public class Configuration { |
/** |
* L'url de base du serveur jrest |
*/ |
private String serviceBaseUrl; |
private String imageBaseUrl; |
/** |
* Constructeur sans argument |
*/ |
public Configuration() { |
// on utilise le dictionnaire d'internationalisation pour lire les |
// variables du fichier javascript |
Dictionary theme = Dictionary.getDictionary("configuration"); |
serviceBaseUrl=theme.get("serviceBaseUrl"); |
} |
/** |
* Accesseur pour l'url de base du serveur jrest |
* |
* @return une url de la forme http://emplacement_serveur/jrest |
*/ |
public String getServiceBaseUrl() { |
return serviceBaseUrl; |
} |
} |
/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/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) ; |
} |
} |
}) ; |
} |
} |