New file |
0,0 → 1,68 |
package org.tela_botanica.client.modeles; |
|
import java.util.Iterator; |
import java.util.Set; |
|
import com.google.gwt.json.client.JSONObject; |
|
public class Personne extends aDonnee { |
/** |
* Constructeur vide |
*/ |
public Personne() { |
this.set("mark_contact", false); |
} |
|
/** |
* Constructeur avec un objet JSON |
* |
* @param image |
*/ |
public Personne(JSONObject liste) { |
// l'objet JSON est une table de hachage |
Set<String> im = liste.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(); |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^cp_", ""); |
if (liste.get(cle).isString() != null) { |
String valeur = liste.get(cle).isString().stringValue(); |
this.set(cleObjet, valeur); |
} else { |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = " "; |
this.set(cleObjet, valeur); |
} |
} |
} |
|
/** |
* 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 ""; |
} |
|
} |
|
} |