Subversion Repositories eFlore/Applications.coel

Rev

Rev 102 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 102 Rev 103
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.Iterator;
3
import java.util.Iterator;
4
import java.util.Set;
4
import java.util.Set;
5
 
5
 
6
import com.google.gwt.json.client.JSONObject;
6
import com.google.gwt.json.client.JSONObject;
7
 
7
 
8
public class Personne extends aDonnee {
8
public class Personne extends aDonnee {
-
 
9
	/**
-
 
10
	 * Constructeur vide
-
 
11
	 */
-
 
12
	public Personne() {
-
 
13
		this.set("mark_contact", false);
-
 
14
	}
9
 
15
	
10
	/**
16
	/**
11
	 * Constructeur avec un objet JSON
17
	 * Constructeur avec un objet JSON
12
	 * 
18
	 * 
13
	 * @param image
19
	 * @param image
14
	 */
20
	 */
15
	public Personne(JSONObject liste) {
21
	public Personne(JSONObject liste) {
16
		// l'objet JSON est une table de hachage
22
		// l'objet JSON est une table de hachage
17
		Set<String> im = liste.keySet();
23
		Set<String> im = liste.keySet();
18
 
24
 
19
		// Parcourt pour chaque clé
25
		// Parcourt pour chaque clé
20
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
26
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
21
			// Si elle est associée à une valeur, nous l'ajoutons
27
			// Si elle est associée à une valeur, nous l'ajoutons
22
			String cle = it.next();
28
			String cle = it.next();
23
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
29
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
24
			String cleObjet = cle.replaceFirst("^cp_", "");
30
			String cleObjet = cle.replaceFirst("^cp_", "");
25
			if (liste.get(cle).isString() != null) {
31
			if (liste.get(cle).isString() != null) {
26
				String valeur = liste.get(cle).isString().stringValue();
32
				String valeur = liste.get(cle).isString().stringValue();
27
				this.set(cleObjet, valeur);
33
				this.set(cleObjet, valeur);
28
			} else {
34
			} else {
29
				// Sinon, nous ajoutons la clé avec une valeur vide
35
				// Sinon, nous ajoutons la clé avec une valeur vide
30
				String valeur = " ";
36
				String valeur = " ";
31
				this.set(cleObjet, valeur);
37
				this.set(cleObjet, valeur);
32
			}
38
			}
33
		}
39
		}
34
	}
40
	}
35
	
41
	
36
	/**
42
	/**
37
	 * Constructeur avec la fonction à passer en paramètre
43
	 * Constructeur avec la fonction à passer en paramètre
38
	 * 
44
	 * 
39
	 * @param image
45
	 * @param image
40
	 */
46
	 */
41
	public Personne(String fonction) {
47
	public Personne(String fonction) {
42
		this.set("ce_truk_fonction", fonction);
48
		this.set("ce_truk_fonction", fonction);
43
		this.set("mark_contact", false);
49
		this.set("mark_contact", false);
44
	}
50
	}
45
	
51
	
46
	public String getId() {
52
	public String getId() {
47
		return (String) renvoyerValeurCorrecte("id_personne");
53
		return (String) renvoyerValeurCorrecte("id_personne");
48
	}
54
	}
49
	
55
	
50
	public String getFonction() {
56
	public String getFonction() {
51
		String fonction = (String) renvoyerValeurCorrecte("ce_truk_fonction");
57
		String fonction = (String) renvoyerValeurCorrecte("ce_truk_fonction");
52
		if (fonction.equals(Valeur.FONCTION_DIRECTEUR)) {
58
		if (fonction.equals(Valeur.FONCTION_DIRECTEUR)) {
53
			return "Directeur";
59
			return "Directeur";
54
		} else if (fonction.equals(Valeur.FONCTION_CONSERVATEUR)) {
60
		} else if (fonction.equals(Valeur.FONCTION_CONSERVATEUR)) {
55
			return "Conservateur";
61
			return "Conservateur";
56
		} else {
62
		} else {
57
			return "";
63
			return "";
58
		}
64
		}
59
		
65
		
60
	}
66
	}
61
 
67
 
62
}
68
}