Author: tchemit Date: 2008-01-24 11:34:56 +0000 (Thu, 24 Jan 2008) New Revision: 487 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java Log: ajout classe utilitaire pour effectuer des appels au bon service de storage Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/StorageServiceHelper.java 2008-01-24 11:34:56 UTC (rev 487) @@ -0,0 +1,63 @@ +/* +* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* 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.ui; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.MetaDataEntity; +import fr.cemagref.simexplorer.is.service.StorageService; + +/** + * Une classe pour encapsuler les appels aux services Sotrage + * + * @author chemit + */ +public class StorageServiceHelper { + + public static int getCount(SimExplorerContext context, boolean remote, String query, boolean onlyLatest) throws Exception { + StorageService service = context.getStorageService(remote); + String token = context.getToken(); + int size; + if (query == null || query.isEmpty()) { + size = service.findApplicationsCount(token, onlyLatest); + } else { + size = service.findFullTextCount(token, query, onlyLatest); + } + return size; + } + + public static MetaDataEntity[] getData(SimExplorerContext context, boolean remote, boolean onlyLatest, String query, long newFirstIndex, int width, int rowOrder) throws Exception { + StorageService service = context.getStorageService(remote); + String token = context.getToken(); + MetaDataEntity[] data; + if (query == null || query.isEmpty()) { + data = service.findApplications(token, onlyLatest, (int) newFirstIndex, width, rowOrder); + } else { + data = service.findFullText(token, query, onlyLatest, (int) newFirstIndex, width, rowOrder); + } + return data; + } + + public static LoggableElement getElement(SimExplorerContext context, boolean remote, String uuid, String version) throws Exception { + StorageService service = context.getStorageService(remote); + LoggableElement data; + data = service.getElement(context.getToken(), uuid, version); + return data; + } + +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org