/trunk/src/org/tela_botanica/client/modeles/aDonnee.java |
---|
58,6 → 58,39 |
} |
} |
protected String getInfoDenormaliseParType(String chaineExistante, String type) { |
String sortie = ""; |
if (!chaineExistante.equals("")) { |
String[] valeurs = chaineExistante.split(";;"); |
for (int i = 0; i < valeurs.length; i++) { |
if (valeurs[i].startsWith(type+"##")) { |
sortie = valeurs[i].replaceFirst("^"+type+"##", ""); |
} |
} |
} |
return sortie; |
} |
protected String getInfoDenormaliseParPosition(String chaineExistante, int position) { |
String sortie = ""; |
if (!chaineExistante.equals("")) { |
String[] valeurs = chaineExistante.split(";;"); |
if (valeurs.length >= position) { |
for (int i = 0; i < valeurs.length; i++) { |
if (i == (position - 1)) { |
if (valeurs[i].contains("##")) { |
sortie = valeurs[i].replaceFirst("^[^#]+##", ""); |
} else { |
sortie = valeurs[i]; |
} |
break; |
} |
} |
} |
} |
return sortie; |
} |
public String getDateModification() { |
return (String) renvoyerValeurCorrecte("cmhl_date_modification"); |
} |
/trunk/src/org/tela_botanica/client/modeles/StructureAPersonne.java |
---|
New file |
0,0 → 1,237 |
package org.tela_botanica.client.modeles; |
import java.util.Iterator; |
import java.util.List; |
import java.util.Set; |
import com.extjs.gxt.ui.client.widget.form.CheckBox; |
import com.google.gwt.json.client.JSONObject; |
public class StructureAPersonne extends aDonnee { |
public static final String ROLE_ADMIN = "2026"; |
public static final String ROLE_EQUIPE = "2027"; |
public static final String PREFIXE = "csap"; |
/** |
* Constructeur vide |
* |
*/ |
public StructureAPersonne() { |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
this.set("contact", false); |
} |
/** |
* Constructeur avec un objet JSON |
* |
* @param |
*/ |
public StructureAPersonne(JSONObject personnel) { |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
this.set("contact", false); |
// L'objet JSON est une table de hachage |
Set<String> im = personnel.keySet(); |
// Parcourt pour chaque clé |
for (Iterator<String> it = im.iterator(); it.hasNext();) { |
// Si elle est associée à une valeur, nous l'ajoutons |
String cle = it.next(); |
if (cle.startsWith(PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (personnel.get(cle).isString() != null) { |
valeur = personnel.get(cle).isString().stringValue(); |
} |
this.set(cleObjet, valeur); |
if (cle.equals("mark_contact")) { |
this.set("contact", (valeur.equals("1") ? true : false)); |
} else if (cle.equals("bota_travail_hebdo_tps")) { |
this.set("travail", Integer.parseInt(valeur)); |
} |
} |
if (cle.startsWith(Personne.PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (personnel.get(cle).isString() != null) { |
valeur = personnel.get(cle).isString().stringValue(); |
} |
if (cleObjet.equals("truk_telephone")) { |
this.set("telephone", getInfoDenormaliseParType(valeur, "FIX")); |
} else if (cleObjet.equals("truk_fax")) { |
this.set("fax", getInfoDenormaliseParPosition(valeur, 1)); |
} else if (cleObjet.equals("truk_courriel")) { |
this.set("courriel", getInfoDenormaliseParPosition(valeur, 1)); |
} else if (cleObjet.equals("ce_truk_specialite")) { |
this.set("specialite", getInfoDenormaliseParPosition(valeur, 1)); |
} else { |
this.set(cleObjet, valeur); |
} |
} |
} |
} |
/** |
* Constructeur avec la fonction à passer en paramètre |
* |
* @param image |
*/ |
public StructureAPersonne(String fonction) { |
setFonction(fonction); |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
this.set("contact", false); |
} |
// ID |
/** Génère un identifiant de StructureAPersonne. |
* |
* C'est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-". |
* |
* @return identifiant unique d'une relation "structure à personne". |
*/ |
public String getId() { |
return (renvoyerValeurCorrecte("id_structure")+"-"+renvoyerValeurCorrecte("id_personne")+"-"+renvoyerValeurCorrecte("id_role")); |
} |
//+---------------------------------------------------------------------------------------------------------------+ |
// CHAMPS PROVENANT de la TABLE COEL_STRUCTURE_A_PERSONNE |
// ID STRUCTURE |
public String getIdStructure() { |
return renvoyerValeurCorrecte("id_structure"); |
} |
public void setIdStructure(String is) { |
this.set("id_structure", is); |
} |
// ID PERSONNE |
public String getIdPersonne() { |
return renvoyerValeurCorrecte("id_personne"); |
} |
public void setIdPersonne(String ip) { |
this.set("id_personne", ip); |
} |
// ID RôLE |
public String getIdRole() { |
return renvoyerValeurCorrecte("id_role"); |
} |
public void setIdRole(String ir) { |
this.set("id_role", ir); |
} |
// FONCTION |
public String getFonction() { |
String fonction = renvoyerValeurCorrecte("ce_truk_fonction"); |
if (fonction.equals(Valeur.FONCTION_DIRECTEUR)) { |
return "Directeur"; |
} else if (fonction.equals(Valeur.FONCTION_CONSERVATEUR)) { |
return "Conservateur"; |
} else { |
return ""; |
} |
} |
public void setFonction(String ctf) { |
this.set("ce_truk_fonction", ctf); |
} |
public void setFonction(String type, Object valeur) { |
setChaineDenormalise("ce_truk_fonction", type, valeur); |
} |
// SERVICE |
public String getService() { |
return renvoyerValeurCorrecte("service"); |
} |
public void setService(String s) { |
this.set("service", s); |
} |
// STATUT |
public String getStatut() { |
return renvoyerValeurCorrecte("ce_truk_statut"); |
} |
public void setStatut(String cts) { |
this.set("ce_truk_statut", cts); |
} |
public void setSatut(String type, Object valeur) { |
setChaineDenormalise("ce_truk_statut", type, valeur); |
} |
// CONTACT |
public String getContact() { |
return renvoyerValeurCorrecte("mark_contact"); |
} |
public void setContact(String c) { |
this.set("contact", (c.equals("1") ? true : false)); |
this.set("mark_contact", c); |
} |
public void setContact(Boolean c) { |
setContact((c.equals(Boolean.TRUE) ? "1" : "0")); |
} |
// BOTA TRAVAIL HEBDO TPS |
public String getBotaTravailHebdoTps() { |
return renvoyerValeurCorrecte("bota_travail_hebdo_tps"); |
} |
public void setBotaTravailHebdoTps(String btht) { |
this.set("bota_travail_hebdo_tps", btht); |
} |
//+---------------------------------------------------------------------------------------------------------------+ |
// CHAMPS PROVENANT de la TABLE COEL_PERSONNE |
// PRÉNOM |
public String getPrenom() { |
return renvoyerValeurCorrecte("prenom"); |
} |
public void setPrenom(String p) { |
this.set("prenom", p); |
} |
// NOM |
public String getNom() { |
return renvoyerValeurCorrecte("nom"); |
} |
public void setNom(String n) { |
this.set("nom", n); |
} |
// TÉLÉPHONE |
public String getTelephone() { |
return renvoyerValeurCorrecte("telephone"); |
} |
public void setTelephone(String t) { |
this.set("telephone", t); |
} |
// FAX |
public String getFax() { |
return renvoyerValeurCorrecte("fax"); |
} |
public void setFax(String f) { |
this.set("fax", f); |
} |
// COURRIEL |
public String getCourriel() { |
return renvoyerValeurCorrecte("courriel"); |
} |
public void setCourriel(String c) { |
this.set("courriel", c); |
} |
// SPÉCIALITÉ |
public String getSpecialite() { |
return renvoyerValeurCorrecte("specialite"); |
} |
public void setSpecialite(String s) { |
this.set("specialite", s); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/StructureAPersonneListe.java |
---|
New file |
0,0 → 1,51 |
package org.tela_botanica.client.modeles; |
import java.util.LinkedHashMap; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
/** |
* Table de hachage composée d'informations sur les Structures et les Personnes, renvoyé par un objet de type DAO |
* La clé est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-". |
* |
* @author david delon |
* |
*/ |
public class StructureAPersonneListe extends LinkedHashMap<String, StructureAPersonne> { |
/** |
* Constructeur sans paramètres |
*/ |
public StructureAPersonneListe() { |
super(); |
} |
/** |
* Constructeur avec paramètre |
* @param taille la taille de la table de hachage |
*/ |
public StructureAPersonneListe(int taille) |
{ |
super(taille); |
} |
/** |
* Constructeur pour une liste de StructureAPersonne |
* @param dates |
*/ |
public StructureAPersonneListe(JSONArray structures) |
{ |
super(structures.size()) ; |
final int taillemax = structures.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject structureAPersonneCourante = structures.get(i).isObject() ; |
if (structureAPersonneCourante != null) { |
StructureAPersonne structureAPersonne = new StructureAPersonne(structureAPersonneCourante); |
this.put(structureAPersonne.getId(), structureAPersonne); |
} |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/StructureAsyncDao.java |
---|
121,7 → 121,7 |
"&cs_telephone =" + URL.encodeComponent(str.getTelephone()) + |
"&cs_fax =" + URL.encodeComponent(str.getFax()) + |
"&cs_truk_url =" + URL.encodeComponent(str.getUrl()) + |
"&cs_nbre_personne =" + URL.encodeComponent(str.getNbrePersonne()) + |
"&cs_nbre_personne =" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) + |
""; |
try { |
267,7 → 267,7 |
"&cs_fax =" + URL.encodeComponent(str.getFax()) + |
"&cs_courriel =" + URL.encodeComponent(str.getCourriel()) + |
"&cs_truk_url =" + URL.encodeComponent(str.getUrl()) + |
"&cs_nbre_personne =" + URL.encodeComponent(str.getNbrePersonne()) + |
"&cs_nbre_personne =" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) + |
"&csc_mark_formation =" + URL.encodeComponent(conservation.getFormation()) + |
"&csc_formation =" + URL.encodeComponent(conservation.getFormationInfo()) + |
"&csc_mark_formation_interet =" + URL.encodeComponent(conservation.getFormationInteret()) + |
/trunk/src/org/tela_botanica/client/modeles/Personne.java |
---|
6,11 → 6,14 |
import com.google.gwt.json.client.JSONObject; |
public class Personne extends aDonnee { |
public static final String PREFIXE = "cp"; |
/** |
* Constructeur vide |
*/ |
public Personne() { |
this.set("mark_contact", false); |
} |
/** |
39,37 → 42,14 |
} |
} |
/** |
* Constructeur avec la fonction à passer en paramètre |
* |
* @param image |
*/ |
public Personne(String fonction) { |
this.set("ce_truk_fonction", fonction); |
this.set("mark_contact", false); |
} |
public String getId() { |
return (String) renvoyerValeurCorrecte("id_personne"); |
} |
public String getFonction() { |
String fonction = (String) renvoyerValeurCorrecte("ce_truk_fonction"); |
if (fonction.equals(Valeur.FONCTION_DIRECTEUR)) { |
return "Directeur"; |
} else if (fonction.equals(Valeur.FONCTION_CONSERVATEUR)) { |
return "Conservateur"; |
} else { |
return ""; |
} |
} |
public String getNom() { |
return (String) renvoyerValeurCorrecte("cp_nom"); |
} |
public String getPrenom() { |
return (String) renvoyerValeurCorrecte("cp_prenom"); |
} |
/trunk/src/org/tela_botanica/client/modeles/StructureValorisation.java |
---|
3,6 → 3,7 |
import java.util.Iterator; |
import java.util.Set; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.json.client.JSONObject; |
public class StructureValorisation extends aDonnee { |
/trunk/src/org/tela_botanica/client/modeles/StructureAPersonneAsyncDao.java |
---|
New file |
0,0 → 1,89 |
package org.tela_botanica.client.modeles; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.http.client.Request; |
import com.google.gwt.http.client.RequestBuilder; |
import com.google.gwt.http.client.RequestCallback; |
import com.google.gwt.http.client.RequestException; |
import com.google.gwt.http.client.Response; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONValue; |
public class StructureAPersonneAsyncDao { |
public void selectionner(final Rafraichissable r, String idUtilisateur, final String idStructure, final String idRole) { |
// Ajout des paramètres et données à selectionner dans l'URL |
final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + |
"CoelStructureAPersonne" + |
(idStructure == null ? "" : "/"+idStructure) + |
(idRole == null ? "" : "/"+idRole) + |
""; |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url); |
try { |
rb.sendRequest(null, new RequestCallback() { |
public void onError(Request request, Throwable exception) { |
// Gestion des exceptions déclenchées par l'exécution de la requête |
GWT.log("Erreur à l'exécution du service CoelStructureAPersonne (selection)", exception); |
Info.display("Erreur de Requête", "Une erreur s'est produite lors de l'exécution de la requête."); |
} |
public void onErrorHTTP(Request request, Response reponse) { |
// Gestion des erreurs HTTP renvoyé par Apache ou JRest |
Information info = new Information("erreur_jrest", JSONParser.parse(reponse.getText()).isArray()); |
GWT.log("Erreur JREST - Code "+reponse.getStatusCode()+"\n"+info.getMessages().toString(), null); |
Info.display("Erreur JREST - Code "+reponse.getStatusCode(), info.toString()); |
} |
public void onResponseReceived(Request request, Response response) { |
// Si le code de réponse HTTP ne vaut pas 200 OK, on lance le mécanise d'erreur HTTP |
if (response.getStatusCode() != 200) { |
onErrorHTTP(request, response); |
} else { |
if (response.getText().length() != 0 && response.getText() != null) { |
final JSONValue responseValue = JSONParser.parse(response.getText()); |
// Si la requête est un succès, reception d'un tableau |
if (responseValue.isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
// Transformation du tableau JSON réponse en ListeInstitution |
Information info = new Information("liste_structure_a_personne"); |
StructureAPersonneListe personnel = new StructureAPersonneListe(reponse); |
info.setDonnee(0, personnel); |
// et on met à jour le demandeur des données |
r.rafraichir(info); |
} else { |
GWT.log(url+"\n\tLa réponse n'est pas un talbeau JSON et vaut : "+responseValue.toString(), null); |
} |
} else { |
if (idStructure == null) { |
// Dans le cas, où nous demandons toutes les relations Structure à Personne et qu'il n'y en a pas, nous retournons un message d'information |
Information info = new Information("liste_structure_a_personne"); |
info.setMessage("Aucun personnel"); |
r.rafraichir(info); |
} else { |
GWT.log(url, null); |
if (response.getText().length() == 0) { |
GWT.log("\tLa réponse a une taille de 0", null); |
} |
if (response.getText() == null) { |
GWT.log("\tLa réponse vaul null", null); |
} |
} |
} |
} |
} |
}); |
} catch (RequestException e) { |
e.printStackTrace(); |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/Structure.java |
---|
254,11 → 254,15 |
} |
} |
public String getNbrePersonne() { |
return (String) renvoyerValeurCorrecte("nbre_personne"); |
public int getNbrePersonne() { |
if (renvoyerValeurCorrecte("nbre_personne").equals("")) { |
return 0; |
} else { |
return Integer.parseInt(renvoyerValeurCorrecte("nbre_personne")); |
} |
} |
public void setNbrePersonne(String nbrePersonne) { |
this.set("nbre_personne", nbrePersonne); |
public void setNbrePersonne(int nbrePersonne) { |
this.set("nbre_personne", Integer.toString(nbrePersonne)); |
} |
public String getConditionAcces() { |