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;
|
9 |
benjamin |
10 |
import org.tela_botanica.del.client.modeles.Observation;
|
14 |
benjamin |
11 |
import org.tela_botanica.del.client.modeles.ObservationValidation;
|
9 |
benjamin |
12 |
|
56 |
benjamin |
13 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
14 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
|
|
15 |
|
96 |
aurelien |
16 |
public class MockDatasource extends GwtObservable {
|
9 |
benjamin |
17 |
|
|
|
18 |
static MockDatasource instance;
|
|
|
19 |
|
|
|
20 |
List<Observation> observations = new ArrayList<Observation>();
|
|
|
21 |
|
14 |
benjamin |
22 |
List<ObservationValidation> observationValidationDatas = new ArrayList<ObservationValidation>();
|
48 |
benjamin |
23 |
|
|
|
24 |
ArrayList<String> propositionsTaxonDatas = new ArrayList<String>();
|
|
|
25 |
|
9 |
benjamin |
26 |
private MockDatasource() {
|
|
|
27 |
|
55 |
gduche |
28 |
HashMap<String, String> auteurObs = new HashMap<String, String>();
|
|
|
29 |
auteurObs.put("Juliette 1MOUREAU", "Tragopogon porrifolius subsp. australis (Jord.) Nyman");
|
|
|
30 |
auteurObs.put("Robert 2LERAS", "Iris lutescens subsp. lutescens");
|
|
|
31 |
auteurObs.put("Geneviève 3BOTTI", "Euphorbia dendroides L.");
|
|
|
32 |
auteurObs.put("Robert 4LERAS", "Lonicera japonica Thunb. ex Murray");
|
|
|
33 |
auteurObs.put("Juliette 5MOUREAU", "Lavatera arborea L.");
|
|
|
34 |
auteurObs.put("Robert 6LERAS", "Lavatera arborea L.");
|
|
|
35 |
auteurObs.put("Juliette 7MOUREAU", "Serapias vomeracea (Burm.f.) Briq. ");
|
|
|
36 |
auteurObs.put("Benjamin 8LIENS", "Lonicera etrusca Santi");
|
|
|
37 |
auteurObs.put("Aurélient 9PERONNET", "Ophrys scolopax Cav. ");
|
|
|
38 |
auteurObs.put("Grégoire 10DUCHÉ", "Staehelina dubia L. ");
|
|
|
39 |
auteurObs.put("Juliette 11MOUREAU", "Tragopogon porrifolius subsp. australis (Jord.) Nyman");
|
|
|
40 |
auteurObs.put("Robert 12LERAS", "Iris lutescens subsp. lutescens");
|
|
|
41 |
auteurObs.put("Geneviève 13BOTTI", "Euphorbia dendroides L.");
|
|
|
42 |
auteurObs.put("Robert 14LERAS", "Lonicera japonica Thunb. ex Murray");
|
|
|
43 |
auteurObs.put("Juliette 15MOUREAU", "Lavatera arborea L.");
|
|
|
44 |
auteurObs.put("Robert 16LERAS", "Lavatera arborea L.");
|
|
|
45 |
auteurObs.put("Juliette 17MOUREAU", "Serapias vomeracea (Burm.f.) Briq. ");
|
|
|
46 |
auteurObs.put("Benjamin 18LIENS", "Lonicera etrusca Santi");
|
|
|
47 |
auteurObs.put("Aurélient 19PERONNET", "Ophrys scolopax Cav. ");
|
|
|
48 |
auteurObs.put("Grégoire 20DUCHÉ", "Staehelina dubia L. ");
|
|
|
49 |
|
61 |
benjamin |
50 |
ArrayList<String> motsClefs = new ArrayList<String>();
|
|
|
51 |
motsClefs.add("plantnet");
|
|
|
52 |
motsClefs.add("fleur");
|
|
|
53 |
motsClefs.add("fruit");
|
|
|
54 |
|
55 |
gduche |
55 |
Iterator<String> auteurs = auteurObs.keySet().iterator();
|
|
|
56 |
|
9 |
benjamin |
57 |
for (int i = 0; i < 20; i++) {
|
|
|
58 |
|
|
|
59 |
Observation observation = new Observation();
|
55 |
gduche |
60 |
String auteur = auteurs.next();
|
|
|
61 |
observation.setAuteur(auteur);
|
|
|
62 |
observation.setSpecies(auteurObs.get(auteur));
|
9 |
benjamin |
63 |
|
45 |
gduche |
64 |
int numobs = 44120 + i;
|
51 |
gduche |
65 |
observation.setUrl("http://www.tela-botanica.org/appli:cel-img:0000" + String.valueOf(numobs) + "CRS.jpg");
|
9 |
benjamin |
66 |
observation.setNumNomenclatural("num nomenclatural " + i);
|
|
|
67 |
observation.setIdImage("id image " + i);
|
56 |
benjamin |
68 |
observation.setDate(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date()));
|
9 |
benjamin |
69 |
observation.setFamille("famille " + i);
|
|
|
70 |
observation.setLocalite("localite " + i);
|
35 |
gduche |
71 |
observation.setNomRetenu("nom retenu " + i);
|
61 |
benjamin |
72 |
observation.setMotsClefs(motsClefs);
|
9 |
benjamin |
73 |
|
|
|
74 |
observations.add(observation);
|
|
|
75 |
}
|
|
|
76 |
|
14 |
benjamin |
77 |
ObservationValidation observationValidationData = new ObservationValidation();
|
96 |
aurelien |
78 |
observationValidationData.setEspece("Espece 1");
|
|
|
79 |
observationValidationData.setContributeur("contributeur test");
|
9 |
benjamin |
80 |
observationValidationData.setId("1");
|
|
|
81 |
observationValidationData.setIdImage("id image 1");
|
|
|
82 |
observationValidationData.setVote(4);
|
96 |
aurelien |
83 |
observationValidationData.setPourcentageConfiance(90);
|
61 |
benjamin |
84 |
observationValidationData.setDate(new Date());
|
9 |
benjamin |
85 |
observationValidationDatas.add(observationValidationData);
|
|
|
86 |
|
14 |
benjamin |
87 |
ObservationValidation observationValidationData2 = new ObservationValidation();
|
96 |
aurelien |
88 |
observationValidationData2.setContributeur("contributeur test 2");
|
9 |
benjamin |
89 |
observationValidationData2.setId("2");
|
|
|
90 |
observationValidationData2.setIdImage("id image 1");
|
|
|
91 |
observationValidationData2.setVote(2);
|
96 |
aurelien |
92 |
observationValidationData2.setPourcentageConfiance(50);
|
61 |
benjamin |
93 |
observationValidationData2.setDate(new Date());
|
9 |
benjamin |
94 |
observationValidationDatas.add(observationValidationData2);
|
48 |
benjamin |
95 |
|
96 |
aurelien |
96 |
ObservationValidation observationValidationData3 = new ObservationValidation();
|
|
|
97 |
observationValidationData3.setEspece("Acer monsp. L.");
|
|
|
98 |
observationValidationData3.setContributeur("Léo Ferré");
|
|
|
99 |
observationValidationData3.setCommentaire("Avec le temps...");
|
|
|
100 |
observationValidationData3.setId("1");
|
|
|
101 |
observationValidationData3.setIdImage("id image 1");
|
|
|
102 |
observationValidationData2.setVote(3);
|
|
|
103 |
observationValidationData3.setPourcentageConfiance(90);
|
|
|
104 |
observationValidationData3.setDate(new Date());
|
|
|
105 |
observationValidationDatas.add(observationValidationData3);
|
48 |
benjamin |
106 |
|
96 |
aurelien |
107 |
ObservationValidation observationValidationData4 = new ObservationValidation();
|
|
|
108 |
observationValidationData4.setEspece("Acer aceras aus.");
|
|
|
109 |
observationValidationData4.setContributeur("Pierre Desproges");
|
|
|
110 |
observationValidationData4.setCommentaire("Public chéri mon amour !");
|
|
|
111 |
observationValidationData4.setId("2");
|
|
|
112 |
observationValidationData4.setIdImage("id image 1");
|
|
|
113 |
observationValidationData2.setVote(1);
|
|
|
114 |
observationValidationData4.setPourcentageConfiance(30);
|
|
|
115 |
observationValidationData4.setDate(new Date());
|
|
|
116 |
observationValidationDatas.add(observationValidationData4);
|
48 |
benjamin |
117 |
|
96 |
aurelien |
118 |
ObservationValidation observationValidationData5 = new ObservationValidation();
|
|
|
119 |
observationValidationData5.setEspece("Acer monsp subsp. monsp.");
|
|
|
120 |
observationValidationData5.setContributeur("Louis Aragon");
|
|
|
121 |
observationValidationData5.setCommentaire("Tout est affaire de décor");
|
|
|
122 |
observationValidationData5.setId("2");
|
|
|
123 |
observationValidationData5.setIdImage("id image 1");
|
|
|
124 |
observationValidationData2.setVote(2);
|
|
|
125 |
observationValidationData5.setPourcentageConfiance(50);
|
|
|
126 |
observationValidationData5.setDate(new Date());
|
|
|
127 |
observationValidationDatas.add(observationValidationData5);
|
48 |
benjamin |
128 |
|
47 |
aurelien |
129 |
propositionsTaxonDatas.add("Acer monsp. L.");
|
|
|
130 |
propositionsTaxonDatas.add("Acer aceras aus.");
|
|
|
131 |
propositionsTaxonDatas.add("Acer monsp subsp. monsp.");
|
|
|
132 |
propositionsTaxonDatas.add("Acer australis L.");
|
9 |
benjamin |
133 |
}
|
|
|
134 |
|
|
|
135 |
public List<Observation> getObservations() {
|
40 |
aurelien |
136 |
|
9 |
benjamin |
137 |
return observations;
|
|
|
138 |
}
|
|
|
139 |
|
14 |
benjamin |
140 |
public List<ObservationValidation> getValidationData(String idImage) {
|
9 |
benjamin |
141 |
|
|
|
142 |
return observationValidationDatas;
|
|
|
143 |
}
|
48 |
benjamin |
144 |
|
47 |
aurelien |
145 |
public ArrayList<String> getPropositionsTaxonsData(String idImage) {
|
9 |
benjamin |
146 |
|
47 |
aurelien |
147 |
return propositionsTaxonDatas;
|
|
|
148 |
}
|
|
|
149 |
|
48 |
benjamin |
150 |
public Observation getObservationCourante() {
|
|
|
151 |
return observations.get(0);
|
|
|
152 |
}
|
40 |
aurelien |
153 |
|
48 |
benjamin |
154 |
public List<Observation> getObservationsEfloreParTaxon(String nomTaxon) {
|
|
|
155 |
return observations;
|
9 |
benjamin |
156 |
}
|
|
|
157 |
|
48 |
benjamin |
158 |
public void saveValidationData(ObservationValidation validationData) throws ExceptionClient {
|
96 |
aurelien |
159 |
observationValidationDatas.add(validationData);
|
97 |
aurelien |
160 |
|
|
|
161 |
setChanged();
|
96 |
aurelien |
162 |
notifyObservers();
|
48 |
benjamin |
163 |
}
|
|
|
164 |
|
9 |
benjamin |
165 |
public static MockDatasource getInstance() {
|
|
|
166 |
if (instance == null) {
|
|
|
167 |
instance = new MockDatasource();
|
|
|
168 |
}
|
|
|
169 |
return instance;
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
}
|