Subversion Repositories eFlore/Applications.coel

Rev

Rev 1567 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1488 cyprien 1
package org.tela_botanica.client.composants.pagination;
2
 
3
import java.util.ArrayList;
4
import java.util.List;
5
 
6
import org.tela_botanica.client.synchronisation.Sequenceur;
1567 jpm 7
import org.tela_botanica.client.util.Log;
1496 cyprien 8
import org.tela_botanica.client.util.UtilString;
1488 cyprien 9
 
10
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
11
import com.google.gwt.user.client.rpc.AsyncCallback;
12
 
13
public class ProxyPersonnesAPublication<D> extends Proxy {
14
 
15
	String publicationId = null;
16
 
17
	public ProxyPersonnesAPublication(Sequenceur sequenceur, String publicationId) {
18
		super(sequenceur);
19
		this.publicationId = publicationId;
20
	}
21
 
22
	@Override
23
	  public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
24
		  this.reader = reader;
25
		  this.callback = callback;
26
		  this.loadConfig = loadConfig;
27
 
1567 jpm 28
		  BasePagingLoadConfig lc = (BasePagingLoadConfig) loadConfig;
1496 cyprien 29
		  if (!UtilString.isEmpty(this.publicationId))	{
30
			  mediateur.selectionnerPersonnesAPublication(this, this.publicationId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
1624 aurelien 31
		  }	else {
1567 jpm 32
			  this.rafraichir(null);
1496 cyprien 33
		  }
1488 cyprien 34
	  }
35
 
36
	public void setPublicationId(String publicationId) {
37
		this.publicationId = publicationId;
38
	}
39
 
40
	@Override
41
	@SuppressWarnings("unchecked")
42
	public void rafraichir(Object nouvellesDonnees) {
1567 jpm 43
		try {
1496 cyprien 44
			D donneesRetour = null;
1567 jpm 45
			if (nouvellesDonnees != null) {
1496 cyprien 46
				data = nouvellesDonnees;
1567 jpm 47
			   	if (reader != null) {
1496 cyprien 48
			   		donneesRetour = (D) reader.read(loadConfig, data);
1567 jpm 49
		    	} else {
1496 cyprien 50
		    		donneesRetour = (D) data;
1567 jpm 51
			        if (donneesRetour instanceof List) {
1496 cyprien 52
			        	donneesRetour = (D) new ArrayList((List) donneesRetour);
53
			        }
54
		    	}
1567 jpm 55
			}
56
			Log.debug("Dans Proxy : "+donneesRetour.toString());
1496 cyprien 57
			callback.onSuccess(donneesRetour);
1567 jpm 58
		} catch (Exception e) {
59
			callback.onFailure(e);
1488 cyprien 60
		}
61
	}
62
 
63
}