Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
147 gduche 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 Projet extends aDonnee {
748 jpm 9
 
10
	private static final long serialVersionUID = 6733053168274995082L;
11
 
12
	private static final String PREFIXE = "cpr";
13
 
147 gduche 14
	public Projet() {
15
		this.set("mark_contact", false);
16
	}
17
 
18
	public Projet(JSONObject liste) {
19
		// l'objet JSON est une table de hachage
20
		Set<String> im = liste.keySet();
21
 
22
		// Parcourt pour chaque clé
23
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
24
			// Si elle est associée à une valeur, nous l'ajoutons
25
			String cle = it.next();
26
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
748 jpm 27
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
147 gduche 28
			if (liste.get(cle).isString() != null) {
29
				String valeur = liste.get(cle).isString().stringValue();
30
				this.set(cleObjet, valeur);
31
			} else {
32
				// Sinon, nous ajoutons la clé avec une valeur vide
33
				String valeur = " ";
34
				this.set(cleObjet, valeur);
35
			}
36
		}
37
	}
38
 
748 jpm 39
	@Override
40
	protected String getPrefixe() {
41
		return PREFIXE;
42
	}
147 gduche 43
 
44
	public String getId() {
804 jpm 45
		return renvoyerValeurCorrecte("id_projet");
147 gduche 46
	}
47
 
48
	public String getNom() {
804 jpm 49
		return renvoyerValeurCorrecte("nom");
147 gduche 50
	}
804 jpm 51
 
52
	public String getAbreviation() {
53
		return renvoyerValeurCorrecte("abreviation");
54
	}
147 gduche 55
 
56
}