| 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 {
|
|
|
9 |
/**
|
|
|
10 |
* Constructeur vide
|
|
|
11 |
*/
|
|
|
12 |
public Projet() {
|
|
|
13 |
this.set("mark_contact", false);
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Constructeur avec un objet JSON
|
|
|
18 |
*
|
|
|
19 |
* @param image
|
|
|
20 |
*/
|
|
|
21 |
public Projet(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("^cpr_", "");
|
|
|
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 Projets(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_projet");
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
public String getNom() {
|
|
|
57 |
return (String) renvoyerValeurCorrecte("nom");
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
/*public String getFonction() {
|
|
|
61 |
String fonction = (String) renvoyerValeurCorrecte("ce_truk_fonction");
|
|
|
62 |
if (fonction.equals(Valeur.FONCTION_DIRECTEUR)) {
|
|
|
63 |
return "Directeur";
|
|
|
64 |
} else if (fonction.equals(Valeur.FONCTION_CONSERVATEUR)) {
|
|
|
65 |
return "Conservateur";
|
|
|
66 |
} else {
|
|
|
67 |
return "";
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
}*/
|
|
|
71 |
|
|
|
72 |
}
|