r228 - trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
Author: tchemit Date: 2008-01-20 11:51:03 +0000 (Sun, 20 Jan 2008) New Revision: 228 Added: trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java Log: un service bouchon?\195?\169 (je ne le mets dans les tests pour l'instant car je m'en sers dans le module ui-swing pour construire l'ui) Added: 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 (rev 0) +++ trunk/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-01-20 11:51:03 UTC (rev 228) @@ -0,0 +1,96 @@ +/* +* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* 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; +import com.healthmarketscience.rmiio.RemoteOutputStream; +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; +import fr.cemagref.simexplorer.is.storage.MetaDataGenerator; + +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + +/** @author tony */ +public class MockStorageServiceImpl implements StorageService { + + static final int SIZE = 200; + SortedMap<String, MetaDataEntity> mockData; + + public SortedMap<String, MetaDataEntity> mockData() { + if (mockData == null) { + mockData = new TreeMap<String, MetaDataEntity>(); + MetaDataGenerator generator = new MetaDataGenerator(); + for (int i = 0; i < SIZE; i++) { + MetaDataEntity metaDataEntity = generator.generateMetaDataEntity(); + mockData.put(metaDataEntity.getUuid(), metaDataEntity); + } + } + return mockData; + } + + public void commit() throws Exception { + checkImplemented(); + } + + private Object checkImplemented() { + throw new IllegalStateException("not implemented"); + } + + public MetaDataEntity saveElement(RemoteInputStream zipRemoteStream) throws Exception { + return (MetaDataEntity) checkImplemented(); + } + + public MetaDataEntity saveElement(RemoteInputStream xmlRemoteStream, Map<String, RemoteInputStream> attachmentsRemoteStream) throws Exception { + return (MetaDataEntity) checkImplemented(); + } + + public MetaDataEntity getMetadata(String uuid) throws Exception { + return mockData().get(uuid); + } + + public MetaDataEntity getMetadata(String uuid, String version) throws Exception { + return null; + } + + public void exportElement(RemoteOutputStream xmlOutputStream, String uuid, String version) throws Exception { + checkImplemented(); + } + + public int findFullTextCount(String query, boolean onlyLatest) throws Exception { + return (Integer) checkImplemented(); + } + + public MetaDataEntity[] findFullText(String query, boolean onlyLatest, int indexStart, int count, int dateOrder) throws Exception { + return (MetaDataEntity[]) checkImplemented(); + } + + public int findApplicationsCount(boolean onlyLatest) throws Exception { + return mockData().size(); + } + + public MetaDataEntity[] findApplications(boolean onlyLatest, int start, int count, int dateOrder) throws Exception { + return (MetaDataEntity[]) checkImplemented(); + } + + public LoggableElement getElement(String uuid, String version) throws Exception { + return (LoggableElement) checkImplemented(); + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org