Subversion Repositories eFlore/Archives.cel-v2

Compare Revisions

Ignore whitespace Rev 19 → Rev 20

/trunk/src/org/tela_botanica/client/image/ImageModele.java
9,6 → 9,14
import org.tela_botanica.client.modeles.ListeImageCarnet;
import org.tela_botanica.client.modeles.ListeImageAsynchroneDAO;
 
import com.gwtext.client.data.ArrayReader;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.IntegerFieldDef;
import com.gwtext.client.data.MemoryProxy;
import com.gwtext.client.data.RecordDef;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
 
/**
* Modèle d'accès aux données pour les images.
* C'est un singleton
15,7 → 23,7
* @author aurelien
*
*/
public class ImageModele {
public class ImageModele implements Rafraichissable {
private static boolean estInstancie = false ;
23,6 → 31,8
private ListeImageCarnet cacheImage = new ListeImageCarnet(0) ;
private Store st = null ;
static ImageModele Instance(ImageMediateur im)
{
if(!estInstancie)
48,7 → 58,7
public void obtenirPhotoGalerie(Rafraichissable r)
{
ListeImageAsynchroneDAO liaDAO = new ListeImageAsynchroneDAO();
liaDAO.ObtenirListeImages(r);
liaDAO.ObtenirListeImages(this);
}
public void uploaderImages()
112,4 → 122,71
iaDaO.SynchroniserBaseDeDonnees(ic) ;
}
 
public void supprimerImages(String[] ids) {
String rids[] = new String[ids.length] ;
ListeImageAsynchroneDAO liDao = new ListeImageAsynchroneDAO() ;
liDao.setIMediateur(iMediateur);
for (int i = 0; i < ids.length; i++) {
String key = ids[i] ;
ImageCarnet ic = (ImageCarnet)cacheImage.get(key) ;
rids[i] = ic.getId() ;
}
if(rids.length != 0)
{
liDao.supprimerBaseDeDonnees(rids);
}
}
 
public void rafraichir(Object nouvelleDonnees,
boolean repandreRafraichissement) {
ListeImageCarnet data = (ListeImageCarnet) nouvelleDonnees ;
Object[][] photoData = new Object[data.size()][7];
int i = 0 ;
for (Iterator it = data.keySet().iterator(); it.hasNext();)
{
ImageCarnet im = (ImageCarnet) data.get(it.next());
photoData[i][0] = im.getOrdre() ;
photoData[i][1] = im.getDate() ;
photoData[i][2] = im.getIptcCity() ;
photoData[i][3] = im.getMake()+" "+im.getModel() ;
photoData[i][4] = im.getSUrl() ;
photoData[i][5] = im.getMUrl() ;
photoData[i][6] = im.getUrl() ;
i++ ;
}
 
// creation du store
FieldDef defNumImage = new IntegerFieldDef("num_image");
FieldDef defDatImage = new StringFieldDef("dat_image");
FieldDef defLieImage = new StringFieldDef("lie_image");
FieldDef defAppImage = new StringFieldDef("app_image");
FieldDef defUrlImageS = new StringFieldDef("url_image_S");
FieldDef defUrlImageM = new StringFieldDef("url_image_M");
FieldDef defUrlImage = new StringFieldDef("url_image");
FieldDef[] defTab = {defNumImage,defDatImage,defLieImage,defAppImage,defUrlImageS,defUrlImageM,defUrlImage};
RecordDef rd = new RecordDef(defTab) ;
final MemoryProxy dataProxy = new MemoryProxy(photoData);
final ArrayReader reader = new ArrayReader(rd);
 
final Store photoStore = new Store(dataProxy, reader);
rafraichirListeImage(nouvelleDonnees);
st = photoStore ;
if(repandreRafraichissement)
{
getIMediateur().synchroniserDonneesZoomListeGalerie(st, this) ;
}
}
}