Author: tchemit Date: 2008-02-26 00:35:04 +0000 (Tue, 26 Feb 2008) New Revision: 1243 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementCache.java Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/DownloadAbstractAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/ListTabModel.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/SynchronizeTabModel.java Log: on remonte les RemoteService au niveau du module service pour que ?\195?\167a soit reutilisable integration des services dans le context directement mise en place cache sur les loggableElement recuperes (todo a finir (capacite, interaction avec l'historique...) Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorer.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -20,14 +20,13 @@ import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction; +import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigMain; import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerMainUI; import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab; import fr.cemagref.simexplorer.is.ui.swing.ui.util.ErrorDialog; -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigMain; import org.codelutin.i18n.I18n; import java.awt.event.ActionEvent; -import java.io.IOException; /** * L'application principale @@ -39,6 +38,7 @@ /** le context principal de l'application */ protected static SimExplorerContext context; + public static SimExplorerContext getContext() { checkInitContext(); return context; @@ -50,8 +50,9 @@ * chargement du context * * @param args les arguments passés à l'application + * @throws java.io.IOException si pb pendant l'init */ - public static void init(String... args) { + public static void init(String... args) throws Exception { // init context context = new SimExplorerContext(); @@ -68,13 +69,14 @@ // init i18n with user locale context.initI18n(); + // mark if first launch context.setFirstLaunch(!context.getConfig().getSource().exists()); - try { - // save config - context.getConfig().save(); - } catch (IOException e) { - throw new RuntimeException(e); - } + + // save config + context.getConfig().save(); + + // init services + context.initServices(); } /** Lancement de l'ui après init de l'application. */ @@ -89,6 +91,7 @@ // show local tab mainUI.getToggleTab_local().doClick(); } + if (conf.isAutoConnect()) { try { // try to connect @@ -106,7 +109,7 @@ // refresh ui accessibles actions if (!context.isConnected()) { - ((SimExplorerAbstractAction)mainUI.getConnectAction(false)).updateUI(); + ((SimExplorerAbstractAction) mainUI.getConnectAction(false)).updateUI(); } mainUI.setVisible(true); } @@ -123,24 +126,26 @@ } } - public static void main(String... args) throws Exception { + public static void main(String... args) { + try { + // init application (parser,config,i18n,...) + init(args); - // init application (parser,config,i18n,...) - init(args); + // launch actions required + context.getParser().doAllActions(); - // launch actions required - context.getParser().doAllActions(); + // show edit config if first launch + if (context.isFirstLaunch()) { + SimExplorerActionManager.fireAction("config", context); + } - // show edit config if first launch - if (context.isFirstLaunch()) { - SimExplorerActionManager.fireAction("config",context); + // launch ui only if required + if (!context.isQuit() && context.isLaunchUI()) { + launch(); + } + } catch (Exception e) { + ErrorDialog.showError(e); } - - // launch ui only if required - if (!context.isQuit() && context.isLaunchUI()) { - launch(); - } - } public static void checkInitContext() { Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/SimExplorerContext.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -19,25 +19,42 @@ package fr.cemagref.simexplorer.is.ui.swing; import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; +import fr.cemagref.simexplorer.is.exceptions.UnreachableServiceException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl; +import fr.cemagref.simexplorer.is.service.StorageService; +import fr.cemagref.simexplorer.is.service.StorageServiceClient; +import fr.cemagref.simexplorer.is.service.remote.RemoteService; +import fr.cemagref.simexplorer.is.service.remote.RemoteStorageService; +import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerOptionParser; import fr.cemagref.simexplorer.is.ui.swing.commandline.actions.SimExplorerCommonActions; -import fr.cemagref.simexplorer.is.ui.swing.commandline.SimExplorerOptionParser; -import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigRemote; import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigLocal; import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigMain; +import fr.cemagref.simexplorer.is.ui.swing.commandline.configs.SimExplorerAbstractConfigRemote; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementCache; +import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.EntityTypeEnum; +import fr.cemagref.simexplorer.is.storage.SortColumn; +import org.codelutin.i18n.I18n; import org.codelutin.option.ParserException; -import org.codelutin.i18n.I18n; import java.io.IOException; /** * Le context de l'application, implanté en singleton. * <p/> - * Contient la configuration de l'application, le parseur d'options,... + * Contient la configuration de l'application, le parseur d'options, les services, ... * + * Contient aussi des méthodes qui appelent les services + * * @author chemit */ public class SimExplorerContext { + private final static boolean mock = false; + /** * le parseur utilisé au démarrage pour récupérer les options passées * par l'utilisateur. @@ -59,6 +76,18 @@ /** le token pour la connexion au serveur distant */ protected String token; + /** le service de données distant */ + protected StorageService remoteService; + + /** le service de données local */ + protected StorageService localService; + + /** le cache de LE local */ + protected LoggableElementCache localCache; + + /** le cache de LE distant */ + protected LoggableElementCache remoteCache; + /** * @return le parseur utilisé pour parser les options de la ligne de * commande. @@ -79,17 +108,17 @@ /** @return la configuration de l'application */ public SimExplorerAbstractConfigMain getConfig() { - return getParser().getMainConfig(); + return getParser().getMainConfig(); } /** @return la configuration de l'application */ public SimExplorerAbstractConfigRemote getRemoteConfig() { - return getParser().getRemoteConfig(); + return getParser().getRemoteConfig(); } /** @return la configuration de l'application */ public SimExplorerAbstractConfigLocal getLocalConfig() { - return getParser().getLocalConfig(); + return getParser().getLocalConfig(); } /** @@ -150,9 +179,99 @@ this.token = token; } + public void initI18n() { + I18n.initISO88591(getConfig().getUserLocale()); + } + + + public void initServices() { + // init local service + getLocalStorageService(); + + if (getConfig().isAutoConnect()) { + getRemoteStorageService(); + } + } + + public LoggableElement getLoggableElement(boolean remote, String uuid, Version version) { + LoggableElementCache cache = getCache(remote); + LoggableElement result; + result = cache.get(uuid, version); + return result; + } + + public Version[] getVersions(boolean remote, String uuid) { + try { + Version[] result; + result = getStorageService(remote).getVersions(getToken(), uuid); + return result; + } catch (SimExplorerException e) { + throw new SimExplorerRuntimeException(e); + } + } + + public int getCount(boolean remote, String query, boolean onlyLatest) { + StorageService service = getStorageService(remote); + String token = getToken(); + int size; + try { + if (query == null || query.isEmpty()) { + size = service.findElementsCount(token, EntityTypeEnum.ExplorationApplication.toString(), onlyLatest); + } else { + size = service.findFullTextCount(token, query, "", onlyLatest); + } + return size; + } catch (SimExplorerException e) { + throw new SimExplorerRuntimeException(e); + } + } + + public MetaData[] getData( boolean remote, boolean onlyLatest, String query, long newFirstIndex, int width, SortColumn column, boolean ascending) { + StorageService service = getStorageService(remote); + String token = getToken(); + try { + MetaData[] data; + if (query == null || query.isEmpty()) { + data = service.findElements(token, EntityTypeEnum.ExplorationApplication.toString(), onlyLatest, (int) newFirstIndex, width, column.name(), ascending); + } else { + data = service.findFullText(token, query, "", onlyLatest, (int) newFirstIndex, width, column.name(), ascending); + //data = service.findFullText(token, query, SearchColumn.AllFields.name(), onlyLatest, (int) newFirstIndex, width, column.name(), ascending); + } + return data; + } catch (SimExplorerException e) { + throw new SimExplorerRuntimeException(e); + } + } + + public String loginUser(boolean remote, String login, String hashPassword) throws UnreachableServiceException { + StorageService service = getStorageService(remote); + try { + String token; + token = service.loginUser(login, hashPassword); + setToken(token); + return token; + } catch (SimExplorerException e) { + throw new SimExplorerRuntimeException(e); + } + } + + public StorageService getStorageService(boolean remote) { + StorageService service; + service = remote ? getRemoteStorageService() : getLocalStorageService(); + if (service == null) { + throw new UnreachableServiceException("could not find service " + (remote ? "remote" : "local")); + } + return service; + } + public LoggableElementCache getCache(boolean remote) { + getStorageService(remote); + LoggableElementCache cache; + cache = remote?remoteCache:localCache; + return cache; + } + /** restricted access constructor */ SimExplorerContext() { - } /** @@ -177,7 +296,48 @@ getRemoteConfig(); } - public void initI18n() { - I18n.initISO88591(getConfig().getUserLocale()); + /** @return le service de storage locale */ + protected StorageService getLocalStorageService() { + if (localService == null) { + if (mock) { + localService = new MockStorageServiceImpl(false); + } else { + try { + localService = new StorageServiceClient(getConfig().getSource().toString(), "local."); + } catch (Exception e) { + throw new SimExplorerRuntimeException(e); + } + } + if (localService != null) { + // init the cache + localCache = new LoggableElementCache(this, localService); + } + } + return localService; } + + /** @return le service de storage distant */ + protected StorageService getRemoteStorageService() { + if (remoteService == null) { + if (mock) { + remoteService = new MockStorageServiceImpl(true); + } else { + + RemoteService.setUri(getRemoteConfig().getURI().toString()); + + try { + remoteService = RemoteStorageService.getStorageService(); + + } catch (Exception e) { + // no remote service available + remoteService = null; + } + } + if (remoteService != null) { + // init the cache + remoteCache = new LoggableElementCache(this, remoteService); + } + } + return remoteService; + } } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -19,7 +19,6 @@ package fr.cemagref.simexplorer.is.ui.swing; import com.healthmarketscience.rmiio.SerializableInputStream; - import fr.cemagref.simexplorer.is.entities.EntityTypeEnum; import fr.cemagref.simexplorer.is.entities.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.data.LoggableElement; @@ -28,58 +27,48 @@ import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; import fr.cemagref.simexplorer.is.exceptions.UnreachableServiceException; -import fr.cemagref.simexplorer.is.service.MockStorageServiceImpl; import fr.cemagref.simexplorer.is.service.StorageService; -import fr.cemagref.simexplorer.is.service.StorageServiceClient; -import static fr.cemagref.simexplorer.is.service.StorageServiceHelper.STORAGE_SERVICE_LOOKUP_NAME; import fr.cemagref.simexplorer.is.storage.SortColumn; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementCache; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import java.net.URI; -import java.util.Properties; /** * Une classe pour encapsuler les appels aux services Storage et leur initialisation. * * @author chemit + * @deprecated use directly service from context */ public class StorageServiceHelper { - private final static boolean mock = false; - - private final static String PROVIDER_URL = "java.naming.provider.url"; - private final static String FACTORY_INITIAL = "java.naming.factory.initial"; - private final static String FACTORY_URL_PKGS = "java.naming.factory.url.pkgs"; - - /** le service de données distant */ - protected static StorageService remoteStorageService; - - /** le service de données local */ - protected static StorageService storageService; - /** * @param context le context de l'application * @param remote flag pour indiquer le type de service recherché (local ou remote) * @return le service instancié et initialisé * @throws UnreachableServiceException si service non joignable */ - public static StorageService getService(SimExplorerContext context, boolean remote) throws UnreachableServiceException { + private static StorageService getService(SimExplorerContext context, boolean remote) throws UnreachableServiceException { StorageService service; - service = remote ? getRemoteStorageService(context) : getLocalStorageService(context); - if (service == null) { - throw new UnreachableServiceException("could not find service " + (remote ? "remote" : "local")); - } + service = context.getStorageService(remote); return service; } - public static int getCount(SimExplorerContext context, boolean remote, String query, boolean onlyLatest) { + private static String loginUser(SimExplorerContext context, boolean remote, String login, String hashPassword) throws UnreachableServiceException { StorageService service = getService(context, remote); + try { + String token; + token = service.loginUser(login, hashPassword); + return token; + } catch (SimExplorerException e) { + throw new SimExplorerRuntimeException(e); + } + } + + private static int getCount(SimExplorerContext context, boolean remote, String query, boolean onlyLatest) { + StorageService service = getService(context, remote); String token = context.getToken(); int size; try { @@ -94,19 +83,8 @@ } } - public static String loginUser(SimExplorerContext context, boolean remote, String login, String hashPassword) throws UnreachableServiceException { + private static MetaData[] getData(SimExplorerContext context, boolean remote, boolean onlyLatest, String query, long newFirstIndex, int width, SortColumn column, boolean ascending) { StorageService service = getService(context, remote); - try { - String token; - token = service.loginUser(login, hashPassword); - return token; - } catch (SimExplorerException e) { - throw new SimExplorerRuntimeException(e); - } - } - - public static MetaData[] getData(SimExplorerContext context, boolean remote, boolean onlyLatest, String query, long newFirstIndex, int width, SortColumn column, boolean ascending) { - StorageService service = getService(context, remote); String token = context.getToken(); try { MetaData[] data; @@ -114,6 +92,7 @@ data = service.findElements(token, EntityTypeEnum.ExplorationApplication.toString(), onlyLatest, (int) newFirstIndex, width, column.name(), ascending); } else { data = service.findFullText(token, query, "", onlyLatest, (int) newFirstIndex, width, column.name(), ascending); + //data = service.findFullText(token, query, SearchColumn.AllFields.name(), onlyLatest, (int) newFirstIndex, width, column.name(), ascending); } return data; } catch (SimExplorerException e) { @@ -121,37 +100,44 @@ } } - - public static LoggableElement getElement(SimExplorerContext context, boolean remote, String uuid, String version) { + private static MetaData getMetaData(SimExplorerContext context, boolean remote, String uuid, String version) { try { - LoggableElement data; - data = getService(context, remote).getLoggableElement(context.getToken(), uuid, version); - return data; + MetaData metas; + metas = getService(context, remote).getMetadata(context.getToken(), uuid, version); + return metas; } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } - public static void deleteElement(SimExplorerContext context, boolean remote, String uuid, String version) { + /** + * @param context the application context + * @param remote flag tosay local or remote + * @param uuid uuid of LoggableElement required + * @param version version of LoggableElement required + * @return the LoggableElement from service + * @deprecated prefer use {@link LoggableElementCache} + */ + private static LoggableElement getElement(SimExplorerContext context, boolean remote, String uuid, String version) { try { - getService(context, remote).deleteElement(context.getToken(), uuid, version); + LoggableElement data; + data = getService(context, remote).getLoggableElement(context.getToken(), uuid, version); + return data; } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } - public static MetaData getMetaData(SimExplorerContext context, boolean remote, String uuid, String version) { + private static void deleteElement(SimExplorerContext context, boolean remote, String uuid, String version) { try { - MetaData metas; - metas = getService(context, remote).getMetadata(context.getToken(), uuid, version); - return metas; + getService(context, remote).deleteElement(context.getToken(), uuid, version); } catch (SimExplorerException e1) { throw new SimExplorerRuntimeException(e1); } } - public static BufferedInputStream retrieveElementFull(SimExplorerContext context, boolean remote, String uuid, String version) { + private static BufferedInputStream retrieveElementFull(SimExplorerContext context, boolean remote, String uuid, String version) { try { InputStream stream = getService(context, remote).retrieveElementFull(context.getToken(), uuid, version); BufferedInputStream bis; @@ -162,7 +148,7 @@ } } - public static BufferedInputStream retrieveElementData(SimExplorerContext context, boolean remote, String uuid, String version, Attachment attachment) { + private static BufferedInputStream retrieveElementData(SimExplorerContext context, boolean remote, String uuid, String version, Attachment attachment) { try { InputStream stream = getService(context, remote).retrieveElementData(context.getToken(), uuid, version, attachment); BufferedInputStream bis; @@ -173,7 +159,7 @@ } } - public static MetaData importElement(SimExplorerContext context, boolean remote, File file) { + private static MetaData importElement(SimExplorerContext context, boolean remote, File file) { try { SerializableInputStream zipStream; zipStream = new SerializableInputStream(new FileInputStream(file)); @@ -185,7 +171,7 @@ } } - public static Version[] getVersions(SimExplorerContext context, boolean remote, String uuid) { + private static Version[] getVersions(SimExplorerContext context, boolean remote, String uuid) { try { Version[] result; result = getService(context, remote).getVersions(context.getToken(), uuid); @@ -195,58 +181,6 @@ } } - /** - * @param context le context de l'application - * @return le service de storage locale - */ - protected static StorageService getLocalStorageService(SimExplorerContext context) { - if (storageService == null) { - if (mock) { - return storageService = new MockStorageServiceImpl(false); - } - try { - storageService = new StorageServiceClient(context.getConfig().getSource().toString(),"local."); - } catch (Exception e) { - throw new SimExplorerRuntimeException(e); - } - } - return storageService; - } - - /** - * @param context le context de l'application - * @return le service de storage distant - */ - protected static StorageService getRemoteStorageService(SimExplorerContext context) { - if (remoteStorageService == null) { - if (mock) { - return remoteStorageService = new MockStorageServiceImpl(true); - } - try { - Properties props = initProperties(context.getRemoteConfig().getURI()); - Context context2; - try { - context2 = new InitialContext(props); - } catch (Exception e) { - context2 = new InitialContext(); - } - remoteStorageService = (StorageService) context2.lookup(STORAGE_SERVICE_LOOKUP_NAME); - } catch (NamingException e) { - // no remote service available - remoteStorageService = null; - } - } - return remoteStorageService; - } - - protected static Properties initProperties(URI uri) { - Properties props = (Properties) System.getProperties().clone(); - props.put(PROVIDER_URL, uri.toString()); - props.put(FACTORY_INITIAL, "org.jnp.interfaces.NamingContextFactory"); - props.put(FACTORY_URL_PKGS, "org.jnp.interfaces"); - return props; - } - protected StorageServiceHelper() { // no instance } Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConnectAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -23,7 +23,6 @@ import fr.cemagref.simexplorer.is.exceptions.UnreachableServiceException; import fr.cemagref.simexplorer.is.service.AuthenticationServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.ui.LoginUI; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractAction; import fr.cemagref.simexplorer.is.ui.swing.model.tab.ListTabModel; import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerMainUI; @@ -132,7 +131,7 @@ boolean ok = false; while (true) { try { - StorageServiceHelper.getService(getContext(), true); + getContext().getStorageService(true); ok = true; break; } catch (UnreachableServiceException e) { @@ -163,10 +162,9 @@ * @return <code>true</code> si l'utilisateur est connecté */ protected boolean connect(String login, String password) { - String token; + + getContext().loginUser( true, login, password); - token = StorageServiceHelper.loginUser(getContext(), true, login, password); - getContext().setToken(token); boolean isConnected = getContext().isConnected(); if (isConnected) { // keep password Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DeleteElementAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -20,7 +20,6 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; import fr.cemagref.simexplorer.is.ui.swing.model.tab.SynchronizeTabModel; @@ -95,15 +94,17 @@ // effectue la suppression boolean remote = selected.isRemote(); String uuid = selected.getUuid(); - StorageServiceHelper.deleteElement(getContext(), remote, uuid, selected.getVersion().toString()); + getContext().getStorageService(remote).deleteElement(uuid, selected.getVersion().toString()); + //StorageServiceHelper.deleteElement(getContext(), remote, uuid, selected.getVersion().toString()); + getListModel(remote).reload(); if (SimExplorerTab.synchronize.isTabVisible(getTabContainer())) { SynchronizeTabModel model = getSynchronizeModel(); - model.reloadSources(uuid, !remote,remote,!remote,remote); + model.reloadSources(uuid, !remote, remote, !remote, remote); } // suppression de l'élément de l'historique (si present) Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -51,6 +51,11 @@ super(name); } + @Override + protected void setStatus(String status) { + // no log + } + @Override protected boolean beforeAction(ActionEvent e) throws Exception { if (!super.beforeAction(e)) { Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadAttachmentAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -19,7 +19,7 @@ package fr.cemagref.simexplorer.is.ui.swing.actions; import fr.cemagref.simexplorer.is.entities.attachment.Attachment; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.ui.swing.actions.util.DownloadAbstractAction; import fr.cemagref.simexplorer.is.ui.swing.model.tab.DetailTabModel; import static org.codelutin.i18n.I18n._; @@ -27,6 +27,7 @@ import java.io.BufferedInputStream; import java.io.File; +import java.io.InputStream; /** * Action pour downloader un fichier attachéà un LoggableElement @@ -78,10 +79,11 @@ return file; } - protected BufferedInputStream getInputStream() { - BufferedInputStream bis; - bis = StorageServiceHelper.retrieveElementData(getContext(), selected.isRemote(), selected.getUuid(), selected.getVersion().toString(), attachment); - return bis; + protected BufferedInputStream getInputStream() throws SimExplorerException { + InputStream bis; + bis = getContext().getStorageService(selected.isRemote()).retrieveElementData(getContext().getToken(), selected.getUuid(), selected.getVersion().toString(), attachment); + //bis = StorageServiceHelper.retrieveElementData(getContext(), selected.isRemote(), selected.getUuid(), selected.getVersion().toString(), attachment); + return new BufferedInputStream(bis); } @Override Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DownloadElementAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -18,13 +18,14 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.swing.actions; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.actions.util.DownloadAbstractAction; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import static org.codelutin.i18n.I18n._; import org.codelutin.util.FileUtil; import java.io.BufferedInputStream; import java.io.File; +import java.io.InputStream; import java.text.MessageFormat; /** @@ -65,10 +66,11 @@ return file; } - protected BufferedInputStream getInputStream() { - BufferedInputStream bis; - bis = StorageServiceHelper.retrieveElementFull(getContext(), selected.isRemote(), selected.getUuid(), selected.getVersion().toString()); - return bis; + protected BufferedInputStream getInputStream() throws SimExplorerException { + InputStream bis; + bis= getContext().getStorageService(selected.isRemote()).retrieveElementFull(getContext().getToken(), selected.getUuid(), selected.getVersion().toString()); + //bis = StorageServiceHelper.retrieveElementFull(getContext(), selected.isRemote(), selected.getUuid(), selected.getVersion().toString()); + return new BufferedInputStream(bis); } } \ No newline at end of file Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ExportElementAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -22,7 +22,6 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.service.StorageService; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; import fr.cemagref.simexplorer.is.ui.swing.model.tab.DetailTabModel; @@ -142,8 +141,8 @@ protected void doAction(ActionEvent e) throws Exception { boolean remote = selected.isRemote(); - StorageService fromService = StorageServiceHelper.getService(getContext(), remote); - StorageService toService = StorageServiceHelper.getService(getContext(), !remote); + StorageService fromService = getContext().getStorageService(remote); + StorageService toService = getContext().getStorageService(!remote); log.info("fromService : " + fromService); log.info("toService : " + toService); Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ImportElementAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -20,21 +20,24 @@ import fr.cemagref.simexplorer.is.ui.swing.ui.ImportDialog; import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; import fr.cemagref.simexplorer.is.ui.swing.model.tab.ListTabModel; import fr.cemagref.simexplorer.is.ui.swing.model.tab.SynchronizeTabModel; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; import static org.codelutin.i18n.I18n._; import static org.codelutin.i18n.I18n.n_; import java.awt.event.ActionEvent; import java.io.File; +import java.io.FileInputStream; import java.util.Map; import java.util.TreeMap; +import com.healthmarketscience.rmiio.SerializableInputStream; + /** * Action de base pour importer une application * @@ -85,7 +88,7 @@ @Override protected void doAction(ActionEvent e) throws Exception { - MetaData result = StorageServiceHelper.importElement(getContext(), remote, f); + MetaData result = importElement(remote, f); DataEntityModel selected = new DataEntityModel(); selected.synch(remote,result); @@ -137,4 +140,16 @@ ui.getTypeImport().updateSelectedValue(); return ui; } + + public MetaData importElement(boolean remote, File file) { + try { + SerializableInputStream zipStream; + zipStream = new SerializableInputStream(new FileInputStream(file)); + MetaData result; + result = getContext().getStorageService(remote).saveElement(getContext().getToken(), zipStream); + return result; + } catch (Exception e) { + throw new SimExplorerRuntimeException(e); + } + } } \ No newline at end of file Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ShowDetailTabAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -21,12 +21,11 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerActionManager; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.actions.util.SelectedAction; import fr.cemagref.simexplorer.is.ui.swing.actions.util.ShowTabAbstractAction; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; -import fr.cemagref.simexplorer.is.ui.swing.model.tab.DetailTabModel; import fr.cemagref.simexplorer.is.ui.swing.model.EntityTreeNode; +import fr.cemagref.simexplorer.is.ui.swing.model.tab.DetailTabModel; import fr.cemagref.simexplorer.is.ui.swing.ui.EntityTreeNodeHelper; import fr.cemagref.simexplorer.is.ui.swing.ui.JDetailTab; import fr.cemagref.simexplorer.is.ui.swing.ui.SimExplorerTab; @@ -45,7 +44,7 @@ /** * Action pour afficher le tab de détail d'un LoggableElement. - * + * * @author chemit */ @jaxx.runtime.builder.ActionConfig( @@ -212,7 +211,7 @@ if (node.isLoggableElement()) { Version[] versions; - versions = StorageServiceHelper.getVersions(getContext(), node.isRemote(), element.getMetaData().getUuid()); + versions = getContext().getVersions(node.isRemote(), element.getMetaData().getUuid()); model.setVersions(versions); } } @@ -237,9 +236,9 @@ DetailTabModel model = getTabModel(); Version selectedVersion = Version.valueOf(selectedItem.toString()); - //if (log.isDebugEnabled()) { - log.info("selected version (" + selectedVersion + ") " + selectedItem); - //} + if (log.isDebugEnabled()) { + log.debug("selected version (" + selectedVersion + ") " + selectedItem); + } DataEntityModel item = model.getSelectedItem().cloneSafe(); @@ -250,7 +249,6 @@ LoggableElement element = item.getLe(getContext()); - log.info("----- new detaul " + element); model.setDetailNode(element); model.setSelectedVersion(selectedVersion); Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/history/HistoryAbstractAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -54,6 +54,11 @@ super(name); } + @Override + protected void setStatus(String status) { + // no log + } + @Override protected boolean beforeAction(ActionEvent e) throws Exception { if (!super.beforeAction(e)) { Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/DownloadAbstractAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/DownloadAbstractAction.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/DownloadAbstractAction.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -19,6 +19,7 @@ package fr.cemagref.simexplorer.is.ui.swing.actions.util; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import java.awt.event.ActionEvent; import java.io.BufferedInputStream; @@ -47,7 +48,7 @@ protected abstract File getFile(); - protected abstract BufferedInputStream getInputStream(); + protected abstract BufferedInputStream getInputStream() throws SimExplorerException; @Override protected boolean beforeAction(ActionEvent e) throws Exception { Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DataEntityModel.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -24,11 +24,14 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; /** - * Le model d'un meta sélectionné dans un onglet + * Le modele qui encapsule un DataEntity. * + * Le chargement des données est intelligent, . + * + * TODO mettre en place un cache pour optimiser les acces aux bases. + * * @author chemit * @see DataEntity */ @@ -46,15 +49,15 @@ /** le type de l'entity encapsulée */ protected transient EntityTypeEnum type; + /** l'objet selectionne ou son le */ + protected transient LoggableElement le; + /** l'objet selectionne */ protected transient DataEntity data; /** les meta du le selectionne */ protected transient MetaData meta; - /** l'objet selectionne ou son le */ - protected transient LoggableElement le; - private static final long serialVersionUID = -6047191988584875688L; public boolean isRemote() { @@ -88,8 +91,10 @@ resetData(); // acquire it - le = StorageServiceHelper.getElement(context, isRemote(), uuid, version.toString()); + le = context.getLoggableElement(isRemote(), uuid, version); + //le = StorageServiceHelper.getElement(context, isRemote(), uuid, version.toString()); + if (le != null) { meta = le.getMetaData(); } @@ -105,16 +110,7 @@ * @return the object selected */ public DataEntity get(SimExplorerContext context) { - if (uuid == null || version == null || remote == null) { - return null; - } - if (data != null) { - return data; - } - // always reset thoses values, before recomputing them - resetData(); - // acquire loggableElement le = getLe(context); @@ -159,6 +155,7 @@ } else { synch(remote, le.getMetaData()); } + // set the le setLe(le); } @@ -167,9 +164,10 @@ synch(remote, null, null); } else { synch(remote, data.getUuid(), data.getVersion()); - EntityTypeEnum entityTypeEnum = data.getEntityType(); - setType(entityTypeEnum); + // set the type + setType(data.getEntityType()); } + // set meta setMeta(data); } Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementCache.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementCache.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/LoggableElementCache.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -0,0 +1,116 @@ +/* +* \#\#% Copyright (C) 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.swing.model; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; +import fr.cemagref.simexplorer.is.service.StorageService; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * Un cache de LoggableElement. + * + * @author chemit + */ +public class LoggableElementCache { + + //private static final int CAPACITY = 200; + + protected Map<String, List<LoggableElement>> cache; + + protected StorageService service; + + protected SimExplorerContext context; + + public LoggableElementCache(SimExplorerContext context, StorageService service) { + if (service==null) { + throw new NullPointerException("could not have a null service"); + } + if (context==null) { + throw new NullPointerException("could not have a null context"); + } + this.service = service; + this.context = context; + } + + public LoggableElement get(String uuid, Version version) { + + List<LoggableElement> list = null; + LoggableElement result = null; + + if (containsKey(uuid)) { + list = getCache().get(uuid); + for (LoggableElement entity : list) { + if (entity.getMetaData().getVersion().equals(version)) { + result = entity; + break; + } + } + } + if (result == null) { + // try to find it from service + try { + result = service.getLoggableElement(context.getToken(), uuid, version.toString()); + if (result != null) { + // save in cache + if (list == null) { + list = new ArrayList<LoggableElement>(); + } + list.add(result); + getCache().put(uuid, list); + } + } catch (SimExplorerException e) { + //TODO + throw new SimExplorerRuntimeException(e); + } + } + return result; + } + + public boolean isEmpty() { + return cache == null || cache.isEmpty(); + } + + public int size() { + return isEmpty() ? 0 : cache.size(); + } + + public boolean containsKey(String o) { + return cache != null && cache.containsKey(o); + } + + public void clear() { + if (cache != null) { + cache.clear(); + } + } + + protected Map<String, List<LoggableElement>> getCache() { + if (cache == null) { + cache = new TreeMap<String, List<LoggableElement>>(); + } + return cache; + } +} Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/ListTabModel.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/ListTabModel.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/ListTabModel.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -240,7 +240,7 @@ if (generatePagination) { // get size list - page.size = StorageServiceHelper.getCount(context, isRemote(), query.getQuery(), query.isOnlyLatest()); + page.size = context.getCount( isRemote(), query.getQuery(), query.isOnlyLatest()); //TODO should be at -1 page.pageNumber = 0; @@ -249,8 +249,7 @@ // init query model // obtain datas from service - MetaData[] data = StorageServiceHelper.getData( - context, + MetaData[] data = context.getData( isRemote(), query.isOnlyLatest(), query.getQuery(), Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/SynchronizeTabModel.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/SynchronizeTabModel.java 2008-02-26 00:33:13 UTC (rev 1242) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/tab/SynchronizeTabModel.java 2008-02-26 00:35:04 UTC (rev 1243) @@ -21,7 +21,6 @@ import fr.cemagref.simexplorer.is.entities.data.LoggableElement; import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerContext; -import fr.cemagref.simexplorer.is.ui.swing.StorageServiceHelper; import fr.cemagref.simexplorer.is.ui.swing.model.DataEntityModel; /** @@ -152,14 +151,14 @@ public void reloadSources(String uuid, boolean deleteLocal, boolean deleteRemote, boolean treateLocal, boolean treateRemote) { LoggableElement[] result = new LoggableElement[2]; - result[0] =loadSource(context, uuid, deleteLocal, treateLocal, false); - result[1] =loadSource(context, uuid, deleteRemote, treateRemote,true); + result[0] = loadSource(context, uuid, deleteLocal, treateLocal, false); + result[1] = loadSource(context, uuid, deleteRemote, treateRemote, true); setSources(result); } private LoggableElement loadSource(SimExplorerContext context, String uuid, boolean deleteRemote, boolean treateRemote, boolean remote) { - LoggableElement result=null; + LoggableElement result = null; LoggableElement node = getRootNode(remote); if (node != null && !node.getMetaData().getUuid().equals(uuid)) { // nothing tobe done @@ -193,7 +192,7 @@ protected Version getVersion(SimExplorerContext context, boolean remote, String uuid) { // recuperation des versions de l'element destination - Version[] versions = StorageServiceHelper.getVersions(context, remote, uuid); + Version[] versions = context.getVersions(remote, uuid); Version requiredVersion = null; if (versions.length != 0) { // on prend la dernière version disponible dans la base (i.e