Line 2... |
Line 2... |
2 |
|
2 |
|
3 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
4 |
import java.util.Date;
|
4 |
import java.util.Date;
|
Line -... |
Line 5... |
- |
|
5 |
import java.util.List;
|
- |
|
6 |
|
5 |
import java.util.List;
|
7 |
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
|
6 |
|
8 |
|
7 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
9 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
8 |
import com.google.gwt.json.client.JSONArray;
|
10 |
import com.google.gwt.json.client.JSONArray;
|
Line 25... |
Line 27... |
25 |
|
27 |
|
26 |
int nbResultats = tableauObs.size();
|
28 |
int nbResultats = tableauObs.size();
|
Line 27... |
Line 29... |
27 |
for (int i = 0; i < nbResultats; i++) {
|
29 |
for (int i = 0; i < nbResultats; i++) {
|
28 |
|
- |
|
29 |
JSONObject observationJson = tableauObs.get(i).isObject();
|
- |
|
30 |
Observation observation = new Observation();
|
- |
|
31 |
|
- |
|
32 |
observation.setAuteur(observationJson.get("prenom_utilisateur").isString().stringValue()+
|
- |
|
33 |
" "+observationJson.get("nom_utilisateur").isString().stringValue());
|
- |
|
34 |
observation.setDateReleve(observationJson.get("date_observation").isString().stringValue());
|
- |
|
35 |
observation.setDateTransmission(observationJson.get("date_transmission").isString().stringValue());
|
- |
|
36 |
observation.setFamille(observationJson.get("famille").isString().stringValue());
|
- |
|
37 |
observation.setId(observationJson.get("id_observation").isString().stringValue());
|
- |
|
38 |
observation.setIdLocalite(observationJson.get("ce_zone_geo").isString().stringValue());
|
- |
|
39 |
observation.setLocalite(observationJson.get("zone_geo").isString().stringValue());
|
- |
|
40 |
observation.setLieuDit(observationJson.get("lieudit").isString().stringValue());
|
- |
|
41 |
observation.setMilieu(observationJson.get("milieu").isString().stringValue());
|
- |
|
42 |
observation.setNomRetenu(observationJson.get("nom_ret").isString().stringValue());
|
- |
|
43 |
observation.setCommentaire(observationJson.get("commentaire").isString().stringValue());
|
- |
|
44 |
observation.ajouterMotsClef(observationJson.get("mots_cles_texte").isString().stringValue());
|
- |
|
45 |
observation.setNumNomenclatural(observationJson.get("nom_ret_nn").isString().stringValue());
|
- |
|
46 |
observation.setMotsClefs(parserMotsCles(observationJson.get("mots_cles_texte").isString().stringValue()));
|
30 |
|
47 |
|
- |
|
48 |
PropositionDetermination propositionDetermination = new PropositionDetermination();
|
- |
|
49 |
propositionDetermination.setContributeur(observationJson.get("prenom_utilisateur").isString().stringValue()+
|
- |
|
50 |
" "+observationJson.get("nom_utilisateur").isString().stringValue());
|
- |
|
51 |
java.util.Date datePropDeter = parserDateObservation(observationJson.get("date_observation").isString().stringValue());
|
- |
|
52 |
propositionDetermination.setDate(datePropDeter);
|
- |
|
53 |
propositionDetermination.setEspece(observationJson.get("nom_ret").isString().stringValue());
|
31 |
JSONObject observationJson = tableauObs.get(i).isObject();
|
54 |
observation.addImageCelValidationData(propositionDetermination);
|
32 |
Observation observation = UtilitairesServiceResultat.parserObservationEtCreerPropositionDetermination(observationJson);
|
55 |
|
33 |
|
Line 56... |
Line 34... |
56 |
JSONArray tableauImagesObs = observationJson.get("images").isArray();
|
34 |
JSONArray tableauImagesObs = observationJson.get("images").isArray();
|
57 |
List<Image> imagesPourObs = new ArrayList<Image>();
|
35 |
List<Image> imagesPourObs = new ArrayList<Image>();
|
58 |
|
36 |
|
59 |
int nbImages = tableauImagesObs.size();
|
- |
|
- |
|
37 |
int nbImages = tableauImagesObs.size();
|
60 |
for (int j = 0; j < nbImages; j++) {
|
38 |
for (int j = 0; j < nbImages; j++) {
|
61 |
JSONObject imageJson = tableauImagesObs.get(j).isObject();
|
- |
|
62 |
Image image = new Image();
|
- |
|
63 |
String idImage = "1"+imageJson.get("id_image").isString().stringValue();
|
- |
|
64 |
image.setIdImage(idImage);
|
- |
|
65 |
image.setUrlFormat("http://www.tela-botanica.org/appli:cel-img:"+getIdAvecPadding(idImage)+"%s%.jpg");
|
39 |
JSONObject imageJson = tableauImagesObs.get(j).isObject();
|
66 |
image.setUrl("http://www.tela-botanica.org/appli:cel-img:"+getIdAvecPadding(idImage)+"CRS.jpg");
|
40 |
|
67 |
image.setMiniature("http://www.tela-botanica.org/appli:cel-img:"+getIdAvecPadding(idImage)+"XS.jpg");
|
41 |
Image image = UtilitairesServiceResultat.parserImageJSON(imageJson);
|
Line 68... |
Line 42... |
68 |
image.setObservation(observation);
|
42 |
image.setObservation(observation);
|
69 |
imagesPourObs.add(image);
|
43 |
imagesPourObs.add(image);
|
Line 87... |
Line 61... |
87 |
}
|
61 |
}
|
Line 88... |
Line 62... |
88 |
|
62 |
|
89 |
public void setNbTotalObservationsPourLaRecherche(int nbTotalObservationsPourLaRecherche) {
|
63 |
public void setNbTotalObservationsPourLaRecherche(int nbTotalObservationsPourLaRecherche) {
|
90 |
this.nbTotalObservationsPourLaRecherche = nbTotalObservationsPourLaRecherche;
|
64 |
this.nbTotalObservationsPourLaRecherche = nbTotalObservationsPourLaRecherche;
|
91 |
}
|
- |
|
92 |
|
- |
|
93 |
private String getIdAvecPadding(String id) {
|
- |
|
94 |
|
- |
|
95 |
int maxZeros = 9 - id.length();
|
- |
|
96 |
|
- |
|
97 |
for (int i = 0; i < maxZeros; i++) {
|
- |
|
98 |
id = "0" + id;
|
- |
|
99 |
}
|
- |
|
100 |
|
- |
|
101 |
return id;
|
- |
|
102 |
}
|
- |
|
103 |
|
- |
|
104 |
private Date parserDateObservation(String date) {
|
- |
|
105 |
Date dateParsee = new Date();
|
- |
|
106 |
DateTimeFormat formatDateObs = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
|
- |
|
107 |
try{
|
- |
|
108 |
dateParsee = formatDateObs.parse(date);
|
- |
|
109 |
} catch (IllegalArgumentException e) {
|
- |
|
110 |
dateParsee = new java.sql.Date(0);
|
- |
|
111 |
}
|
- |
|
112 |
return dateParsee;
|
- |
|
113 |
}
|
- |
|
114 |
|
- |
|
115 |
private List<String> parserMotsCles(String motsClesTexte) {
|
- |
|
116 |
String[] tabMotsCle = motsClesTexte.split(",");
|
- |
|
117 |
List<String> motsClesParses = new ArrayList<String>();
|
- |
|
118 |
for (int i = 0; i < tabMotsCle.length; i++) {
|
- |
|
119 |
motsClesParses.add(tabMotsCle[i]);
|
- |
|
120 |
}
|
- |
|
121 |
|
- |
|
122 |
return motsClesParses;
|
- |
|
123 |
}
|
- |
|
124 |
|
- |
|
125 |
|
65 |
}
|