/trunk/src/org/tela_botanica/client/modeles/Utilisateur.java |
---|
New file |
0,0 → 1,33 |
package org.tela_botanica.client.modeles; |
public class Utilisateur { |
private String identifiant=null; |
private boolean identifie=false; |
public Utilisateur(String identifiant, boolean identifie) { |
this.identifiant=identifiant; |
this.identifie=identifie; |
} |
/** |
* Retourne l'identifiant de l'utilisateur identifie ou un identifiant de session |
* @return String identifiant |
*/ |
public String getIdentifiant() { |
return identifiant; |
} |
/** |
* Retourne vrai si utilisateur identifie |
* @return boolean |
*/ |
public boolean isIdentifie() { |
return identifie; |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/Observation.java |
---|
New file |
0,0 → 1,95 |
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; |
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 |
* @param numeroNomenclatural |
* @param numeroTaxonomique |
* @param famille |
* @param localite |
* @param lieudit |
* @param station |
* @param milieu |
* @param commentaire |
* @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) { |
this.transmis = transmis; |
this.nomSaisi = nomSaisi; |
this.nomRetenu = nomRetenu; |
this.numeroNomenclatural = numeroNomenclatural; |
this.numeroTaxonomique = numeroTaxonomique; |
this.famille = famille; |
this.localite = localite; |
this.lieudit = lieudit; |
this.station = station; |
this.milieu = milieu; |
this.commentaire = commentaire; |
this.date = date; |
this.numeroOrdre = numeroOrdre; |
} |
public Observation(Observation[] listeObservation) { |
this.listeObservation=listeObservation; |
} |
public Observation[] getListeObservation() { |
return listeObservation; |
} |
public String getNomSaisi() { |
return nomSaisi; |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/UtilisateurAsynchroneDAO.java |
---|
New file |
0,0 → 1,117 |
package org.tela_botanica.client.modeles; |
/** |
* Modele DAO, specifique, permettant la validation, l'acces aux donnees distantes et la présentation des donnees en retour |
* |
*/ |
import org.tela_botanica.client.interfaces.iRetourUtilisateur; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONBoolean; |
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; |
public class UtilisateurAsynchroneDAO { |
/** |
* Constructeur |
*/ |
public UtilisateurAsynchroneDAO() { |
} |
/** |
* Methode de classe d'appel du service gestion identification |
* @param baseURL : URL du service |
* @param retour : methode appelle en retour d'appel |
*/ |
public void getUtilisateur(String baseURL, final iRetourUtilisateur retour) { |
// Recherche identifiant utilisateur identifie |
HTTPRequest.asyncGet(baseURL + "/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)); |
} |
} |
}); |
} |
public void deconnecterUtilisateur(String baseURL, final iRetourUtilisateur retour, String user) { |
HTTPRequest.asyncGet(baseURL + "/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)); |
} |
} |
}); |
} |
public void connecteUtilisateur(String baseURL,final iRetourUtilisateur retour, String login, String password) { |
HTTPRequest.asyncGet(baseURL + "/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 |
boolean identifie = ((JSONBoolean) jsonArray.get(1)) |
.booleanValue(); // Drapeau leve si utilisateur |
// deja identifie |
retour.onRetour(new Utilisateur(identifiant, identifie)); |
} |
} |
}); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/ObservationAsynchroneDAO.java |
---|
New file |
0,0 → 1,119 |
package org.tela_botanica.client.modeles; |
/** |
* Modele DAO, specifique, permettant la validation, l'acces aux donnees distantes et la présentation des donnees en retour |
* |
*/ |
import net.mygwt.ui.client.widget.table.TableItem; |
import org.tela_botanica.client.Util; |
import org.tela_botanica.client.interfaces.iRetourObservation; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
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; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.Image; |
public class ObservationAsynchroneDAO { |
/** |
* Constructeur |
*/ |
public ObservationAsynchroneDAO() { |
} |
// TODO Classe Filtre pour les parametres ? |
public void getNombreObservation(String baseURL, final iRetourObservation retour, String identifiant, String identifiantLocalite, String localite, String annee, String mois, String jour, String lieudit, String rechercheLibre) { |
HTTPRequest.asyncGet(baseURL + "/InventoryItemList/" + identifiant + "/" + identifiantLocalite + "/" + URL.encodeComponent(localite) + "/" + annee + "/" + mois + "/" + jour + "/" + URL.encodeComponent(rechercheLibre) + "/" + URL.encodeComponent(lieudit), |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
retour.onRetour(new Observation((int) jsonNumber.getValue())); |
} |
} |
}); |
} |
public void getListeObservation(String baseURL,final iRetourObservation retour, String identifiant, String identifiantLocalite, String localite, String annee, String mois, String jour, String lieudit, String rechercheLibre, int debut, int longueur) |
{ |
HTTPRequest.asyncGet(baseURL + "/InventoryItemList/" + identifiant + "/" + identifiantLocalite + "/" + URL.encodeComponent(localite) +"/" + annee + "/" + mois + "/" + jour + "/" + URL.encodeComponent(rechercheLibre) + "/" + URL.encodeComponent(lieudit) + "/" |
+ debut + "/" + longueur , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
if ((jsonArray = jsonValue.isArray()) != null) { |
if ((jsonArray = jsonValue.isArray()) != null) { |
int arraySize = jsonArray.size(); |
Observation[] listeObservation=new Observation[arraySize]; |
for (int i = 0; i < arraySize; i++) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
String transmis=((JSONString) jsonArrayNested.get(13)).stringValue(); |
String nomSaisi=Util.toCelString(((JSONString) jsonArrayNested.get(0)).toString()); |
String nomRetenu=Util.toCelString(((JSONString) jsonArrayNested.get(2)).toString()); |
String numeroNomenclatural=((JSONString) jsonArrayNested.get(3)).stringValue(); |
String numeroTaxonomique=((JSONString) jsonArrayNested.get(4)).stringValue(); |
String famille=Util.toCelString(((JSONString) jsonArrayNested .get(5)).toString()); |
String localite=Util.toCelString(((JSONString) jsonArrayNested .get(6)).toString()); |
String lieudit=Util.toCelString(((JSONString) jsonArrayNested .get(9)).toString()); |
String station=Util.toCelString(((JSONString) jsonArrayNested .get(10)).toString()); |
String milieu=Util.toCelString(((JSONString) jsonArrayNested .get(11)).toString()); |
String commentaire=Util.toCelString(((JSONString) jsonArrayNested .get(12)).toString()); |
String date=((JSONString) jsonArrayNested .get(8)).stringValue(); |
String numeroOrdre=((JSONString) jsonArrayNested.get(7)).stringValue(); |
listeObservation[i]=new Observation(transmis, nomSaisi, nomRetenu, numeroNomenclatural, numeroTaxonomique, famille, localite, lieudit, station, milieu, commentaire, date, numeroOrdre); |
} |
} |
retour.onRetour(new Observation(listeObservation)); |
} |
} |
} |
}); |
} |
} |