Subversion Repositories eFlore/Applications.coel

Rev

Rev 1624 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.composants.pagination;

import java.util.ArrayList;
import java.util.List;

import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Log;
import org.tela_botanica.client.util.UtilString;

import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class ProxyPersonnesAPublication<D> extends Proxy {
        
        String publicationId = null;
        
        public ProxyPersonnesAPublication(Sequenceur sequenceur, String publicationId) {
                super(sequenceur);
                this.publicationId = publicationId;
        }
        
        @Override
          public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
                  this.reader = reader;
                  this.callback = callback;
                  this.loadConfig = loadConfig;

                  BasePagingLoadConfig lc = (BasePagingLoadConfig) loadConfig;            
                  if (!UtilString.isEmpty(this.publicationId))  {
                          mediateur.selectionnerPersonnesAPublication(this, this.publicationId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
                  }     else {
                          this.rafraichir(null);
                  }
          }
        
        public void setPublicationId(String publicationId) {
                this.publicationId = publicationId;
        }

        @Override
        @SuppressWarnings("unchecked")
        public void rafraichir(Object nouvellesDonnees) {       
                try {
                        D donneesRetour = null;
                        if (nouvellesDonnees != null) {
                                data = nouvellesDonnees;
                                if (reader != null) {
                                        donneesRetour = (D) reader.read(loadConfig, data);
                        } else {
                                donneesRetour = (D) data;
                                if (donneesRetour instanceof List) {
                                        donneesRetour = (D) new ArrayList((List) donneesRetour);
                                }
                        }
                        }
                        Log.debug("Dans Proxy : "+donneesRetour.toString());
                        callback.onSuccess(donneesRetour);
                } catch (Exception e) {
                        callback.onFailure(e);
                }
        }

}