Changeset 728


Ignore:
Timestamp:
Jul 17, 2008, 4:20:07 PM (14 years ago)
Author:
Martin Svensson
Message:

Re-arrange the files.
Created the plug-in body for average and cubic spline, without the algorithms.

Location:
plugins/base2/net.sf.basedb.normalizations/trunk/src/net/sf/basedb
Files:
4 added
3 deleted
1 copied

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.normalizations/trunk/src/net/sf/basedb/plugins/AverageNormalization.java

    r727 r728  
    2424*/
    2525
    26 package net.sf.basedb.plugins.average;
     26package net.sf.basedb.plugins;
    2727
    2828import net.sf.basedb.core.BaseException;
     29import net.sf.basedb.core.BioAssay;
     30import net.sf.basedb.core.BioAssaySet;
     31import net.sf.basedb.core.DbControl;
     32import net.sf.basedb.core.PluginParameter;
    2933import net.sf.basedb.core.ProgressReporter;
    3034import net.sf.basedb.core.RequestInformation;
    3135import net.sf.basedb.core.plugin.About;
    3236import net.sf.basedb.core.plugin.AboutImpl;
    33 import net.sf.basedb.core.plugin.AbstractPlugin;
    3437import net.sf.basedb.core.plugin.GuiContext;
    3538import net.sf.basedb.core.plugin.InteractivePlugin;
     
    3740import net.sf.basedb.core.plugin.Response;
    3841import net.sf.basedb.core.signal.SignalHandler;
     42import net.sf.basedb.core.signal.SignalReceivedException;
    3943import net.sf.basedb.core.signal.SignalTarget;
    40 
    41 import java.util.Set;
     44import net.sf.basedb.core.signal.ThreadSignalHandler;
     45import net.sf.basedb.normalizations.Normalizations;
     46import net.sf.basedb.util.Values;
     47
     48import java.util.ArrayList;
     49import java.util.Arrays;
     50import java.util.List;
    4251
    4352/**
     
    5059 */
    5160public class AverageNormalization
    52   extends AbstractPlugin
    53   implements SignalTarget, InteractivePlugin
     61  extends AbstractNormalizationPlugin
     62  implements InteractivePlugin, SignalTarget
    5463{
     64  /**
     65    Use to abort a running job
     66   */
     67  private ThreadSignalHandler signalHandler;
     68 
     69  /**
     70    Holds the configured job parameters
     71  */
     72  private RequestInformation configureJob = null;
     73 
    5574 
    5675  private final About about = new AboutImpl
    5776  (
    5877    "Average normalization plug-in",
    59     "",
    60     "",
    61     "",
    62     "",
    63     "",
    64     ""
     78    "This normalization plug-in uses the average algorithm to adjust sample signals.\n" +
     79    "\n" +
     80    "This plug-in is part of the BASE 2 normalization package.",
     81    Normalizations.PACKAGE_VERSION,
     82    Normalizations.COPYRIGHT,
     83    null,
     84    Normalizations.EMAIL,
     85    Normalizations.URL
    6586  );
    66 
    67   /*  (non-Javadoc)
    68       @see net.sf.basedb.core.signal.SignalTarget#getSignalHandler()
     87   
     88  /*
     89    From SignalTarget interface
     90  */
     91  @Override
     92  public SignalHandler getSignalHandler()
     93  {
     94    signalHandler = new ThreadSignalHandler();
     95    return signalHandler;
     96  }
     97  /*
     98   ---------------------------------------------------------
     99  */
     100
     101
     102  /*
     103    From InteractivePlugin interface
    69104   */
    70105  @Override
    71   public SignalHandler getSignalHandler()
    72   {
    73     // TODO Auto-generated method stub
    74     return null;
    75   }
    76 
    77   /*  (non-Javadoc)
    78       @see net.sf.basedb.core.plugin.InteractivePlugin#configure(net.sf.basedb.core.plugin.GuiContext, net.sf.basedb.core.plugin.Request, net.sf.basedb.core.plugin.Response)
    79    */
    80   @Override
    81   public void configure(GuiContext arg0, Request arg1, Response arg2)
    82   {
    83     // TODO Auto-generated method stub
    84 
    85   }
    86 
    87   /*  (non-Javadoc)
    88       @see net.sf.basedb.core.plugin.InteractivePlugin#getGuiContexts()
    89    */
    90   @Override
    91   public Set<GuiContext> getGuiContexts()
    92   {
    93     // TODO Auto-generated method stub
    94     return null;
    95   }
    96 
    97   /*  (non-Javadoc)
    98       @see net.sf.basedb.core.plugin.InteractivePlugin#getRequestInformation(net.sf.basedb.core.plugin.GuiContext, java.lang.String)
    99    */
    100   @Override
    101   public RequestInformation getRequestInformation(GuiContext context, String arg1)
     106  public void configure(GuiContext context, Request request, Response response)
     107  {
     108    String command = request.getCommand();
     109    if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     110    {
     111      try
     112      {
     113        RequestInformation ri = getConfiguredJobParameters();
     114        List<Throwable> errors = validateRequestParameters(ri.getParameters(), request);
     115        if (errors != null)
     116        {
     117          response.setError(errors.size() + " invalid parameter(s) were found in the request", errors);
     118          return;
     119        }
     120
     121        // Source bioassay set
     122        storeValue(job, request, ri.getParameter(SOURCE_BIOASSAYSET));
     123               
     124        // Child name, description and transformation
     125        storeValue(job, request, ri.getParameter(CHILD_NAME));
     126        storeValue(job, request, ri.getParameter(CHILD_DESCRIPTION));
     127       
     128        //TODO Store Average Normalization specific parameters
     129      }
     130      catch (SignalReceivedException signalException)
     131      {
     132        response.setError("Aborted by user.", Arrays.asList(signalException));
     133      }
     134      catch (Throwable ex)
     135      {
     136        response.setError(ex.getMessage(), Arrays.asList(ex));
     137      }
     138    }
     139  }
     140
     141
     142  @Override
     143  public RequestInformation getRequestInformation(GuiContext context, String command)
    102144      throws BaseException
    103145  {
    104     // TODO Auto-generated method stub
    105     return null;
    106   }
    107 
    108   /*  (non-Javadoc)
    109       @see net.sf.basedb.core.plugin.InteractivePlugin#isInContext(net.sf.basedb.core.plugin.GuiContext, java.lang.Object)
    110    */
    111   @Override
    112   public String isInContext(GuiContext arg0, Object arg1)
    113   {
    114     // TODO Auto-generated method stub
    115     return null;
    116   }
    117 
    118   /*  (non-Javadoc)
    119       @see net.sf.basedb.core.plugin.Plugin#getAbout()
    120    */
     146    RequestInformation requestInformation = null;
     147    if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     148    {
     149      requestInformation = getConfiguredJobParameters();
     150    }
     151    return requestInformation;
     152  }
     153  /*
     154   ---------------------------------------------------------
     155  */
     156 
     157  /*
     158    From Plugin interface
     159  */
    121160  @Override
    122161  public About getAbout()
    123162  {
    124     // TODO Auto-generated method stub
    125     return null;
    126   }
    127 
    128   /*  (non-Javadoc)
    129       @see net.sf.basedb.core.plugin.Plugin#getMainType()
    130    */
    131   @Override
    132   public MainType getMainType()
    133   {
    134     // TODO Auto-generated method stub
    135     return null;
    136   }
    137 
    138   /*  (non-Javadoc)
    139       @see net.sf.basedb.core.plugin.Plugin#run(net.sf.basedb.core.plugin.Request, net.sf.basedb.core.plugin.Response, net.sf.basedb.core.ProgressReporter)
    140    */
    141   @Override
    142   public void run(Request arg0, Response arg1, ProgressReporter arg2)
    143   {
    144     // TODO Auto-generated method stub
    145 
    146   }
    147 
     163    return about;
     164  }
     165
     166  @Override
     167  public void run(Request request, Response response, ProgressReporter progress)
     168  {
     169    String command = request.getCommand();
     170    if (command.equals(Request.COMMAND_EXECUTE))
     171    {
     172      if (signalHandler != null)
     173      {
     174        signalHandler.setWorkerThread(null);
     175      }
     176      DbControl dc = null;
     177      try
     178      {
     179        dc = sc.newDbControl();
     180        BioAssaySet source = getSourceBioAssaySet(dc);
     181        String childName = Values.getString((String)job.getValue(CHILD_NAME), source.getName());
     182        String childDescription = (String)job.getValue(CHILD_DESCRIPTION);
     183       
     184        List<BioAssay> referenceGroup = getReferenceGroup(dc);
     185        //TODO Implement things specific for the algortihm.
     186      }
     187      catch (Throwable ex)
     188      {
     189        response.setError(ex.getMessage(), Arrays.asList(ex));
     190      }
     191      finally
     192      {
     193        if (dc != null) dc.close();
     194      }
     195    }
     196  }
     197  /*
     198   ---------------------------------------------------------
     199  */
     200 
     201  private RequestInformation getConfiguredJobParameters()
     202  {
     203    DbControl dc = null;
     204    try
     205    {
     206      if (configureJob == null)
     207      {
     208        dc = sc.newDbControl();
     209        BioAssaySet bas = getCurrentBioAssaySet(dc);
     210        List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(3);
     211       
     212        // Source and child bioassay set parameters
     213        parameters.add(getSourceBioAssaySetParameter(null, null));
     214        parameters.add(getChildNameParameter(null, null, bas.getName()));
     215        parameters.add(getChildDescriptionParameter(null, null, null));
     216
     217        //Reference group
     218        parameters.add(getReferenceGroupParameter(null, null));
     219        //TODO Configure Average Normalization specific parameters.
     220      }
     221    }
     222    finally
     223    {
     224      if (dc != null ) dc.close();
     225    }
     226   
     227    return configureJob;
     228  }
    148229}
Note: See TracChangeset for help on using the changeset viewer.