Changeset 1351


Ignore:
Timestamp:
Apr 28, 2011, 8:18:46 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #309: Merge example plug-ins and extensions into one package

Made the ExampleImporter a configurable plug-in so that we can test the new support for installing plug-in configurations automatically.

Location:
extensions/net.sf.basedb.examples/trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.examples/trunk/src/net/sf/basedb/examples/plugins/ExampleImporter.java

    r1347 r1351  
    8888    new GuiContext(Item.SAMPLE, GuiContext.Type.LIST)
    8989  );
    90  
     90
     91  // Plugin configuration is created by getConfigurePlugin()
     92  private RequestInformation configurePlugin;
     93
    9194  // Job configuration is created by getConfigureJob()
    9295  private RequestInformation configureJob;
     
    122125  public boolean supportsConfigurations()
    123126  {
    124     return false;
     127    return true;
    125128  }
    126129  @Override
     
    200203  {
    201204    RequestInformation requestInformation = null;
    202     if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     205    if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
     206    {
     207      requestInformation = getConfigurePlugin();
     208    }
     209    else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
    203210    {
    204211      requestInformation = getConfigureJob(context);
     
    216223    try
    217224    {
    218       if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     225      if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
     226      {
     227        List<Throwable> errors =
     228          validateRequestParameters(getConfigurePlugin().getParameters(), request);
     229        if (errors != null)
     230        {
     231          response.setError(errors.size()+" invalid parameter(s) were found in the request", errors);
     232          return;
     233        }
     234
     235        storeValue(configuration, request, updateExistingParameter);
     236        response.setDone("Configuration completed");
     237      }
     238      else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
    219239      {
    220240        List<Throwable> errors =
     
    312332      );
    313333     
     334      boolean defaultUpdateExisting = false;
     335      if (configuration != null)
     336      {
     337        defaultUpdateExisting = Boolean.TRUE.equals(configuration.getValue("updateExisting"));
     338      }
     339      // Create update existing parameter
     340      updateExistingParameter = new PluginParameter<Boolean>(
     341        "updateExisting",
     342        "Update existing samples",
     343        "If this option is selected, already existing samples will be updated with the information "+
     344        "in the file. If this option isn't selected existing samples are left untouched.",
     345        new BooleanParameterType(defaultUpdateExisting, true)
     346      );
     347     
     348      // Create parameter list and request informaion
     349      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
     350      parameters.add(fileParameter);
     351      parameters.add(updateExistingParameter);
     352     
     353      configureJob = new RequestInformation
     354      (
     355        Request.COMMAND_CONFIGURE_JOB,
     356        "Select a file to import samples from",
     357        "This is an example plugin, it will accept any file but won't import any samples.",
     358        parameters
     359      );
     360    }
     361    return configureJob;
     362  }
     363
     364  private RequestInformation getConfigurePlugin()
     365  {
     366    if (configurePlugin == null)
     367    {
     368     
    314369      // Create update existing parameter
    315370      updateExistingParameter = new PluginParameter<Boolean>(
     
    323378      // Create parameter list and request informaion
    324379      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
    325       parameters.add(fileParameter);
    326380      parameters.add(updateExistingParameter);
    327381     
    328       configureJob = new RequestInformation
     382      configurePlugin = new RequestInformation
    329383      (
    330         Request.COMMAND_CONFIGURE_JOB,
    331         "Select a file to import samples from",
     384        Request.COMMAND_CONFIGURE_PLUGIN,
     385        "Default settings",
    332386        "This is an example plugin, it will accept any file but won't import any samples.",
    333387        parameters
    334388      );
    335389    }
    336     return configureJob;
    337   }
    338 
     390    return configurePlugin;
     391  }
     392
     393 
    339394}
Note: See TracChangeset for help on using the changeset viewer.