Author: tchemit Date: 2008-01-22 05:57:07 +0000 (Tue, 22 Jan 2008) New Revision: 377 Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java Log: correction erreur dans algo Modified: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java =================================================================== --- trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-01-22 05:56:50 UTC (rev 376) +++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-01-22 05:57:07 UTC (rev 377) @@ -1,5 +1,5 @@ /* -* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, * Tony Chemit * * This program is free software; you can redistribute it and/or @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* \#\#% */ +* ##% */ package fr.cemagref.simexplorer.is.service; import com.healthmarketscience.rmiio.RemoteInputStream; @@ -24,7 +24,8 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; import fr.cemagref.simexplorer.is.storage.MetaDataGenerator; -import java.util.Iterator; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; @@ -32,16 +33,20 @@ /** @author tony */ public class MockStorageServiceImpl implements StorageService { - static final int SIZE = 200; + static final int SIZE = 400; SortedMap<String, MetaDataEntity> mockData; + List<String> mockDataIndex; public SortedMap<String, MetaDataEntity> mockData() { if (mockData == null) { mockData = new TreeMap<String, MetaDataEntity>(); + mockDataIndex = new ArrayList<String>(); MetaDataGenerator generator = new MetaDataGenerator(); for (int i = 0; i < SIZE; i++) { MetaDataEntity metaDataEntity = generator.generateMetaDataEntity(); + metaDataEntity.setName(i + " -- " + metaDataEntity.getName()); mockData.put(metaDataEntity.getUuid(), metaDataEntity); + mockDataIndex.add(metaDataEntity.getUuid()); } } return mockData; @@ -89,22 +94,16 @@ public MetaDataEntity[] findApplications(boolean onlyLatest, int start, int count, int dateOrder) throws Exception { int last = start + count; + System.out.println("ask data from " + start + " width:" + count); SortedMap<String, MetaDataEntity> map = mockData(); if (last > map.size()) { - last = map.size() - last; + last = map.size(); } MetaDataEntity[] result = new MetaDataEntity[last - start]; - int i = 0; - Iterator<MetaDataEntity> it = map.values().iterator(); - for (; it.hasNext();) { - if (i == start) { - break; - } - it.next(); + + for (int i = start; i < last; i++) { + result[i - start] = map.get(mockDataIndex.get(i)); } - for (; i < last; i++) { - result[i - start] = it.next(); - } return result; }