Subversion Repositories eFlore/Applications.coel

Rev

Rev 103 | Rev 208 | 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 {
9
	/**
103 jpm 10
	 * Constructeur vide
11
	 */
12
	public Personne() {
13
		this.set("mark_contact", false);
14
	}
15
 
16
	/**
102 jpm 17
	 * Constructeur avec un objet JSON
18
	 *
19
	 * @param image
20
	 */
21
	public Personne(JSONObject liste) {
22
		// l'objet JSON est une table de hachage
23
		Set<String> im = liste.keySet();
24
 
25
		// Parcourt pour chaque clé
26
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
27
			// Si elle est associée à une valeur, nous l'ajoutons
28
			String cle = it.next();
29
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
30
			String cleObjet = cle.replaceFirst("^cp_", "");
31
			if (liste.get(cle).isString() != null) {
32
				String valeur = liste.get(cle).isString().stringValue();
33
				this.set(cleObjet, valeur);
34
			} else {
35
				// Sinon, nous ajoutons la clé avec une valeur vide
36
				String valeur = " ";
37
				this.set(cleObjet, valeur);
38
			}
39
		}
40
	}
41
 
42
	/**
43
	 * Constructeur avec la fonction à passer en paramètre
44
	 *
45
	 * @param image
46
	 */
47
	public Personne(String fonction) {
48
		this.set("ce_truk_fonction", fonction);
49
		this.set("mark_contact", false);
50
	}
51
 
52
	public String getId() {
53
		return (String) renvoyerValeurCorrecte("id_personne");
54
	}
55
 
56
	public String getFonction() {
57
		String fonction = (String) renvoyerValeurCorrecte("ce_truk_fonction");
58
		if (fonction.equals(Valeur.FONCTION_DIRECTEUR)) {
59
			return "Directeur";
60
		} else if (fonction.equals(Valeur.FONCTION_CONSERVATEUR)) {
61
			return "Conservateur";
62
		} else {
63
			return "";
181 gduche 64
		}
102 jpm 65
	}
181 gduche 66
 
102 jpm 67
 
181 gduche 68
	public String getNom()	{
69
		return (String) renvoyerValeurCorrecte("cp_nom");
70
	}
71
 
72
 
73
	public String getPrenom()	{
74
		return (String) renvoyerValeurCorrecte("cp_prenom");
75
	}
76
 
77
	public Object obtenirValeurChamp(String nomChamp)	{
78
		return renvoyerValeurCorrecte(nomChamp);
79
	}
80
 
102 jpm 81
}