814 |
aurelien |
1 |
package org.tela_botanica.del.client.modeles;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
|
|
|
6 |
|
|
|
7 |
import com.google.gwt.json.client.JSONObject;
|
|
|
8 |
import com.google.gwt.json.client.JSONValue;
|
|
|
9 |
|
|
|
10 |
public class ProtocoleServiceResultat {
|
|
|
11 |
private List<Protocole> protocoles;
|
|
|
12 |
|
|
|
13 |
public ProtocoleServiceResultat(List<Protocole> protocoles) {
|
|
|
14 |
// constructeur utilisable plus tard quand on aura implenté un systeme de cache
|
|
|
15 |
this.protocoles = protocoles;
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
public ProtocoleServiceResultat(JSONValue retourJson) {
|
|
|
19 |
protocoles = new ArrayList<Protocole>();
|
|
|
20 |
JSONObject tableauProto = retourJson.isObject().get("resultats").isObject();
|
|
|
21 |
|
|
|
22 |
if(tableauProto != null) {
|
|
|
23 |
java.util.Iterator<String> it = tableauProto.keySet().iterator();
|
|
|
24 |
while (it.hasNext()) {
|
|
|
25 |
|
|
|
26 |
JSONObject protocoleJSON = tableauProto.get(it.next()).isObject();
|
|
|
27 |
Protocole protocole = new Protocole();
|
|
|
28 |
String idProtocole = UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.id");
|
|
|
29 |
protocole.setId(Integer.parseInt(idProtocole));
|
|
|
30 |
protocole.setNom(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.intitule"));
|
|
|
31 |
protocole.setDescription(UtilitairesServiceResultat.getValeurOuVide(protocoleJSON, "protocole.descriptif"));
|
|
|
32 |
protocoles.add(protocole);
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
public List<Protocole> getProtocoles() {
|
|
|
38 |
return protocoles;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
public void setProtocoles(List<Protocole> protocoles) {
|
|
|
42 |
this.protocoles = protocoles;
|
|
|
43 |
}
|
|
|
44 |
}
|