r1261 - trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages
Author: glandais Date: 2008-02-29 16:44:06 +0000 (Fri, 29 Feb 2008) New Revision: 1261 Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java Log: Update to use StorageServiceGenerator Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java 2008-02-29 16:43:35 UTC (rev 1260) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Install.java 2008-02-29 16:44:06 UTC (rev 1261) @@ -1,42 +1,27 @@ /* -* ##% Copyright (C) 2008 Code Lutin, 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. -* ##% */ + * ##% Copyright (C) 2008 Code Lutin, 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.web.pages; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - import org.apache.tapestry.annotations.InjectPage; -import com.healthmarketscience.rmiio.SerializableInputStream; - -import fr.cemagref.simexplorer.is.entities.attachment.Attachment; -import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication; -import fr.cemagref.simexplorer.is.entities.data.LoggableElement; -import fr.cemagref.simexplorer.is.entities.metadata.Version; -import fr.cemagref.simexplorer.is.factories.LoggableElementFactory; -import fr.cemagref.simexplorer.is.storage.ElementGenerator; -import fr.cemagref.simexplorer.is.storage.ElementGenerator.RandomStream; -import fr.cemagref.simexplorer.is.ui.web.pages.security.SuperAdminPage; +import fr.cemagref.simexplorer.is.service.StorageServiceGenerator; import fr.cemagref.simexplorer.is.service.remote.RemoteStorageService; +import fr.cemagref.simexplorer.is.ui.web.pages.security.SuperAdminPage; /** * The Class Install. @@ -47,7 +32,9 @@ @InjectPage private ElementList elementList; - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see fr.cemagref.simexplorer.is.ui.web.pages.security.ProtectedPage#getWindowTitle() */ @Override @@ -62,51 +49,9 @@ * @throws Exception */ public Object onActionFromGenerateData() throws Exception { - - ElementGenerator elementGenerator = new ElementGenerator(); - Random r = new Random(); - - int c = 20; - - for (int i = 0; i < c; i++) { - ExplorationApplication parentEa; - parentEa = elementGenerator.generateRandomEA(); - - int v = 2 + r.nextInt(5); - Version version = new Version(parentEa.getMetaData().getVersion().toString()); - - for (int j = 0; j < v; j++) { - ExplorationApplication ea = elementGenerator.generateRandomEA(); - ea.getMetaData().setUuid(parentEa.getMetaData().getUuid()); - - version = version.incVersion(r.nextInt(3)); - ea.getMetaData().setVersion(version.toString()); - - Map<Attachment, SerializableInputStream> attachments = new HashMap<Attachment, SerializableInputStream>(); - - List<Attachment> attachmentsKeys = new ArrayList<Attachment>(); - - attachmentsKeys.addAll(ea.getAttachments()); - List<LoggableElement> children = ea.getChildren(); - for (LoggableElement child : children) { - attachmentsKeys.addAll(child.getAttachments()); - } - - for (Attachment attachment : attachmentsKeys) { - RandomStream randomStream = elementGenerator.generateTextStream(); - attachment.setDataHash(randomStream.getMd5()); - SerializableInputStream remoteStream = new SerializableInputStream(randomStream.getStream()); - attachments.put(attachment, remoteStream); - } - - InputStream xmlStream = LoggableElementFactory.getStream(ea); - - SerializableInputStream xmlRemoteStream = new SerializableInputStream(xmlStream); - RemoteStorageService.getStorageService().saveElement(getToken(), xmlRemoteStream, attachments); - } - - } - + StorageServiceGenerator storageServiceGenerator = new StorageServiceGenerator(); + storageServiceGenerator.generateLotsExplorationApplication(RemoteStorageService.getStorageService(), + getToken(), 20); return elementList; }
participants (1)
-
glandais@users.labs.libre-entreprise.org