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