Subversion Repositories eFlore/Applications.cel

Rev

Rev 2033 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2033 Rev 2392
Line 1... Line 1...
1
package org.tela_botanica.client.modeles.objets;
1
package org.tela_botanica.client.modeles.objets;
Line 2... Line 2...
2
 
2
 
3
import java.util.HashMap;
3
import java.util.HashMap;
Line -... Line 4...
-
 
4
import java.util.Iterator;
-
 
5
 
-
 
6
import org.tela_botanica.client.cel2;
4
import java.util.Iterator;
7
 
5
 
8
import com.google.gwt.json.client.JSONArray;
6
import com.google.gwt.json.client.JSONObject;
9
import com.google.gwt.json.client.JSONObject;
Line 7... Line 10...
7
import com.google.gwt.json.client.JSONParser;
10
import com.google.gwt.json.client.JSONParser;
Line -... Line 11...
-
 
11
import com.google.gwt.json.client.JSONValue;
-
 
12
 
8
import com.google.gwt.json.client.JSONValue;
13
public class ListeGroupesChampsEtendus extends HashMap<String,HashMap<String, String>> {
9
 
14
	
10
public class ListeGroupesChampsEtendus extends HashMap<String,HashMap<String, String>> {
15
	public HashMap<String, String> correspondancesClesLabels ;
-
 
16
	
11
	
17
	public ListeGroupesChampsEtendus(String groupeChampsEtendusJson) {
12
	public ListeGroupesChampsEtendus(String groupeChampsEtendusJson) {
18
		super();
Line 13... Line 19...
13
		super();
19
		try {
-
 
20
			correspondancesClesLabels = new HashMap<String, String>();
14
		try {
21
			JSONValue groupesJson = JSONParser.parseStrict(groupeChampsEtendusJson);
15
			JSONValue groupesJson = JSONParser.parse(groupeChampsEtendusJson);
22
			JSONArray groupes = groupesJson.isArray();
16
			JSONObject groupes = groupesJson.isObject();
23
			
-
 
24
			for (int i = 0; i < groupes.size(); i++) {
17
			
25
				
-
 
26
				JSONObject groupe = groupes.get(i).isObject();
18
			for (Iterator<String> iterator = groupes.keySet().iterator(); iterator.hasNext();) {
27
				String nomGroupe = groupe.get("nom").isString().stringValue();
19
				String groupe = iterator.next();
28
				JSONArray listeClesLabels = groupe.get("champs").isArray();
-
 
29
				
20
				JSONValue listeClesLabelsJson = groupes.get(groupe);
30
				HashMap<String, String> groupesClesLabel = new HashMap<String, String>();
21
				JSONObject listeClesLabels = listeClesLabelsJson.isObject();
31
				
-
 
32
				for (int j = 0; j < listeClesLabels.size(); j++) {
22
				HashMap<String, String> groupesClesLabel = new HashMap<String, String>();
33
					JSONObject champ = listeClesLabels.get(j).isObject();
-
 
34
					String cle = champ.get("cle").isString().stringValue();
23
				for (Iterator<String> itCleLabels = listeClesLabels.keySet().iterator(); itCleLabels.hasNext();) {
35
					String label = champ.get("label").isString().stringValue();
24
					String cle = itCleLabels.next();
36
					groupesClesLabel.put(cle, label);
25
					String label = listeClesLabels.get(cle).isString().stringValue();	
37
					correspondancesClesLabels.put(cle, label);
26
					groupesClesLabel.put(cle, label);
38
				}
27
				}
39
				
28
				this.put(groupe, groupesClesLabel);
40
				this.put(nomGroupe, groupesClesLabel);
-
 
41
			}
-
 
42
		} catch (Exception e) {
-
 
43
			// TODO: handle exception
-
 
44
		}
-
 
45
	}
29
			}
46