Subversion Repositories eFlore/Applications.coel

Rev

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