9 |
benjamin |
1 |
package org.tela_botanica.del.client.utils;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.Date;
|
55 |
gduche |
5 |
import java.util.HashMap;
|
|
|
6 |
import java.util.Iterator;
|
9 |
benjamin |
7 |
import java.util.List;
|
|
|
8 |
|
14 |
benjamin |
9 |
import org.tela_botanica.del.client.exceptions.ExceptionClient;
|
130 |
aurelien |
10 |
import org.tela_botanica.del.client.i18n.I18n;
|
141 |
aurelien |
11 |
import org.tela_botanica.del.client.modeles.Commentaire;
|
154 |
benjamin |
12 |
import org.tela_botanica.del.client.modeles.Image;
|
9 |
benjamin |
13 |
import org.tela_botanica.del.client.modeles.Observation;
|
141 |
aurelien |
14 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
103 |
benjamin |
15 |
import org.tela_botanica.del.client.modeles.Protocole;
|
154 |
benjamin |
16 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
115 |
benjamin |
17 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
9 |
benjamin |
18 |
|
56 |
benjamin |
19 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
20 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
|
|
21 |
|
159 |
benjamin |
22 |
public class MockDatasource {
|
9 |
benjamin |
23 |
|
|
|
24 |
static MockDatasource instance;
|
|
|
25 |
|
|
|
26 |
List<Observation> observations = new ArrayList<Observation>();
|
|
|
27 |
|
154 |
benjamin |
28 |
List<PropositionDetermination> observationValidationDatas = new ArrayList<PropositionDetermination>();
|
48 |
benjamin |
29 |
|
|
|
30 |
ArrayList<String> propositionsTaxonDatas = new ArrayList<String>();
|
115 |
benjamin |
31 |
|
107 |
benjamin |
32 |
List<Protocole> protocoles = new ArrayList<Protocole>();
|
159 |
benjamin |
33 |
|
154 |
benjamin |
34 |
List<Image> images = new ArrayList<Image>();
|
135 |
gduche |
35 |
|
154 |
benjamin |
36 |
List<String> pourcentagesConfiance = new ArrayList<String>();
|
48 |
benjamin |
37 |
|
9 |
benjamin |
38 |
private MockDatasource() {
|
|
|
39 |
|
55 |
gduche |
40 |
HashMap<String, String> auteurObs = new HashMap<String, String>();
|
|
|
41 |
auteurObs.put("Juliette 1MOUREAU", "Tragopogon porrifolius subsp. australis (Jord.) Nyman");
|
|
|
42 |
auteurObs.put("Robert 2LERAS", "Iris lutescens subsp. lutescens");
|
|
|
43 |
auteurObs.put("Geneviève 3BOTTI", "Euphorbia dendroides L.");
|
|
|
44 |
auteurObs.put("Robert 4LERAS", "Lonicera japonica Thunb. ex Murray");
|
|
|
45 |
auteurObs.put("Juliette 5MOUREAU", "Lavatera arborea L.");
|
|
|
46 |
auteurObs.put("Robert 6LERAS", "Lavatera arborea L.");
|
|
|
47 |
auteurObs.put("Juliette 7MOUREAU", "Serapias vomeracea (Burm.f.) Briq. ");
|
|
|
48 |
auteurObs.put("Benjamin 8LIENS", "Lonicera etrusca Santi");
|
|
|
49 |
auteurObs.put("Aurélient 9PERONNET", "Ophrys scolopax Cav. ");
|
|
|
50 |
auteurObs.put("Grégoire 10DUCHÉ", "Staehelina dubia L. ");
|
|
|
51 |
auteurObs.put("Juliette 11MOUREAU", "Tragopogon porrifolius subsp. australis (Jord.) Nyman");
|
|
|
52 |
auteurObs.put("Robert 12LERAS", "Iris lutescens subsp. lutescens");
|
|
|
53 |
auteurObs.put("Geneviève 13BOTTI", "Euphorbia dendroides L.");
|
|
|
54 |
auteurObs.put("Robert 14LERAS", "Lonicera japonica Thunb. ex Murray");
|
|
|
55 |
auteurObs.put("Juliette 15MOUREAU", "Lavatera arborea L.");
|
|
|
56 |
auteurObs.put("Robert 16LERAS", "Lavatera arborea L.");
|
|
|
57 |
auteurObs.put("Juliette 17MOUREAU", "Serapias vomeracea (Burm.f.) Briq. ");
|
|
|
58 |
auteurObs.put("Benjamin 18LIENS", "Lonicera etrusca Santi");
|
|
|
59 |
auteurObs.put("Aurélient 19PERONNET", "Ophrys scolopax Cav. ");
|
|
|
60 |
auteurObs.put("Grégoire 20DUCHÉ", "Staehelina dubia L. ");
|
|
|
61 |
|
61 |
benjamin |
62 |
ArrayList<String> motsClefs = new ArrayList<String>();
|
|
|
63 |
motsClefs.add("plantnet");
|
|
|
64 |
motsClefs.add("fleur");
|
|
|
65 |
motsClefs.add("fruit");
|
|
|
66 |
|
55 |
gduche |
67 |
Iterator<String> auteurs = auteurObs.keySet().iterator();
|
|
|
68 |
|
103 |
benjamin |
69 |
Protocole protocol1 = new Protocole();
|
|
|
70 |
protocol1.setNom(Protocole.ESTHETISME);
|
100 |
benjamin |
71 |
protocol1.setId(1);
|
|
|
72 |
|
103 |
benjamin |
73 |
Protocole protocol2 = new Protocole();
|
|
|
74 |
protocol2.setNom(Protocole.IDENTIFICATION_AUTOMATIQUE);
|
100 |
benjamin |
75 |
protocol2.setId(2);
|
115 |
benjamin |
76 |
|
107 |
benjamin |
77 |
protocoles.add(protocol1);
|
|
|
78 |
protocoles.add(protocol2);
|
100 |
benjamin |
79 |
|
154 |
benjamin |
80 |
VoteDetermination voteDetermination = new VoteDetermination();
|
|
|
81 |
voteDetermination.setVote(4);
|
|
|
82 |
voteDetermination.setDate(new Date());
|
|
|
83 |
voteDetermination.setContributeur("benjamin");
|
9 |
benjamin |
84 |
|
154 |
benjamin |
85 |
PropositionDetermination observationValidationData = new PropositionDetermination();
|
|
|
86 |
observationValidationData.setEspece("Iris lutescens subsp. lutescens");
|
|
|
87 |
observationValidationData.setContributeur("contributeur test");
|
|
|
88 |
observationValidationData.setId("1");
|
|
|
89 |
observationValidationData.setIdImage("id image 1");
|
48 |
benjamin |
90 |
|
154 |
benjamin |
91 |
observationValidationData.getVotesDeterminations().add(voteDetermination);
|
|
|
92 |
observationValidationData.setPourcentageConfiance(I18n.getVocabulary().confiance_simple_suggestion());
|
|
|
93 |
observationValidationData.setDate(new Date());
|
|
|
94 |
observationValidationDatas.add(observationValidationData);
|
48 |
benjamin |
95 |
|
154 |
benjamin |
96 |
PropositionDetermination observationValidationData2 = new PropositionDetermination();
|
|
|
97 |
observationValidationData2.setContributeur("contributeur test 2");
|
|
|
98 |
observationValidationData2.setEspece("Lavatera arborea L.");
|
|
|
99 |
observationValidationData2.setId("2");
|
|
|
100 |
observationValidationData2.setIdImage("id image 1");
|
|
|
101 |
observationValidationData2.getVotesDeterminations().add(voteDetermination);
|
|
|
102 |
observationValidationData2.setPourcentageConfiance(I18n.getVocabulary().confiance_sur_cent());
|
|
|
103 |
observationValidationData2.setDate(new Date());
|
|
|
104 |
observationValidationDatas.add(observationValidationData2);
|
48 |
benjamin |
105 |
|
154 |
benjamin |
106 |
PropositionDetermination observationValidationData3 = new PropositionDetermination();
|
|
|
107 |
observationValidationData3.setEspece("Acer monsp. L.");
|
|
|
108 |
observationValidationData3.setContributeur("Léo Ferré");
|
159 |
benjamin |
109 |
Commentaire commentaire = new Commentaire("Greg", new Date(), "Avec le temps...");
|
|
|
110 |
Commentaire commentaireBis = new Commentaire("Benj", new Date(), "Pas d'accord avec Greg!");
|
|
|
111 |
commentaire.getListeCommentaires().add(commentaireBis);
|
154 |
benjamin |
112 |
observationValidationData3.getCommentaires().add(commentaire);
|
|
|
113 |
observationValidationData3.setId("1");
|
|
|
114 |
observationValidationData3.setIdImage("id image 1");
|
|
|
115 |
observationValidationData2.getVotesDeterminations().add(voteDetermination);
|
|
|
116 |
observationValidationData3.setPourcentageConfiance(I18n.getVocabulary().confiance_sur_cent());
|
|
|
117 |
observationValidationData3.setDate(new Date());
|
|
|
118 |
observationValidationDatas.add(observationValidationData3);
|
115 |
benjamin |
119 |
|
154 |
benjamin |
120 |
PropositionDetermination observationValidationData4 = new PropositionDetermination();
|
|
|
121 |
observationValidationData4.setEspece("Acer aceras aus.");
|
|
|
122 |
observationValidationData4.setContributeur("Pierre Desproges");
|
159 |
benjamin |
123 |
Commentaire commentaire2 = new Commentaire("Greg", new Date(), "Public chéri mon amour...");
|
154 |
benjamin |
124 |
observationValidationData4.getCommentaires().add(commentaire2);
|
|
|
125 |
observationValidationData4.setId("2");
|
|
|
126 |
observationValidationData4.setIdImage("id image 1");
|
|
|
127 |
observationValidationData4.getVotesDeterminations().add(voteDetermination);
|
|
|
128 |
observationValidationData4.setPourcentageConfiance(I18n.getVocabulary().confiance_sur_cent());
|
|
|
129 |
observationValidationData4.setDate(new Date());
|
|
|
130 |
observationValidationDatas.add(observationValidationData4);
|
|
|
131 |
|
|
|
132 |
PropositionDetermination observationValidationData5 = new PropositionDetermination();
|
|
|
133 |
observationValidationData5.setEspece("Acer monsp subsp. monsp.");
|
|
|
134 |
observationValidationData5.setContributeur("Louis Aragon");
|
159 |
benjamin |
135 |
Commentaire commentaire3 = new Commentaire("Greg", new Date(), "Tout est affaire de décor...");
|
154 |
benjamin |
136 |
observationValidationData5.getCommentaires().add(commentaire3);
|
|
|
137 |
observationValidationData5.setId("2");
|
|
|
138 |
observationValidationData5.setIdImage("id image 1");
|
|
|
139 |
observationValidationData5.getVotesDeterminations().add(voteDetermination);
|
|
|
140 |
observationValidationData5.setPourcentageConfiance(I18n.getVocabulary().confiance_probable());
|
|
|
141 |
observationValidationData5.setDate(new Date());
|
|
|
142 |
observationValidationDatas.add(observationValidationData5);
|
|
|
143 |
|
103 |
benjamin |
144 |
for (int i = 0; i < 20; i++) {
|
48 |
benjamin |
145 |
|
103 |
benjamin |
146 |
Observation observation = new Observation();
|
|
|
147 |
String auteur = auteurs.next();
|
|
|
148 |
observation.setAuteur(auteur);
|
|
|
149 |
observation.setSpecies(auteurObs.get(auteur));
|
|
|
150 |
|
|
|
151 |
int numobs = 44120 + i;
|
|
|
152 |
observation.setNumNomenclatural("num nomenclatural " + i);
|
|
|
153 |
observation.setDate(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date()));
|
|
|
154 |
observation.setFamille("famille " + i);
|
|
|
155 |
observation.setLocalite("localite " + i);
|
135 |
gduche |
156 |
observation.setNomRetenu(auteurObs.get(auteur));
|
103 |
benjamin |
157 |
observation.setMotsClefs(motsClefs);
|
154 |
benjamin |
158 |
observation.setImageCelValidationDatas(observationValidationDatas);
|
103 |
benjamin |
159 |
|
154 |
benjamin |
160 |
Image image = new Image();
|
|
|
161 |
image.setIdImage("id image " + i);
|
|
|
162 |
image.setUrl("http://www.tela-botanica.org/appli:cel-img:0000" + String.valueOf(numobs) + "CRS.jpg");
|
|
|
163 |
observation.getImages().add(image);
|
|
|
164 |
image.setObservation(observation);
|
|
|
165 |
images.add(image);
|
|
|
166 |
|
|
|
167 |
VoteProtocole voteProtocole = new VoteProtocole();
|
|
|
168 |
voteProtocole.setProtocol(protocol1);
|
159 |
benjamin |
169 |
voteProtocole.setVote(3);
|
154 |
benjamin |
170 |
voteProtocole.setContributeur("aurelien");
|
|
|
171 |
voteProtocole.setDate(new Date());
|
|
|
172 |
|
|
|
173 |
image.getVoteProtocoles().add(voteProtocole);
|
|
|
174 |
|
159 |
benjamin |
175 |
VoteProtocole voteProtocole2 = new VoteProtocole();
|
|
|
176 |
voteProtocole2.setProtocol(protocol2);
|
|
|
177 |
voteProtocole2.setVote(2);
|
|
|
178 |
voteProtocole2.setContributeur("jpm");
|
|
|
179 |
voteProtocole2.setDate(new Date());
|
|
|
180 |
|
|
|
181 |
image.getVoteProtocoles().add(voteProtocole2);
|
|
|
182 |
|
103 |
benjamin |
183 |
observations.add(observation);
|
|
|
184 |
}
|
135 |
gduche |
185 |
|
130 |
aurelien |
186 |
pourcentagesConfiance.add(I18n.getVocabulary().confiance_simple_suggestion());
|
|
|
187 |
pourcentagesConfiance.add(I18n.getVocabulary().confiance_probable());
|
|
|
188 |
pourcentagesConfiance.add(I18n.getVocabulary().confiance_sur_cent());
|
9 |
benjamin |
189 |
}
|
|
|
190 |
|
|
|
191 |
public List<Observation> getObservations() {
|
|
|
192 |
return observations;
|
|
|
193 |
}
|
159 |
benjamin |
194 |
|
154 |
benjamin |
195 |
public List<Image> getImages() {
|
|
|
196 |
return images;
|
|
|
197 |
}
|
9 |
benjamin |
198 |
|
154 |
benjamin |
199 |
public List<VoteProtocole> getValidationData(String idImage) {
|
|
|
200 |
for (Observation observation : observations) {
|
|
|
201 |
for (Image image : observation.getImages()) {
|
|
|
202 |
if (image.getIdImage().equals(idImage)) {
|
|
|
203 |
return image.getVoteProtocoles();
|
|
|
204 |
}
|
|
|
205 |
}
|
|
|
206 |
}
|
|
|
207 |
return null;
|
9 |
benjamin |
208 |
}
|
48 |
benjamin |
209 |
|
154 |
benjamin |
210 |
public List<VoteProtocole> getValidationDataByImageAndProtocol(String idImage, String protocolName) {
|
|
|
211 |
|
|
|
212 |
List<VoteProtocole> voteProtocoles = new ArrayList<VoteProtocole>();
|
|
|
213 |
for (Observation observation : observations) {
|
|
|
214 |
for (Image image : observation.getImages()) {
|
|
|
215 |
if (image.getIdImage().equals(idImage)) {
|
|
|
216 |
for (VoteProtocole voteProtocole : image.getVoteProtocoles()) {
|
|
|
217 |
if (voteProtocole.getProtocol().getNom().equals(protocolName)) {
|
|
|
218 |
voteProtocoles.add(voteProtocole);
|
|
|
219 |
}
|
|
|
220 |
}
|
|
|
221 |
}
|
|
|
222 |
}
|
103 |
benjamin |
223 |
}
|
154 |
benjamin |
224 |
return voteProtocoles;
|
103 |
benjamin |
225 |
}
|
|
|
226 |
|
48 |
benjamin |
227 |
public Observation getObservationCourante() {
|
|
|
228 |
return observations.get(0);
|
|
|
229 |
}
|
40 |
aurelien |
230 |
|
154 |
benjamin |
231 |
public List<Image> getImagesEfloreParTaxon(String nomTaxon) {
|
|
|
232 |
return images;
|
9 |
benjamin |
233 |
}
|
115 |
benjamin |
234 |
|
107 |
benjamin |
235 |
public Protocole getProtocole(String nomProtocole) {
|
|
|
236 |
for (Protocole protocole : protocoles) {
|
|
|
237 |
if (protocole.getNom().equals(nomProtocole)) {
|
|
|
238 |
return protocole;
|
|
|
239 |
}
|
|
|
240 |
}
|
|
|
241 |
return null;
|
|
|
242 |
}
|
159 |
benjamin |
243 |
|
|
|
244 |
public void saveVote(VoteProtocole voteProtocole) {
|
|
|
245 |
// TODO implement method
|
154 |
benjamin |
246 |
}
|
135 |
gduche |
247 |
|
154 |
benjamin |
248 |
public List<String> getPourcentagesConfiance() {
|
130 |
aurelien |
249 |
return pourcentagesConfiance;
|
|
|
250 |
}
|
9 |
benjamin |
251 |
|
141 |
aurelien |
252 |
public void saveValidationData(PropositionDetermination validationData) throws ExceptionClient {
|
154 |
benjamin |
253 |
observationValidationDatas.add(validationData);
|
48 |
benjamin |
254 |
}
|
|
|
255 |
|
9 |
benjamin |
256 |
public static MockDatasource getInstance() {
|
|
|
257 |
if (instance == null) {
|
|
|
258 |
instance = new MockDatasource();
|
|
|
259 |
}
|
|
|
260 |
return instance;
|
|
|
261 |
}
|
154 |
benjamin |
262 |
|
9 |
benjamin |
263 |
}
|