| Line 4... |
Line 4... |
| 4 |
import java.text.ParsePosition;
|
4 |
import java.text.ParsePosition;
|
| 5 |
import java.util.ArrayList;
|
5 |
import java.util.ArrayList;
|
| 6 |
import java.util.Collections;
|
6 |
import java.util.Collections;
|
| 7 |
import java.util.Comparator;
|
7 |
import java.util.Comparator;
|
| 8 |
import java.util.HashMap;
|
8 |
import java.util.HashMap;
|
| - |
|
9 |
import java.util.Iterator;
|
| 9 |
import java.util.List;
|
10 |
import java.util.List;
|
| 10 |
import java.util.Map;
|
11 |
import java.util.Map;
|
| 11 |
import java.util.Vector;
|
12 |
import java.util.Vector;
|
| Line 12... |
Line 13... |
| 12 |
|
13 |
|
| 13 |
import org.tela_botanica.client.modeles.objets.ChampEtendu;
|
14 |
import org.tela_botanica.client.modeles.objets.ChampEtendu;
|
| - |
|
15 |
import org.tela_botanica.client.modeles.objets.Observation;
|
| - |
|
16 |
import org.tela_botanica.client.modeles.objets.ReferentielLocalite;
|
| Line 14... |
Line 17... |
| 14 |
import org.tela_botanica.client.modeles.objets.Observation;
|
17 |
import org.tela_botanica.client.modeles.objets.ReferentielNom;
|
| 15 |
|
18 |
|
| 16 |
import com.google.gwt.dom.client.Element;
|
19 |
import com.google.gwt.dom.client.Element;
|
| 17 |
import com.google.gwt.http.client.Response;
|
20 |
import com.google.gwt.http.client.Response;
|
| Line 463... |
Line 466... |
| 463 |
}
|
466 |
}
|
| 464 |
}
|
467 |
}
|
| 465 |
}
|
468 |
}
|
| 466 |
return referentielData;
|
469 |
return referentielData;
|
| 467 |
}
|
470 |
}
|
| - |
|
471 |
|
| - |
|
472 |
public static Map<String, ReferentielNom> parserRetourReferentielNomIndexeParNom(Response response) {
|
| - |
|
473 |
|
| - |
|
474 |
final Map<String, ReferentielNom> referentielNomData ;
|
| - |
|
475 |
final JSONValue responseValue = JSONParser.parse(response.getText());
|
| - |
|
476 |
JSONArray reponse=null;
|
| - |
|
477 |
|
| - |
|
478 |
// si c'est un tableau
|
| - |
|
479 |
if ((reponse=responseValue.isArray()) != null) {
|
| - |
|
480 |
|
| - |
|
481 |
JSONArray noms;
|
| - |
|
482 |
final int taillemax = reponse.size();
|
| - |
|
483 |
|
| - |
|
484 |
referentielNomData = new HashMap<String, ReferentielNom>(taillemax);
|
| - |
|
485 |
for (int i = 0; i < taillemax; i++) {
|
| - |
|
486 |
if ((noms=reponse.get(i).isArray()) != null) {
|
| - |
|
487 |
String nom = ((JSONString) noms.get(0)).stringValue();
|
| - |
|
488 |
String numeroNom = ((JSONString) noms.get(1)).stringValue();
|
| - |
|
489 |
String statut= ((JSONString) noms.get(2)).stringValue();
|
| - |
|
490 |
ReferentielNom nomScientifique = new ReferentielNom(nom, numeroNom, statut);
|
| - |
|
491 |
// FIXME : et si le numero de nom n'est pas unique ? (cas de multirefrentiel....)
|
| - |
|
492 |
referentielNomData.put(nomScientifique.getNom(),nomScientifique);
|
| - |
|
493 |
}
|
| - |
|
494 |
}
|
| - |
|
495 |
} else {
|
| - |
|
496 |
referentielNomData = new HashMap<String, ReferentielNom>(0);
|
| - |
|
497 |
}
|
| - |
|
498 |
return referentielNomData;
|
| - |
|
499 |
}
|
| - |
|
500 |
|
| - |
|
501 |
public static Map<String, String> convertirListeReferentielNomVersMap(Map<String, ReferentielNom> referentielNom) {
|
| - |
|
502 |
Map<String, String> nomMap = new HashMap<String, String>();
|
| - |
|
503 |
for (Iterator<String> it = referentielNom.keySet().iterator(); it.hasNext();) {
|
| - |
|
504 |
String cle = it.next();
|
| - |
|
505 |
nomMap.put(cle, referentielNom.get(cle).getNom());
|
| - |
|
506 |
}
|
| - |
|
507 |
return nomMap;
|
| - |
|
508 |
}
|
| - |
|
509 |
|
| - |
|
510 |
public static Map<String, ReferentielLocalite> parserRetourReferentielLocaliteIndexeParNom(Response response) {
|
| - |
|
511 |
|
| - |
|
512 |
final Map<String, ReferentielLocalite> referentielLocaliteData;
|
| - |
|
513 |
final JSONValue responseValue = JSONParser.parse(response.getText());
|
| - |
|
514 |
JSONArray reponse = null;
|
| - |
|
515 |
|
| - |
|
516 |
// si c'est un tableau
|
| - |
|
517 |
if ((reponse = responseValue.isArray()) != null) {
|
| - |
|
518 |
|
| - |
|
519 |
JSONArray localites;
|
| - |
|
520 |
final int taillemax = reponse.size();
|
| - |
|
521 |
|
| - |
|
522 |
referentielLocaliteData = new HashMap<String, ReferentielLocalite>(taillemax);
|
| - |
|
523 |
|
| - |
|
524 |
for (int i = 0; i < taillemax; i++) {
|
| - |
|
525 |
if ((localites = reponse.get(i).isArray()) != null) {
|
| - |
|
526 |
String localite = ((JSONString) localites.get(0)).stringValue();
|
| - |
|
527 |
String codeLocalite = ((JSONString) localites.get(1)).stringValue();
|
| - |
|
528 |
ReferentielLocalite com = new ReferentielLocalite(localite, codeLocalite);
|
| - |
|
529 |
referentielLocaliteData.put(com.getLocalite() + com.getCodeLocalite(), com);
|
| - |
|
530 |
}
|
| - |
|
531 |
}
|
| - |
|
532 |
} else {
|
| - |
|
533 |
referentielLocaliteData = new HashMap<String, ReferentielLocalite>(0);
|
| - |
|
534 |
}
|
| - |
|
535 |
return referentielLocaliteData;
|
| - |
|
536 |
}
|
| - |
|
537 |
|
| - |
|
538 |
public static Map<String, String> convertirListeReferentielLocaliteVersMap(Map<String, ReferentielLocalite> referentielLocalite) {
|
| - |
|
539 |
Map<String, String> locMap = new HashMap<String, String>();
|
| - |
|
540 |
for (Iterator<String> it = referentielLocalite.keySet().iterator(); it.hasNext();) {
|
| - |
|
541 |
String cle = it.next();
|
| - |
|
542 |
locMap.put(cle, referentielLocalite.get(cle).getLocalite());
|
| - |
|
543 |
}
|
| - |
|
544 |
return locMap;
|
| - |
|
545 |
}
|
| 468 |
}
|
546 |
}
|