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;
|
1496 |
cyprien |
14 |
import org.tela_botanica.client.util.UtilString;
|
1488 |
cyprien |
15 |
|
|
|
16 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
17 |
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
|
|
18 |
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
|
|
19 |
import com.extjs.gxt.ui.client.data.DataReader;
|
|
|
20 |
import com.extjs.gxt.ui.client.data.MemoryProxy;
|
|
|
21 |
import com.extjs.gxt.ui.client.data.ModelData;
|
|
|
22 |
import com.google.gwt.json.client.JSONObject;
|
|
|
23 |
import com.google.gwt.json.client.JSONString;
|
|
|
24 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
25 |
|
|
|
26 |
public class ProxyPersonnesAPublication<D> extends Proxy {
|
|
|
27 |
|
|
|
28 |
String publicationId = null;
|
|
|
29 |
|
|
|
30 |
public ProxyPersonnesAPublication(Sequenceur sequenceur, String publicationId) {
|
|
|
31 |
super(sequenceur);
|
|
|
32 |
this.publicationId = publicationId;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
@Override
|
|
|
36 |
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
|
|
|
37 |
this.reader = reader;
|
|
|
38 |
this.callback = callback;
|
|
|
39 |
this.loadConfig = loadConfig;
|
|
|
40 |
|
|
|
41 |
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
|
1496 |
cyprien |
42 |
if (!UtilString.isEmpty(this.publicationId)) {
|
|
|
43 |
mediateur.selectionnerPersonnesAPublication(this, this.publicationId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
|
|
|
44 |
} else {
|
|
|
45 |
this.rafraichir(null);
|
|
|
46 |
}
|
1488 |
cyprien |
47 |
}
|
|
|
48 |
|
|
|
49 |
public void setPublicationId(String publicationId) {
|
|
|
50 |
this.publicationId = publicationId;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
@Override
|
|
|
54 |
@SuppressWarnings("unchecked")
|
|
|
55 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
56 |
try
|
|
|
57 |
{
|
1496 |
cyprien |
58 |
D donneesRetour = null;
|
|
|
59 |
if (nouvellesDonnees!=null) {
|
|
|
60 |
data = nouvellesDonnees;
|
|
|
61 |
if (reader != null)
|
|
|
62 |
{
|
|
|
63 |
donneesRetour = (D) reader.read(loadConfig, data);
|
|
|
64 |
}
|
|
|
65 |
else
|
|
|
66 |
{
|
|
|
67 |
donneesRetour = (D) data;
|
|
|
68 |
if (donneesRetour instanceof List)
|
|
|
69 |
{
|
|
|
70 |
donneesRetour = (D) new ArrayList((List) donneesRetour);
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
callback.onSuccess(donneesRetour);
|
1488 |
cyprien |
75 |
}
|
|
|
76 |
catch (Exception e)
|
|
|
77 |
{
|
|
|
78 |
callback.onFailure(e);
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
}
|