extensions/net.sf.basedb.examples/trunk/src/net/sf/basedb/examples/plugins/ExampleImporter.java

Code
Comments
Other
Rev Date Author Line
647 11 Apr 08 nicklas 1 /*
1391 15 Sep 11 nicklas 2   Copyright (C) 2006, 2007, 2011 Nicklas Nordborg
647 11 Apr 08 nicklas 3
1391 15 Sep 11 nicklas 4   This file is part of the Example Code Package for BASE.
1391 15 Sep 11 nicklas 5   Available at http://baseplugins.thep.lu.se/
1391 15 Sep 11 nicklas 6   BASE main site: http://base.thep.lu.se/
1391 15 Sep 11 nicklas 7   
1391 15 Sep 11 nicklas 8   This is free software; you can redistribute it and/or
647 11 Apr 08 nicklas 9   modify it under the terms of the GNU General Public License
1391 15 Sep 11 nicklas 10   as published by the Free Software Foundation; either version 3
647 11 Apr 08 nicklas 11   of the License, or (at your option) any later version.
1391 15 Sep 11 nicklas 12   
1391 15 Sep 11 nicklas 13   The software is distributed in the hope that it will be useful,
647 11 Apr 08 nicklas 14   but WITHOUT ANY WARRANTY; without even the implied warranty of
647 11 Apr 08 nicklas 15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
647 11 Apr 08 nicklas 16   GNU General Public License for more details.
1391 15 Sep 11 nicklas 17   
647 11 Apr 08 nicklas 18   You should have received a copy of the GNU General Public License
1391 15 Sep 11 nicklas 19   along with BASE. If not, see <http://www.gnu.org/licenses/>.
647 11 Apr 08 nicklas 20 */
1347 18 Apr 11 nicklas 21 package net.sf.basedb.examples.plugins;
647 11 Apr 08 nicklas 22
647 11 Apr 08 nicklas 23 import net.sf.basedb.core.BooleanParameterType;
647 11 Apr 08 nicklas 24 import net.sf.basedb.core.BaseException;
647 11 Apr 08 nicklas 25 import net.sf.basedb.core.DbControl;
647 11 Apr 08 nicklas 26 import net.sf.basedb.core.Item;
647 11 Apr 08 nicklas 27 import net.sf.basedb.core.Job;
647 11 Apr 08 nicklas 28 import net.sf.basedb.core.File;
647 11 Apr 08 nicklas 29 import net.sf.basedb.core.FileParameterType;
647 11 Apr 08 nicklas 30 import net.sf.basedb.core.PluginParameter;
647 11 Apr 08 nicklas 31 import net.sf.basedb.core.ProgressReporter;
647 11 Apr 08 nicklas 32 import net.sf.basedb.core.RequestInformation;
647 11 Apr 08 nicklas 33
647 11 Apr 08 nicklas 34 import net.sf.basedb.core.plugin.About;
647 11 Apr 08 nicklas 35 import net.sf.basedb.core.plugin.AboutImpl;
647 11 Apr 08 nicklas 36 import net.sf.basedb.core.plugin.AbstractPlugin;
647 11 Apr 08 nicklas 37 import net.sf.basedb.core.plugin.AutoDetectingImporter;
647 11 Apr 08 nicklas 38 import net.sf.basedb.core.plugin.InteractivePlugin;
647 11 Apr 08 nicklas 39 import net.sf.basedb.core.plugin.GuiContext;
647 11 Apr 08 nicklas 40 import net.sf.basedb.core.plugin.Plugin;
647 11 Apr 08 nicklas 41 import net.sf.basedb.core.plugin.Request;
647 11 Apr 08 nicklas 42 import net.sf.basedb.core.plugin.Response;
647 11 Apr 08 nicklas 43 import net.sf.basedb.core.signal.SignalHandler;
647 11 Apr 08 nicklas 44 import net.sf.basedb.core.signal.SignalTarget;
647 11 Apr 08 nicklas 45 import net.sf.basedb.core.signal.ThreadSignalHandler;
647 11 Apr 08 nicklas 46
647 11 Apr 08 nicklas 47 import java.io.InputStream;
647 11 Apr 08 nicklas 48 import java.util.ArrayList;
647 11 Apr 08 nicklas 49 import java.util.Arrays;
647 11 Apr 08 nicklas 50 import java.util.Collections;
647 11 Apr 08 nicklas 51 import java.util.List;
647 11 Apr 08 nicklas 52 import java.util.Set;
647 11 Apr 08 nicklas 53
647 11 Apr 08 nicklas 54
647 11 Apr 08 nicklas 55 /**
647 11 Apr 08 nicklas 56   An example plugin that pretends to import samples. It can't be configured,
647 11 Apr 08 nicklas 57   but will ask for a file to import from and if existing samples should be updated 
647 11 Apr 08 nicklas 58   or not. It won't actually import any samples, but will report that a few samples
647 11 Apr 08 nicklas 59   has been imported.
647 11 Apr 08 nicklas 60   
647 11 Apr 08 nicklas 61   @base.modified $Date$
647 11 Apr 08 nicklas 62   @author Nicklas
647 11 Apr 08 nicklas 63   @version 2.0
647 11 Apr 08 nicklas 64 */
647 11 Apr 08 nicklas 65 public class ExampleImporter 
647 11 Apr 08 nicklas 66   extends AbstractPlugin
647 11 Apr 08 nicklas 67   implements InteractivePlugin, AutoDetectingImporter, SignalTarget
647 11 Apr 08 nicklas 68 {
647 11 Apr 08 nicklas 69
647 11 Apr 08 nicklas 70   private static final About about = 
647 11 Apr 08 nicklas 71     new AboutImpl
647 11 Apr 08 nicklas 72     (
647 11 Apr 08 nicklas 73       "Example importer",
647 11 Apr 08 nicklas 74       "An example plugin that pretends to import samples. It can't be configured, " +
647 11 Apr 08 nicklas 75       "but will ask for a file to import from and if existing samples should be updated " +
647 11 Apr 08 nicklas 76       "or not. It won't actually import any samples, but will report that a few samples " +
647 11 Apr 08 nicklas 77       "has been imported.",
1292 24 Feb 11 nicklas 78       "2.17",
647 11 Apr 08 nicklas 79       "2006, Base 2 development team",
647 11 Apr 08 nicklas 80       null,
647 11 Apr 08 nicklas 81       null,
647 11 Apr 08 nicklas 82       "http://base.thep.lu.se"
647 11 Apr 08 nicklas 83     );
647 11 Apr 08 nicklas 84
647 11 Apr 08 nicklas 85   private static final Set<GuiContext> guiContexts = Collections.singleton(
647 11 Apr 08 nicklas 86     new GuiContext(Item.SAMPLE, GuiContext.Type.LIST)
647 11 Apr 08 nicklas 87   );
1351 28 Apr 11 nicklas 88
1351 28 Apr 11 nicklas 89   // Plugin configuration is created by getConfigurePlugin()
1351 28 Apr 11 nicklas 90   private RequestInformation configurePlugin;
1351 28 Apr 11 nicklas 91
647 11 Apr 08 nicklas 92   // Job configuration is created by getConfigureJob()
647 11 Apr 08 nicklas 93   private RequestInformation configureJob;
647 11 Apr 08 nicklas 94   
647 11 Apr 08 nicklas 95   // Parameter that asks for the file to import from
647 11 Apr 08 nicklas 96   private PluginParameter<File> fileParameter;
647 11 Apr 08 nicklas 97   
647 11 Apr 08 nicklas 98   // Parameter that asks if existing items should be updated or not
647 11 Apr 08 nicklas 99   private PluginParameter<Boolean> updateExistingParameter;
647 11 Apr 08 nicklas 100   
647 11 Apr 08 nicklas 101   // 
647 11 Apr 08 nicklas 102   private DbControl dc;
647 11 Apr 08 nicklas 103   
647 11 Apr 08 nicklas 104   // So we can react to ABORT requests
647 11 Apr 08 nicklas 105   private ThreadSignalHandler signalHandler;
647 11 Apr 08 nicklas 106   
647 11 Apr 08 nicklas 107   /**
647 11 Apr 08 nicklas 108     Create a new example importer.
647 11 Apr 08 nicklas 109   */
647 11 Apr 08 nicklas 110   public ExampleImporter()
647 11 Apr 08 nicklas 111   {}
647 11 Apr 08 nicklas 112   
647 11 Apr 08 nicklas 113   /*
647 11 Apr 08 nicklas 114     From the Plugin interface
647 11 Apr 08 nicklas 115     -------------------------------------------
647 11 Apr 08 nicklas 116   */
1292 24 Feb 11 nicklas 117   @Override
647 11 Apr 08 nicklas 118   public Plugin.MainType getMainType()
647 11 Apr 08 nicklas 119   {
647 11 Apr 08 nicklas 120     return Plugin.MainType.IMPORT;
647 11 Apr 08 nicklas 121   }
1292 24 Feb 11 nicklas 122   @Override
647 11 Apr 08 nicklas 123   public boolean supportsConfigurations()
647 11 Apr 08 nicklas 124   {
1351 28 Apr 11 nicklas 125     return true;
647 11 Apr 08 nicklas 126   }
1292 24 Feb 11 nicklas 127   @Override
647 11 Apr 08 nicklas 128   public boolean requiresConfiguration()
647 11 Apr 08 nicklas 129   {
647 11 Apr 08 nicklas 130     return false;
647 11 Apr 08 nicklas 131   }
1292 24 Feb 11 nicklas 132   @Override
647 11 Apr 08 nicklas 133   public void run(Request request, Response response, ProgressReporter progress)
647 11 Apr 08 nicklas 134   {
647 11 Apr 08 nicklas 135     // Ensure that the ABORT signal gets sent to this thread
647 11 Apr 08 nicklas 136     if (signalHandler != null) signalHandler.setWorkerThread(null);
647 11 Apr 08 nicklas 137     
647 11 Apr 08 nicklas 138     // Open a connection to the database
647 11 Apr 08 nicklas 139     // sc is set by init() method
647 11 Apr 08 nicklas 140     DbControl dc = sc.newDbControl();
647 11 Apr 08 nicklas 141     try
647 11 Apr 08 nicklas 142     {
647 11 Apr 08 nicklas 143       // Get the parameters from the job configuration
647 11 Apr 08 nicklas 144       boolean updateExisting = (Boolean)job.getValue("updateExisting");
647 11 Apr 08 nicklas 145       File f = (File)job.getValue("file");
647 11 Apr 08 nicklas 146       
647 11 Apr 08 nicklas 147       // Open the file an import it
647 11 Apr 08 nicklas 148       f = File.getById(dc, f.getId());
647 11 Apr 08 nicklas 149       InputStream in = f.getDownloadStream(0);
647 11 Apr 08 nicklas 150       doImport(in, progress);
647 11 Apr 08 nicklas 151       in.close();
647 11 Apr 08 nicklas 152       
647 11 Apr 08 nicklas 153       // Commit the work
647 11 Apr 08 nicklas 154       dc.commit();
647 11 Apr 08 nicklas 155       response.setDone("Plugin ended successfully");
647 11 Apr 08 nicklas 156     }
647 11 Apr 08 nicklas 157     catch (Throwable t)
647 11 Apr 08 nicklas 158     {
647 11 Apr 08 nicklas 159       // All exceptions must be catched and sent back 
647 11 Apr 08 nicklas 160       // using the response object
647 11 Apr 08 nicklas 161       response.setError(t.getMessage(), Arrays.asList(t));
647 11 Apr 08 nicklas 162     }
647 11 Apr 08 nicklas 163     finally
647 11 Apr 08 nicklas 164     {
647 11 Apr 08 nicklas 165       // IMPORTANT!!! Make sure opened connections are closed
647 11 Apr 08 nicklas 166       if (dc != null) dc.close();
647 11 Apr 08 nicklas 167     }
647 11 Apr 08 nicklas 168   }
647 11 Apr 08 nicklas 169   // -------------------------------------------
647 11 Apr 08 nicklas 170   
647 11 Apr 08 nicklas 171   /*
647 11 Apr 08 nicklas 172     From the InteractivePlugin interface
647 11 Apr 08 nicklas 173     -------------------------------------------
647 11 Apr 08 nicklas 174   */
647 11 Apr 08 nicklas 175   /**
647 11 Apr 08 nicklas 176     Return a set containing the context [SAMPLE, LIST].
647 11 Apr 08 nicklas 177   */
1292 24 Feb 11 nicklas 178   @Override
647 11 Apr 08 nicklas 179   public Set<GuiContext> getGuiContexts()
647 11 Apr 08 nicklas 180   {
647 11 Apr 08 nicklas 181     return guiContexts;
647 11 Apr 08 nicklas 182   }
647 11 Apr 08 nicklas 183   /**
647 11 Apr 08 nicklas 184     Always null, we are not dealing with individual items.
647 11 Apr 08 nicklas 185   */
1292 24 Feb 11 nicklas 186   @Override
647 11 Apr 08 nicklas 187   public String isInContext(GuiContext context, Object item)
647 11 Apr 08 nicklas 188   {
647 11 Apr 08 nicklas 189     return null;
647 11 Apr 08 nicklas 190   }
647 11 Apr 08 nicklas 191   /**
647 11 Apr 08 nicklas 192     The {@link Request#COMMAND_CONFIGURE_PLUGIN} command will not ask
647 11 Apr 08 nicklas 193     for any parameters.
647 11 Apr 08 nicklas 194     <p>
647 11 Apr 08 nicklas 195     The {@link Request#COMMAND_CONFIGURE_JOB} command will ask for
647 11 Apr 08 nicklas 196     a file and if existing samples should be updated or ignored.
647 11 Apr 08 nicklas 197   */
1292 24 Feb 11 nicklas 198   @Override
647 11 Apr 08 nicklas 199   public RequestInformation getRequestInformation(GuiContext context, String command)
647 11 Apr 08 nicklas 200     throws BaseException
647 11 Apr 08 nicklas 201   {
647 11 Apr 08 nicklas 202     RequestInformation requestInformation = null;
1351 28 Apr 11 nicklas 203     if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
647 11 Apr 08 nicklas 204     {
1351 28 Apr 11 nicklas 205       requestInformation = getConfigurePlugin();
1351 28 Apr 11 nicklas 206     }
1351 28 Apr 11 nicklas 207     else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
1351 28 Apr 11 nicklas 208     {
647 11 Apr 08 nicklas 209       requestInformation = getConfigureJob(context);
647 11 Apr 08 nicklas 210     }
647 11 Apr 08 nicklas 211     return requestInformation;
647 11 Apr 08 nicklas 212   }
647 11 Apr 08 nicklas 213   /**
647 11 Apr 08 nicklas 214     Store configuration settings for {@link Request#COMMAND_CONFIGURE_PLUGIN} and
647 11 Apr 08 nicklas 215     {@link Request#COMMAND_CONFIGURE_JOB}.
647 11 Apr 08 nicklas 216   */
1292 24 Feb 11 nicklas 217   @Override
647 11 Apr 08 nicklas 218   public void configure(GuiContext context, Request request, Response response)
647 11 Apr 08 nicklas 219   {
647 11 Apr 08 nicklas 220     String command = request.getCommand();
647 11 Apr 08 nicklas 221     try
647 11 Apr 08 nicklas 222     {
1351 28 Apr 11 nicklas 223       if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
647 11 Apr 08 nicklas 224       {
647 11 Apr 08 nicklas 225         List<Throwable> errors = 
1351 28 Apr 11 nicklas 226           validateRequestParameters(getConfigurePlugin().getParameters(), request);
1351 28 Apr 11 nicklas 227         if (errors != null)
1351 28 Apr 11 nicklas 228         {
1351 28 Apr 11 nicklas 229           response.setError(errors.size()+" invalid parameter(s) were found in the request", errors);
1351 28 Apr 11 nicklas 230           return;
1351 28 Apr 11 nicklas 231         }
1351 28 Apr 11 nicklas 232
1351 28 Apr 11 nicklas 233         storeValue(configuration, request, updateExistingParameter);
1351 28 Apr 11 nicklas 234         response.setDone("Configuration completed");
1351 28 Apr 11 nicklas 235       }
1351 28 Apr 11 nicklas 236       else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
1351 28 Apr 11 nicklas 237       {
1351 28 Apr 11 nicklas 238         List<Throwable> errors = 
647 11 Apr 08 nicklas 239           validateRequestParameters(getConfigureJob(context).getParameters(), request);
647 11 Apr 08 nicklas 240         if (errors != null)
647 11 Apr 08 nicklas 241         {
647 11 Apr 08 nicklas 242           response.setError(errors.size()+" invalid parameter(s) were found in the request", errors);
647 11 Apr 08 nicklas 243           return;
647 11 Apr 08 nicklas 244         }
647 11 Apr 08 nicklas 245
647 11 Apr 08 nicklas 246         storeValue(job, request, fileParameter);
647 11 Apr 08 nicklas 247         storeValue(job, request, updateExistingParameter);
1292 24 Feb 11 nicklas 248         File importFile = (File)job.getValue(fileParameter.getName());
1292 24 Feb 11 nicklas 249         response.setSuggestedJobName("Import samples from '" + importFile.getName() + "'");
647 11 Apr 08 nicklas 250         response.setDone("Job configuration complete", Job.ExecutionTime.SHORT);
647 11 Apr 08 nicklas 251         // TODO - maybe check file size to make a better estimate
647 11 Apr 08 nicklas 252       }
647 11 Apr 08 nicklas 253     }
647 11 Apr 08 nicklas 254     catch (Throwable ex)
647 11 Apr 08 nicklas 255     {
647 11 Apr 08 nicklas 256       response.setError(ex.getMessage(), Arrays.asList(ex));
647 11 Apr 08 nicklas 257     }
647 11 Apr 08 nicklas 258   }
647 11 Apr 08 nicklas 259   // -------------------------------------------
647 11 Apr 08 nicklas 260
647 11 Apr 08 nicklas 261
647 11 Apr 08 nicklas 262   /*
647 11 Apr 08 nicklas 263     From the AutoDetectingImporter interface
647 11 Apr 08 nicklas 264     -------------------------------------------
647 11 Apr 08 nicklas 265   */
647 11 Apr 08 nicklas 266   /**
647 11 Apr 08 nicklas 267     Always true, since we accept all files.
647 11 Apr 08 nicklas 268   */
1292 24 Feb 11 nicklas 269   @Override
647 11 Apr 08 nicklas 270   public boolean isImportable(InputStream in) 
647 11 Apr 08 nicklas 271     throws BaseException
647 11 Apr 08 nicklas 272   {
647 11 Apr 08 nicklas 273     return true;
647 11 Apr 08 nicklas 274   }
647 11 Apr 08 nicklas 275   /**
647 11 Apr 08 nicklas 276     We don't do anything in this method.
647 11 Apr 08 nicklas 277   */
1292 24 Feb 11 nicklas 278   @Override
647 11 Apr 08 nicklas 279   public void doImport(InputStream in, ProgressReporter progress) 
647 11 Apr 08 nicklas 280     throws BaseException
647 11 Apr 08 nicklas 281   {
647 11 Apr 08 nicklas 282     // Check if the ABORT signal has been sent
1292 24 Feb 11 nicklas 283     ThreadSignalHandler.checkInterrupted();
647 11 Apr 08 nicklas 284     /*
647 11 Apr 08 nicklas 285       Pseudo code:
647 11 Apr 08 nicklas 286       Parse input stream, for each found sample:
1292 24 Feb 11 nicklas 287       ThreadSignalHandler.checkInterrupted();  // Do this as the first thing in a loop
647 11 Apr 08 nicklas 288       String name = ...
647 11 Apr 08 nicklas 289       String externalId = ...
647 11 Apr 08 nicklas 290       boolean isNew = false;
647 11 Apr 08 nicklas 291       Sample s = getByExternalId(externalId);
647 11 Apr 08 nicklas 292       if (s == null)
647 11 Apr 08 nicklas 293       {
647 11 Apr 08 nicklas 294         s = Sample.getNew(dc);
1292 24 Feb 11 nicklas 295         s.setName(name) // and other properites
647 11 Apr 08 nicklas 296         dc.saveItem(s);
647 11 Apr 08 nicklas 297         isNew = true;
647 11 Apr 08 nicklas 298       }
647 11 Apr 08 nicklas 299       if (updateExisting || isNew)
647 11 Apr 08 nicklas 300       {
647 11 Apr 08 nicklas 301         s.setName(name);
647 11 Apr 08 nicklas 302         s.setExternalId(externalId);
647 11 Apr 08 nicklas 303         ...
647 11 Apr 08 nicklas 304       }
647 11 Apr 08 nicklas 305     */
647 11 Apr 08 nicklas 306   }
647 11 Apr 08 nicklas 307   // -------------------------------------------
647 11 Apr 08 nicklas 308   /*
647 11 Apr 08 nicklas 309     From the SignalTarget interface
647 11 Apr 08 nicklas 310     -------------------------------------------
647 11 Apr 08 nicklas 311   */
1292 24 Feb 11 nicklas 312   @Override
647 11 Apr 08 nicklas 313   public SignalHandler getSignalHandler()
647 11 Apr 08 nicklas 314   {
647 11 Apr 08 nicklas 315     signalHandler = new ThreadSignalHandler();
647 11 Apr 08 nicklas 316     return signalHandler;
647 11 Apr 08 nicklas 317   }
647 11 Apr 08 nicklas 318   // -------------------------------------------
647 11 Apr 08 nicklas 319
647 11 Apr 08 nicklas 320   private RequestInformation getConfigureJob(GuiContext context)
647 11 Apr 08 nicklas 321   {
647 11 Apr 08 nicklas 322     if (configureJob == null)
647 11 Apr 08 nicklas 323     {
647 11 Apr 08 nicklas 324       // Create file parameter
647 11 Apr 08 nicklas 325       fileParameter = new PluginParameter<File>(
647 11 Apr 08 nicklas 326         "file",
647 11 Apr 08 nicklas 327         "File",
647 11 Apr 08 nicklas 328         "The file to import the data from",
647 11 Apr 08 nicklas 329         new FileParameterType(null, true, 1)
647 11 Apr 08 nicklas 330       );
647 11 Apr 08 nicklas 331       
1351 28 Apr 11 nicklas 332       boolean defaultUpdateExisting = false;
1351 28 Apr 11 nicklas 333       if (configuration != null)
1351 28 Apr 11 nicklas 334       {
1351 28 Apr 11 nicklas 335         defaultUpdateExisting = Boolean.TRUE.equals(configuration.getValue("updateExisting"));
1351 28 Apr 11 nicklas 336       }
647 11 Apr 08 nicklas 337       // Create update existing parameter
647 11 Apr 08 nicklas 338       updateExistingParameter = new PluginParameter<Boolean>(
647 11 Apr 08 nicklas 339         "updateExisting",
647 11 Apr 08 nicklas 340         "Update existing samples",
647 11 Apr 08 nicklas 341         "If this option is selected, already existing samples will be updated with the information "+
647 11 Apr 08 nicklas 342         "in the file. If this option isn't selected existing samples are left untouched.",
1351 28 Apr 11 nicklas 343         new BooleanParameterType(defaultUpdateExisting, true)
647 11 Apr 08 nicklas 344       );
647 11 Apr 08 nicklas 345       
647 11 Apr 08 nicklas 346       // Create parameter list and request informaion
647 11 Apr 08 nicklas 347       List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
647 11 Apr 08 nicklas 348       parameters.add(fileParameter);
647 11 Apr 08 nicklas 349       parameters.add(updateExistingParameter);
647 11 Apr 08 nicklas 350       
647 11 Apr 08 nicklas 351       configureJob = new RequestInformation
647 11 Apr 08 nicklas 352       (
647 11 Apr 08 nicklas 353         Request.COMMAND_CONFIGURE_JOB,
647 11 Apr 08 nicklas 354         "Select a file to import samples from",
647 11 Apr 08 nicklas 355         "This is an example plugin, it will accept any file but won't import any samples.",
647 11 Apr 08 nicklas 356         parameters
647 11 Apr 08 nicklas 357       );
647 11 Apr 08 nicklas 358     }
647 11 Apr 08 nicklas 359     return configureJob;
647 11 Apr 08 nicklas 360   }
647 11 Apr 08 nicklas 361
1351 28 Apr 11 nicklas 362   private RequestInformation getConfigurePlugin()
1351 28 Apr 11 nicklas 363   {
1351 28 Apr 11 nicklas 364     if (configurePlugin == null)
1351 28 Apr 11 nicklas 365     {
1351 28 Apr 11 nicklas 366       
1351 28 Apr 11 nicklas 367       // Create update existing parameter
1351 28 Apr 11 nicklas 368       updateExistingParameter = new PluginParameter<Boolean>(
1351 28 Apr 11 nicklas 369         "updateExisting",
1351 28 Apr 11 nicklas 370         "Update existing samples",
1351 28 Apr 11 nicklas 371         "If this option is selected, already existing samples will be updated with the information "+
1351 28 Apr 11 nicklas 372         "in the file. If this option isn't selected existing samples are left untouched.",
1351 28 Apr 11 nicklas 373         new BooleanParameterType(false, true)
1351 28 Apr 11 nicklas 374       );
1351 28 Apr 11 nicklas 375       
1351 28 Apr 11 nicklas 376       // Create parameter list and request informaion
1351 28 Apr 11 nicklas 377       List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
1351 28 Apr 11 nicklas 378       parameters.add(updateExistingParameter);
1351 28 Apr 11 nicklas 379       
1351 28 Apr 11 nicklas 380       configurePlugin = new RequestInformation
1351 28 Apr 11 nicklas 381       (
1351 28 Apr 11 nicklas 382         Request.COMMAND_CONFIGURE_PLUGIN,
1351 28 Apr 11 nicklas 383         "Default settings",
1351 28 Apr 11 nicklas 384         "This is an example plugin, it will accept any file but won't import any samples.",
1351 28 Apr 11 nicklas 385         parameters
1351 28 Apr 11 nicklas 386       );
1351 28 Apr 11 nicklas 387     }
1351 28 Apr 11 nicklas 388     return configurePlugin;
1351 28 Apr 11 nicklas 389   }
1351 28 Apr 11 nicklas 390
1351 28 Apr 11 nicklas 391   
647 11 Apr 08 nicklas 392 }