Subversion Repositories eFlore/Applications.coel

Rev

Rev 181 | Rev 238 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
102 jpm 1
package org.tela_botanica.client.modeles;
2
 
3
import java.util.Iterator;
4
import java.util.Set;
5
 
6
import com.google.gwt.json.client.JSONObject;
7
 
8
public class Personne extends aDonnee {
208 jp_milcent 9
 
10
	public static final String PREFIXE = "cp";
11
 
102 jpm 12
	/**
103 jpm 13
	 * Constructeur vide
14
	 */
15
	public Personne() {
208 jp_milcent 16
 
103 jpm 17
	}
18
 
19
	/**
102 jpm 20
	 * Constructeur avec un objet JSON
21
	 *
22
	 * @param image
23
	 */
24
	public Personne(JSONObject liste) {
25
		// l'objet JSON est une table de hachage
26
		Set<String> im = liste.keySet();
27
 
28
		// Parcourt pour chaque clé
29
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
30
			// Si elle est associée à une valeur, nous l'ajoutons
31
			String cle = it.next();
32
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
33
			String cleObjet = cle.replaceFirst("^cp_", "");
34
			if (liste.get(cle).isString() != null) {
35
				String valeur = liste.get(cle).isString().stringValue();
36
				this.set(cleObjet, valeur);
37
			} else {
38
				// Sinon, nous ajoutons la clé avec une valeur vide
39
				String valeur = " ";
40
				this.set(cleObjet, valeur);
41
			}
42
		}
43
	}
44
 
45
	public String getId() {
46
		return (String) renvoyerValeurCorrecte("id_personne");
47
	}
48
 
181 gduche 49
	public String getNom()	{
50
		return (String) renvoyerValeurCorrecte("cp_nom");
51
	}
52
 
53
	public String getPrenom()	{
54
		return (String) renvoyerValeurCorrecte("cp_prenom");
55
	}
56
 
57
	public Object obtenirValeurChamp(String nomChamp)	{
58
		return renvoyerValeurCorrecte(nomChamp);
59
	}
60
 
102 jpm 61
}