1488 |
cyprien |
1 |
package org.tela_botanica.client.composants.pagination;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.HashMap;
|
|
|
5 |
import java.util.List;
|
|
|
6 |
|
|
|
7 |
import org.tela_botanica.client.Mediateur;
|
|
|
8 |
import org.tela_botanica.client.RegistreId;
|
|
|
9 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
10 |
import org.tela_botanica.client.modeles.ValeurListe;
|
|
|
11 |
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
|
|
|
12 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
|
|
13 |
import org.tela_botanica.client.util.Debug;
|
|
|
14 |
|
|
|
15 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
16 |
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
|
|
17 |
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
|
|
18 |
import com.extjs.gxt.ui.client.data.DataReader;
|
|
|
19 |
import com.extjs.gxt.ui.client.data.MemoryProxy;
|
|
|
20 |
import com.extjs.gxt.ui.client.data.ModelData;
|
|
|
21 |
import com.google.gwt.json.client.JSONObject;
|
|
|
22 |
import com.google.gwt.json.client.JSONString;
|
|
|
23 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
24 |
|
|
|
25 |
public class ProxyPersonnesAPublication<D> extends Proxy {
|
|
|
26 |
|
|
|
27 |
String publicationId = null;
|
|
|
28 |
|
|
|
29 |
public ProxyPersonnesAPublication(Sequenceur sequenceur, String publicationId) {
|
|
|
30 |
super(sequenceur);
|
|
|
31 |
this.publicationId = publicationId;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
@Override
|
|
|
35 |
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
|
|
|
36 |
this.reader = reader;
|
|
|
37 |
this.callback = callback;
|
|
|
38 |
this.loadConfig = loadConfig;
|
|
|
39 |
|
|
|
40 |
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
|
|
|
41 |
mediateur.selectionnerPersonnesAPublication(this, this.publicationId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public void setPublicationId(String publicationId) {
|
|
|
45 |
this.publicationId = publicationId;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
@Override
|
|
|
49 |
@SuppressWarnings("unchecked")
|
|
|
50 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
51 |
try
|
|
|
52 |
{
|
|
|
53 |
data = nouvellesDonnees;
|
|
|
54 |
D d = null;
|
|
|
55 |
|
|
|
56 |
if (reader != null)
|
|
|
57 |
{
|
|
|
58 |
d = (D) reader.read(loadConfig, data);
|
|
|
59 |
}
|
|
|
60 |
else
|
|
|
61 |
{
|
|
|
62 |
d = (D) data;
|
|
|
63 |
if (d instanceof List)
|
|
|
64 |
{
|
|
|
65 |
d = (D) new ArrayList((List) d);
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
callback.onSuccess(d);
|
|
|
70 |
}
|
|
|
71 |
catch (Exception e)
|
|
|
72 |
{
|
|
|
73 |
callback.onFailure(e);
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
}
|