Changeset 3108


Ignore:
Timestamp:
Feb 6, 2007, 3:28:34 PM (16 years ago)
Author:
Johan Enell
Message:

BASE1PluginExecuter uses BioAssaySetExporter? to create basefile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r2992 r3108  
    2121 Foundation, Inc., 59 Temple Place - Suite 330,
    2222 Boston, MA  02111-1307, USA.
    23  */
     23*/
    2424
    2525package net.sf.basedb.plugins;
     
    3434import net.sf.basedb.core.DbControl;
    3535import net.sf.basedb.core.Directory;
    36 import net.sf.basedb.core.DynamicResultIterator;
    37 import net.sf.basedb.core.DynamicSpotQuery;
    3836import net.sf.basedb.core.Experiment;
    3937import net.sf.basedb.core.ExtraValue;
     
    4442import net.sf.basedb.core.Include;
    4543import net.sf.basedb.core.IntegerParameterType;
    46 import net.sf.basedb.core.InvalidDataException;
    4744import net.sf.basedb.core.Item;
    4845import net.sf.basedb.core.ItemNotFoundException;
    49 import net.sf.basedb.core.ItemParameterType;
    5046import net.sf.basedb.core.ItemQuery;
    5147import net.sf.basedb.core.Job;
     
    6056import net.sf.basedb.core.SpotExtraValueBatcher;
    6157import net.sf.basedb.core.StringParameterType;
    62 import net.sf.basedb.core.SystemItems;
    6358import net.sf.basedb.core.Transformation;
    6459import net.sf.basedb.core.Type;
    65 import net.sf.basedb.core.User;
    66 import net.sf.basedb.core.VirtualColumn;
    6760import net.sf.basedb.core.plugin.About;
    6861import net.sf.basedb.core.plugin.AboutImpl;
    69 import net.sf.basedb.core.plugin.AbstractPlugin;
     62import net.sf.basedb.core.plugin.AbstractAnalysisPlugin;
    7063import net.sf.basedb.core.plugin.GuiContext;
    7164import net.sf.basedb.core.plugin.InteractivePlugin;
     65import net.sf.basedb.core.plugin.Permissions;
    7266import net.sf.basedb.core.plugin.Request;
    7367import net.sf.basedb.core.plugin.Response;
    74 import net.sf.basedb.core.query.Dynamic;
    75 import net.sf.basedb.core.query.Expressions;
    7668import net.sf.basedb.core.query.Hql;
    77 import net.sf.basedb.core.query.JoinType;
    7869import net.sf.basedb.core.query.Orders;
    79 import net.sf.basedb.core.query.Restrictions;
    80 import net.sf.basedb.core.query.Select;
    81 import net.sf.basedb.core.query.Selects;
    82 import net.sf.basedb.core.query.SqlResult;
    83 import net.sf.basedb.core.query.WhenStatement;
    84 import net.sf.basedb.util.BioAssaySetUtil;
    8570import net.sf.basedb.util.Enumeration;
     71import net.sf.basedb.util.RemovableUtil;
    8672import net.sf.basedb.util.parser.FlatFileParser;
    8773
     
    10086import java.util.ArrayList;
    10187import java.util.Arrays;
     88import java.util.Collection;
    10289import java.util.Collections;
     90import java.util.EnumSet;
    10391import java.util.HashMap;
    10492import java.util.HashSet;
     
    10997import java.util.regex.Pattern;
    11098
    111 public class Base1PluginExecuter extends AbstractPlugin implements InteractivePlugin
     99public class Base1PluginExecuter extends AbstractAnalysisPlugin implements InteractivePlugin
    112100{
    113101  /**
     
    122110    null,
    123111    "http://base.thep.lu.se");
    124 
    125   private static final Set<GuiContext> guiContexts = Collections.singleton(new GuiContext(Item.BIOASSAYSET, GuiContext.Type.ITEM));
    126 
     112 
     113  private static final Set<Permissions> permissions = new HashSet<Permissions>();
     114 
    127115  /**
    128116   * Parameter definition that asks for the file that should be imported. This
     
    132120    "file",
    133121    "File",
    134     "The file to import the data from",
    135     new FileParameterType(null, true, 1));
     122    "The file to import the data from. If you leave this parameter blank you can manually configure the plug-in.",
     123    new FileParameterType(null, false, 1));
    136124
    137125  private static PluginParameter<String> execPathParameter = new PluginParameter<String>(
     
    140128    "The path to the executables",
    141129    new StringParameterType(255, null, true));
    142 
    143   /** File configuration parameters * */
    144   private static final String serialFormatParameterName = "serialFormat";
    145 
    146   private static final String versionNumberParameterName = "versionNumber";
    147 
    148   private static final String execNameParameterName = "execName";
    149 
    150   private static final String geneAveragesParameterName = "geneAverages";
    151 
    152   private static final String minChannelsParameterName = "minChannels";
    153 
    154   private static final String maxChannelsParameterName = "maxChannels";
    155 
    156   private static final String leaveStdinParameterName = "leaveStdin";
    157 
    158   private static final String leaveStdoutParameterName = "leaveStdout";
    159 
    160   private static final String usedColumnsParameterName = "usedColumns";
    161 
    162   private static final String usedFieldsParameterName = "usedFields";
    163 
    164   /** * */
    165 
    166   /** Job parameters * */
    167   private static final PluginParameter<BioAssaySet> bioAssaySetParameter = new PluginParameter<BioAssaySet>(
    168     "bioAssaySet",
    169     "Bioassay set",
    170     "The bioassay set that this plugin will run on",
    171     new ItemParameterType<BioAssaySet>(BioAssaySet.class, null, true, 1, null));
    172 
    173   private static final String pluginDirectoryParameterName = "pluginDirectory";
    174 
    175   /** **/
    176 
    177   private static final String PARSE_CONFIG_FILE = "PARSE_CONFIG_FILE";
     130 
     131  /* File configuration parameters */
     132  private PluginParameter<Boolean> serialFormatParameter;
     133  private PluginParameter<String> versionNumberParameter;
     134  private PluginParameter<String> execNameParameter;
     135  private PluginParameter<Boolean> geneAveragesParameter;
     136  private PluginParameter<Integer> minChannelsParameter;
     137  private PluginParameter<Integer> maxChannelsParameter;
     138  private PluginParameter<Boolean> leaveStdinParameter;
     139  private PluginParameter<Boolean> leaveStdoutParameter;
     140  private PluginParameter<String> usedColumnsParameter;
     141  private PluginParameter<String> usedFieldsParameter;
     142 
     143  /* Job parameters */
     144  private PluginParameter<String> pluginDirectoryParameter;
     145
     146  private static final String COMMAND_MANUAL_CONFIG = "COMMAND_MANUAL_CONFIG";
    178147
    179148  private RequestInformation configureJob;
    180 
    181149  private RequestInformation configurePlugin;
    182 
    183   private RequestInformation configureFile;
     150  private RequestInformation configureManual;
    184151
    185152  /**
     
    189156
    190157  /**
    191    * This list holds the configure parameters derived from the headers in the
    192    * configuration file.
    193    */
    194   private List<PluginParameter<?>> configureFileParameters;
    195 
    196   /**
    197158   * This is the directory where the plugin will generate its output.
    198159   */
    199160  private java.io.File execDirectory;
    200161
    201   private Directory pluginDirectory;
    202 
    203   private Map<String, Select> base1columns = null;
    204 
    205   // *** From InteractivePlugin iterface
    206   public Set<GuiContext> getGuiContexts()
    207   {
    208     return guiContexts;
    209   }
    210 
     162  /* From InteractivePlugin iterface */
     163
     164  @Override
    211165  public String isInContext(GuiContext context, Object item)
    212166  {
    213     String message = null;
    214     if (item == null)
    215     {
    216       message = "The object is null";
    217     }
    218     else if (!(item instanceof BioAssaySet))
    219     {
    220       message = "The object is not a BioAssaySet: " + item;
    221     }
    222     else
    223     {
    224       DbControl dc = sc.newDbControl();
    225       RequestInformation ri = getConfigureFileParameters();
    226 
    227       PluginConfiguration pc = PluginConfiguration.getById(dc, configuration.getId());
    228       String name = pc.getName();
    229      
    230       BioAssaySet bas = (BioAssaySet) item;
    231 
    232       int channels = bas.getRawDataType().getChannels();
    233       Integer maxChannels = pc.getParameterValues(maxChannelsParameterName).isEmpty() ? null : (Integer) pc.getParameterValues(maxChannelsParameterName).get(0);
    234       Integer minChannels = (Integer) pc.getParameterValues(minChannelsParameterName).get(0);
    235       if (channels < minChannels || ( maxChannels != 0 && channels > maxChannels))
    236       {
    237         message = name + " can't work on " + channels + "-channel data. " + minChannels + " < " + channels + " < " + maxChannels;
    238       }
    239      
    240       List<String> extraValues = new ArrayList<String>();
    241       for (ExtraValue ev : bas.getExtraValues().list(dc))
    242       {
    243         extraValues.add(ev.getExtraValueType().getName());
    244       }
    245       Pattern p = Pattern.compile("_xc_(.+)\\t?");
    246       Matcher m = p.matcher((String) ri.getParameter(usedFieldsParameterName).getParameterType().getDefaultValue());
    247       while (message == null && m.find())
    248       {
    249         if (!extraValues.contains(m.group(1)))
    250         {
    251           message = "Requires "+ m.group(1) +" attached to BioAssaySet";
    252         }
    253       }
    254       dc.close();
     167    String message = super.isInContext(context, item);
     168    if (message == null)
     169    {
     170      DbControl dc = null;
     171      try
     172      {
     173        dc = sc.newDbControl();
     174        getManualConfigureParameters();
     175
     176        BioAssaySet bas = (BioAssaySet) item;
     177        int channels = bas.getRawDataType().getChannels();
     178        Integer maxChannels = (Integer) configuration.getValue(maxChannelsParameter.getName());
     179        Integer minChannels = (Integer) configuration.getValue(minChannelsParameter.getName());;
     180        if (channels < minChannels || ( maxChannels != 0 && channels > maxChannels))
     181        {
     182          message = configuration.getPluginConfiguration().getName() + " can't work on " + channels + "-channel data. " + minChannels + " < " + channels + " < " + maxChannels;
     183        }
     184       
     185        List<String> extraValues = new ArrayList<String>();
     186        for (ExtraValue ev : bas.getExtraValues().list(dc))
     187        {
     188          extraValues.add(ev.getExtraValueType().getName());
     189        }
     190        Pattern p = Pattern.compile("_xc_(.+)\\t?");
     191        Matcher m = p.matcher((CharSequence) configuration.getValue(usedFieldsParameter.getName()));
     192        while (message == null && m.find())
     193        {
     194          if (!extraValues.contains(m.group(1)))
     195          {
     196            message = "Requires "+ m.group(1) +" attached to BioAssaySet";
     197          }
     198        }
     199      }
     200      catch (Exception e)
     201      {
     202        message = e.getMessage();
     203        e.printStackTrace();
     204      }
     205      finally
     206      {
     207        if (dc != null)
     208        {
     209          dc.close();
     210        }
     211      }
    255212    }
    256213    return message;
     
    266223      requestInformation = getConfigurePluginParameters();
    267224    }
    268     else if (command.equals(Base1PluginExecuter.PARSE_CONFIG_FILE))
    269     {
    270       requestInformation = getConfigureFileParameters();
     225    else if (command.equals(Base1PluginExecuter.COMMAND_MANUAL_CONFIG))
     226    {
     227      requestInformation = getManualConfigureParameters();
    271228    }
    272229    else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
     
    278235      catch (IOException e)
    279236      {
    280         throw new BaseException("Unable to configure job from configuratin file.");
    281       }
     237        throw new BaseException("Unable to configure job from configuration file. "+e.getMessage());
     238      }
     239    }
     240    else
     241    {
     242      throw new BaseException("Unknown command: "+command);
    282243    }
    283244    return requestInformation;
    284245  }
     246 
    285247
    286248  public void configure(GuiContext context, Request request, Response response)
    287249  {
    288250    String command = request.getCommand();
     251    DbControl dc = null;
    289252    try
    290253    {
    291254      if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN))
    292255      {
     256        storeValue(configuration, request, execPathParameter);
    293257        storeValue(configuration, request, fileParameter);
    294         storeValue(configuration, request, execPathParameter);
    295 
    296         response.setContinue(Base1PluginExecuter.PARSE_CONFIG_FILE);
    297       }
    298       else if (command.equals(Base1PluginExecuter.PARSE_CONFIG_FILE))
    299       {
    300         for (PluginParameter<?> p : getConfigureParameters())
    301         {
    302           storeValue(configuration, request, p);
    303         }
    304 
     258       
     259        dc = sc.newDbControl();
     260        File f = (File) request.getParameterValue(fileParameter.getName());
     261        PluginConfiguration pc = PluginConfiguration.getById(dc, configuration.getId());
     262        if (f != null)
     263        {
     264          f = File.getById(dc, f.getId());
     265          AnyToAny ata = AnyToAny.getNewOrExisting(dc, pc, "Configurationfile", f, true);
     266          if (!ata.isInDatabase())
     267          {
     268            dc.saveItem(ata);
     269          }
     270         
     271          getManualConfigureParameters();
     272          Map<String, String> headers = getBaseFileHeaders(f);
     273          configuration.setValue(serialFormatParameter.getName(), serialFormatParameter.getParameterType(), getBoolean(headers.get(serialFormatParameter.getName())));
     274          configuration.setValue(versionNumberParameter.getName(), versionNumberParameter.getParameterType(), headers.get(versionNumberParameter.getName()));
     275          configuration.setValue(execNameParameter.getName(), execNameParameter.getParameterType(), headers.get(execNameParameter.getName()));
     276          configuration.setValue(geneAveragesParameter.getName(), geneAveragesParameter.getParameterType(), getBoolean(headers.get(geneAveragesParameter.getName())));
     277          configuration.setValue(minChannelsParameter.getName(), minChannelsParameter.getParameterType(), new Integer(headers.get(minChannelsParameter.getName())));
     278          configuration.setValue(maxChannelsParameter.getName(), maxChannelsParameter.getParameterType(), new Integer(headers.get(maxChannelsParameter.getName())));
     279          configuration.setValue(leaveStdinParameter.getName(), leaveStdinParameter.getParameterType(), getBoolean(headers.get(leaveStdinParameter.getName())));
     280          configuration.setValue(leaveStdoutParameter.getName(), leaveStdoutParameter.getParameterType(), getBoolean(headers.get(leaveStdoutParameter.getName())));
     281          configuration.setValue(usedColumnsParameter.getName(), usedColumnsParameter.getParameterType(), headers.get(usedColumnsParameter.getName()));
     282          configuration.setValue(usedFieldsParameter.getName(), usedFieldsParameter.getParameterType(), headers.get(usedFieldsParameter.getName()));
     283         
     284          response.setDone("Configured plug-in with file.");
     285        }
     286        else
     287        {
     288          response.setContinue(Base1PluginExecuter.COMMAND_MANUAL_CONFIG);
     289        }
     290      }
     291      else if (command.equals(Base1PluginExecuter.COMMAND_MANUAL_CONFIG))
     292      {
     293        storeValue(configuration, request, serialFormatParameter);
     294        storeValue(configuration, request, versionNumberParameter);
     295        storeValue(configuration, request, execNameParameter);
     296        storeValue(configuration, request, geneAveragesParameter);
     297        storeValue(configuration, request, minChannelsParameter);
     298        storeValue(configuration, request, maxChannelsParameter);
     299        storeValue(configuration, request, leaveStdinParameter);
     300        storeValue(configuration, request, leaveStdoutParameter);
     301        storeValue(configuration, request, usedColumnsParameter);
     302        storeValue(configuration, request, usedFieldsParameter);
     303       
     304        //TODO: Ask about parameters and create a config file
    305305        response.setDone("Plugin configuration done.");
    306306      }
    307307      else if (command.equals(Request.COMMAND_CONFIGURE_JOB))
    308308      {
    309         storeValue(job, request, bioAssaySetParameter);
    310 
     309        storeValue(job, request, getSourceBioAssaySetParameter(null, null));
    311310        for (PluginParameter<?> p : getJobParameters())
    312311        {
    313312          storeValue(job, request, p);
    314313        }
    315        
    316314        response.setDone("Job configuration complete", Job.ExecutionTime.SHORT);
    317315      }
     316      else
     317      {
     318        throw new BaseException("Command unknown: "+command);
     319      }
    318320    }
    319321    catch (Throwable ex)
    320322    {
    321       ex.printStackTrace();
    322323      response.setError(ex.getMessage(), Arrays.asList(ex));
    323324    }
    324   }
    325 
     325    finally
     326    {
     327      if (dc != null)
     328      {
     329        dc.commit();
     330        dc.close();
     331      }
     332    }
     333  }
     334 
     335 
     336  private void copy(File f, java.io.File d)
     337    throws IOException
     338  {
     339    if (f != null && d.isDirectory())
     340    {
     341      java.io.File target = new java.io.File(d, f.getName());
     342      InputStream in = f.getDownloadStream(0);
     343      FileOutputStream out = new FileOutputStream(target);
     344      byte[] buf = new byte[1024];
     345      int i = 0;
     346      while((i = in.read(buf)) != -1)
     347      {
     348        out.write(buf, 0, i);
     349      }
     350      in.close();
     351      out.close();
     352    }
     353  }
     354 
     355 
     356  private void createPluginDirectory()
     357  {
     358    DbControl dc = null;
     359    try
     360    {
     361      dc = sc.newDbControl();
     362      Directory parent = Directory.getByPath(dc, getPluginDirectoryPath().getParent());
     363      if (Directory.exists(dc, parent, getPluginDirectoryPath().getDirectory(getPluginDirectoryPath().getDirectoryCount() - 1)))
     364      {
     365        int directoryId = Directory.getIdFromPath(dc, getPluginDirectoryPath());
     366        RemovableUtil.removeRecursively(dc, Item.DIRECTORY, Collections.singleton(directoryId), true);
     367        dc.commit();
     368        dc = sc.newDbControl();
     369      }
     370      Directory d = Directory.getNew(dc, getPluginDirectoryPath());
     371      dc.saveItem(d);
     372      dc.commit();
     373    }
     374    finally
     375    {
     376      if (dc != null) dc.close();
     377    }
     378  }
     379 
     380
     381  /**
     382  */
     383  @Override
     384  public Collection<Permissions> getPermissions()
     385  {
     386    if (permissions.size() == 0)
     387    {
     388      permissions.add(new Permissions(Item.ANNOTATIONTYPE, null, EnumSet.of(Permission.READ)));
     389      permissions.add(new Permissions(Item.DIRECTORY, null, EnumSet.of(Permission.CREATE, Permission.WRITE)));
     390      permissions.add(new Permissions(Item.EXPERIMENT, null, EnumSet.of(Permission.WRITE)));
     391      permissions.add(new Permissions(Item.FILE, EnumSet.of(Permission.USE), EnumSet.of(Permission.CREATE, Permission.WRITE)));
     392      permissions.add(new Permissions(Item.PLUGINCONFIGURATION, EnumSet.of(Permission.WRITE), null));
     393      permissions.add(new Permissions(Item.RAWBIOASSAY, null, EnumSet.of(Permission.READ)));
     394    }
     395    return permissions;
     396  }
     397 
    326398  // ***
    327399
    328400  // *** From Plugin interface
    329   public MainType getMainType()
    330   {
    331     return MainType.ANALYZE;
    332   }
    333401
    334402  public About getAbout()
     
    336404    return about;
    337405  }
     406 
    338407
    339408  @Override
     
    342411    return true;
    343412  }
     413 
    344414
    345415  @Override
     
    348418    return true;
    349419  }
     420 
    350421
    351422  public void run(Request request, Response response, ProgressReporter progress)
     
    354425    if (command.equals(Request.COMMAND_EXECUTE))
    355426    {
     427      DbControl dc = sc.newDbControl();
    356428      try
    357429      {
     430        getManualConfigureParameters();
     431        getConfigureJobParameters();
    358432        progress.display(0, "Exporting data to be used by plugin.");
    359         exportData();
    360 
     433        createPluginDirectory();
     434        File stdin = exportData(dc);
     435        copy(stdin, getExecDirectory());
    361436        progress.display(10, "Running on remote computation server.");
    362437       
    363438        String execPath = (String) configuration.getValue(execPathParameter.getName());
    364         String execName = (String) configuration.getValue(execNameParameterName);
     439        String execName = (String) configuration.getValue(execNameParameter.getName());
    365440        Process p = Runtime.getRuntime().exec(execPath + java.io.File.separator + execName, null, getExecDirectory());
    366441
     
    371446        StreamHandler inputStream = new StreamHandler(new BufferedInputStream(p.getInputStream()), new BufferedOutputStream(out));
    372447       
    373         java.io.File stdin = new java.io.File(getExecDirectory(), "stdin.txt");
    374        
    375         StreamHandler outputStream = new StreamHandler(
    376           new BufferedInputStream(new FileInputStream(stdin)),
    377           new BufferedOutputStream(p.getOutputStream()));
     448        StreamHandler outputStream = new StreamHandler(new BufferedInputStream(stdin.getDownloadStream(0)), new BufferedOutputStream(p.getOutputStream()));
    378449       
    379450        inputStream.start();
     
    383454        err.flush();
    384455        out.close();
    385 
    386456       
    387457        int t;
     
    394464        else
    395465        {
    396           DbControl dc = sc.newDbControl();
    397  
    398           BioAssaySet parentBas = (BioAssaySet) job.getValue(bioAssaySetParameter.getName());
    399           parentBas = BioAssaySet.getById(dc, parentBas.getId());
     466          BioAssaySet parentBas = getSourceBioAssaySet(dc);
    400467          Transformation trans = parentBas.newTransformation(Job.getById(dc, job.getId()));
    401           trans.setName("Something---");
     468          trans.setName(getTransformationName(dc));
    402469          dc.saveItem(trans);
    403470          dc.commit();
     
    414481      {
    415482        getExecDirectory().delete();
     483        dc.close();
    416484      }
    417485    }
     
    421489    }
    422490  }
    423 
    424   // ***
    425 
    426 
    427   private FlatFileParser getInitializedFlatFileParser(InputStream stream)
    428     throws BaseException
    429   {
    430     FlatFileParser ffp = new FlatFileParser();
    431     ffp.setSectionRegexp(Pattern.compile("section\\t(.*)"));
    432     ffp.setHeaderRegexp(Pattern.compile("(.*?)\\s(.*)"));
    433     ffp.setDataHeaderRegexp(Pattern.compile("%"));
    434     ffp.setDataSplitterRegexp(Pattern.compile("\\t"));
    435 
    436     ffp.setInputStream(stream, Config.getCharset());
    437     return ffp;
    438   }
    439 
    440   private List<PluginParameter<?>> getConfigureParameters()
    441   {
    442     if (configureFileParameters == null)
    443     {
    444       configureFileParameters = new ArrayList<PluginParameter<?>>();
    445 
    446       File f = (File) configuration.getValue(fileParameter.getName());
    447       FlatFileParser ffp = getInitializedFlatFileParser(f.getDownloadStream(0));
    448 
    449       try
    450       {
    451         FlatFileParser.LineType result = ffp.parseHeaders();
    452         if (result != FlatFileParser.LineType.UNKNOWN)
    453         {
    454           if (!ffp.getLine(0).line().equals("BASEfile"))
    455           {
    456             throw new InvalidDataException(
    457               "File '" + f + "' is not a valid basefile. First line (" + ffp.getLine(0).line() + ") must be BASEfile.");
    458           }
    459 
    460           FlatFileParser.Line section = ffp.nextSection();
    461           while (section != null && !section.name().equals("plugin"))
    462           {
    463             section = ffp.nextSection();
    464           }
    465           if (section == null)
    466           {
    467             throw new InvalidDataException(
    468               "File '" + f + "' is not a valid plugin configuration. cannt find the plugin section.");
    469           }
    470           ffp.parseHeaders();
    471         }
    472         else
    473         {
    474           throw new InvalidDataException("Unable to parse configuration file '" + f + "'.");
    475         }
    476       }
    477       catch (IOException e)
    478       {
    479         throw new BaseException("Unable to read the configuration file: " + e.getMessage());
    480       }
    481       configureFileParameters.add(new PluginParameter<String>(
    482         versionNumberParameterName,
     491 
     492
     493  private File exportData(DbControl dc)
     494  {
     495    try
     496    {
     497      Directory d = Directory.getByPath(dc, getPluginDirectoryPath());
     498      File file = File.getFile(dc, d, "stdin.txt", true);
     499      file.setMimeTypeAuto("text/plain", null);
     500      if(!file.isInDatabase()) dc.saveItem(file);
     501     
     502      BioAssaySet bas = getSourceBioAssaySet(dc);
     503     
     504      String usedColumns = (String) configuration.getValue(usedColumnsParameter.getName());
     505      List<String> reporterFields = Arrays.asList(usedColumns.split("\\\\t"));
     506     
     507      String usedFields = (String) configuration.getValue(usedFieldsParameter.getName());
     508      List<String> spotFields = Arrays.asList(usedFields.split("\\\\t"));
     509     
     510      Boolean mergeReporters = (Boolean) configuration.getValue(geneAveragesParameter.getName());
     511     
     512      Map<String, String> parameters = new HashMap<String, String>();
     513      for (PluginParameter<?> pp : getJobParameters())
     514      {
     515        String name = pp.getName();
     516        Object value = job.getValue(name);
     517        parameters.put(name, value == null ? "" : value.toString());
     518      }
     519     
     520      BioAssaySetExporter exporter = new BioAssaySetExporter();
     521      if ((Boolean) configuration.getValue(serialFormatParameter.getName()))
     522      {
     523        exporter.exportBaseFileSerial(bas, file, parameters, reporterFields, spotFields, mergeReporters);
     524      }
     525      else
     526      {
     527        exporter.exportBaseFileMatrix(bas, file, parameters, reporterFields, spotFields, mergeReporters);
     528      }
     529      return file;
     530    }
     531    catch (IOException e)
     532    {
     533      throw new BaseException(e);
     534    }
     535    catch (SQLException e)
     536    {
     537      throw new BaseException(e);
     538    }
     539  }
     540 
     541 
     542  private List<AnnotationType> getAnnotationTypes(DbControl dc, Experiment e)
     543  {
     544    ItemQuery<AnnotationType> query = e.getExperimentalFactors();
     545    query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
     546    query.order(Orders.asc(Hql.property("name")));
     547    return query.list(dc);
     548  }
     549 
     550 
     551 
     552  private Map<String, String> getBaseFileHeaders(File f)
     553    throws IOException
     554  {
     555    FlatFileParser ffp = getInitializedFlatFileParser(f.getDownloadStream(0));
     556    ffp.setMinDataColumns(8);
     557
     558    FlatFileParser.Line s = ffp.nextSection();
     559    ffp.parseHeaders();
     560    if (!s.name().equals("plugin"))
     561    {
     562      throw new BaseException("Bad format on configfile.");
     563    }
     564   
     565    HashMap<String, String> headers = new HashMap<String, String>();
     566    for (String header : ffp.getHeaderNames())
     567    {
     568      headers.put(header, ffp.getHeader(header));
     569    }
     570    return headers;
     571  }
     572 
     573 
     574  private Boolean getBoolean(String s)
     575  {
     576    return s.equals("0") ? false : true;
     577  }
     578 
     579  private RequestInformation getManualConfigureParameters()
     580  {
     581    if (configureManual == null)
     582    {
     583      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
     584
     585      versionNumberParameter = new PluginParameter<String>(
     586        "versionNumber",
    483587        "Version",
    484588        "The version of this plug-in",
    485         new StringParameterType(255, ffp.getHeader(versionNumberParameterName), true)));
    486 
    487       configureFileParameters.add(new PluginParameter<String>(
    488         execNameParameterName,
     589        new StringParameterType(255, null, false));
     590      parameters.add(versionNumberParameter);
     591     
     592      usedColumnsParameter = new PluginParameter<String>(
     593        "usedColumns",
     594        "Columns",
     595        "A tab separeted sting of field namnes. A field is a value from the bioassay, the rawdata or feature",
     596        new StringParameterType(null, null, true));
     597      parameters.add(usedColumnsParameter);
     598     
     599      usedFieldsParameter = new PluginParameter<String>(
     600        "usedFields",
     601        "Fields",
     602        "A tab separeted sting of field namnes. A field is a value from the bioassay or the rawdata",
     603        new StringParameterType(null, null, true));
     604      parameters.add(usedFieldsParameter);
     605     
     606      execNameParameter = new PluginParameter<String>(
     607        "execName",
    489608        "Name of executable",
    490609        "The name of the file to be executed.",
    491         new StringParameterType(255, ffp.getHeader(execNameParameterName), true)));
    492 
    493       configureFileParameters.add(new PluginParameter<String>(
    494         usedColumnsParameterName,
    495         "Columns",
    496         "A tab separeted sting of field namnes. A field is a value from the bioassay, the rawdata or feature",
    497         new StringParameterType(null, ffp.getHeader(usedColumnsParameterName), true)));
    498 
    499       configureFileParameters.add(new PluginParameter<String>(
    500         usedFieldsParameterName,
    501         "Fields",
    502         "A tab separeted sting of field namnes. A field is a value from the bioassay or the rawdata",
    503         new StringParameterType(null, ffp.getHeader(usedFieldsParameterName), true)));
    504 
    505       configureFileParameters.add(new PluginParameter<Boolean>(
    506         geneAveragesParameterName,
     610        new StringParameterType(255, null, true));
     611      parameters.add(execNameParameter);
     612     
     613      geneAveragesParameter = new PluginParameter<Boolean>(
     614        "geneAverages",
    507615        "Average on reporters",
    508616        "Average on reporters within each assay",
    509         new BooleanParameterType(new Boolean(ffp.getHeader(geneAveragesParameterName).equals("0") ? false : true), true)));
    510 
    511       Enumeration<String, String> formatEnum = new Enumeration<String, String>();
    512       formatEnum.add("0", "Normal BASEfile (one big matrix)");
    513       formatEnum.add("1", "Serial BASEfile (one section per assay)");
    514       configureFileParameters.add(new PluginParameter<String>(
    515         serialFormatParameterName,
     617        new BooleanParameterType(false, true));
     618      parameters.add(geneAveragesParameter);
     619
     620      Enumeration<Boolean, String> format = new Enumeration<Boolean, String>();
     621      format.add(false, "Normal BASEfile (one big matrix)");
     622      format.add(true, "Serial BASEfile (one section per assay)");
     623      serialFormatParameter = new PluginParameter<Boolean>(
     624        "serialFormat",
    516625        "Data format",
    517626        "The format of the datafile can either be in a serial or matrix format",
    518         new StringParameterType(1, ffp.getHeader(serialFormatParameterName), true, 1, 0, 0, formatEnum)));
    519 
    520       configureFileParameters.add(new PluginParameter<Boolean>(
    521         leaveStdinParameterName,
     627        new BooleanParameterType(null, true, 1, format));
     628      parameters.add(serialFormatParameter);
     629     
     630      leaveStdinParameter = new PluginParameter<Boolean>(
     631        "leaveStdin",
    522632        "Leave stdin.txt",
    523633        "If the file stdin.txt should be removed after the plug-in execution or not",
    524         new BooleanParameterType(new Boolean(ffp.getHeader(leaveStdinParameterName).equals("0") ? false : true), true)));
    525 
    526       configureFileParameters.add(new PluginParameter<Boolean>(
    527         leaveStdoutParameterName,
     634        new BooleanParameterType(false, true));
     635      parameters.add(leaveStdinParameter);
     636     
     637      leaveStdoutParameter = new PluginParameter<Boolean>(
     638        "leaveStdout",
    528639        "Leave stdout.txt",
    529640        "If the file stdout.txt should be removed after the plug-in execution or not",
    530         new BooleanParameterType(new Boolean(ffp.getHeader(leaveStdoutParameterName).equals("0") ? false : true), true)));
    531 
    532       configureFileParameters.add(new PluginParameter<Integer>(
    533         minChannelsParameterName,
     641        new BooleanParameterType(false, true));
     642      parameters.add(leaveStdoutParameter);
     643     
     644      minChannelsParameter = new PluginParameter<Integer>(
     645        "minChannels",
    534646        "Min channels",
    535647        "Minimum number of channels",
    536         new IntegerParameterType(1, null, new Integer(ffp.getHeader(minChannelsParameterName)), true)));
    537 
    538       configureFileParameters.add(new PluginParameter<Integer>(
    539         maxChannelsParameterName,
     648        new IntegerParameterType(1, null, 2, true));
     649      parameters.add(minChannelsParameter);
     650     
     651      maxChannelsParameter = new PluginParameter<Integer>(
     652        "maxChannels",
    540653        "Max channels",
    541654        "Maximum number of channels. 0 for infinity",
    542         new IntegerParameterType(0, null, new Integer(ffp.getHeader(maxChannelsParameterName)), true)));
    543 
    544     }
    545     return configureFileParameters;
    546   }
    547 
    548   private List<PluginParameter<?>> getJobParameters()
     655        new IntegerParameterType(0, null, 0, true));
     656      parameters.add(maxChannelsParameter);
     657     
     658      configureManual = new RequestInformation(
     659        Base1PluginExecuter.COMMAND_MANUAL_CONFIG,
     660        "Parse configuration file",
     661        "These parameters are parsed from the configuration file",
     662        parameters);
     663    }
     664
     665    return configureManual;
     666  }
     667
     668 
     669  private RequestInformation getConfigureJobParameters()
    549670    throws IOException
    550671  {
    551     if (jobParameters != null)
    552     {
    553       return jobParameters;
    554     }
    555     jobParameters = new ArrayList<PluginParameter<?>>();
    556     File f = (File) configuration.getValue(fileParameter.getName());
    557     if (f == null || f.isRemoved())
    558     {
    559       throw new BaseException(getAbout().getName() + " needs a configfile to execute.");
    560     }
    561     DbControl dc = sc.newDbControl();
    562     BioAssaySet bas = (BioAssaySet) job.getValue(bioAssaySetParameter.getName());
    563     if (bas == null)
    564     {
    565       int id = sc.getCurrentContext(Item.BIOASSAYSET).getId();
    566       bas = BioAssaySet.getById(dc, id);
    567     }
    568     else
    569     {
    570       bas = BioAssaySet.getById(dc, bas.getId());
    571     }
    572     Experiment experiment = bas.getExperiment();
    573     FlatFileParser ffp = getInitializedFlatFileParser(f.getDownloadStream(0));
    574     ffp.setMinDataColumns(8);
    575 
    576     FlatFileParser.Line section = ffp.nextSection();
    577     while (section != null && !section.name().equals("plugin"))
    578     {
    579       section = ffp.nextSection();
    580     }
    581     ffp.parseHeaders();
    582     List<String> columns = Arrays.asList(ffp.getHeader("columns").split("\\t"));
    583     int valueTypeCol = columns.indexOf("valueType");
    584     int nameCol = columns.indexOf("name");
    585     int commonNameCol = columns.indexOf("commonName");
    586     int optionsCol = columns.indexOf("options");
    587     int defaultValueCol = columns.indexOf("defaultValue");
    588     int enumOptionsCol = columns.indexOf("enumOptions");
    589     int removedCol = columns.indexOf("removed");
    590 
    591     while (ffp.hasMoreData())
    592     {
    593       FlatFileParser.Data dataline = ffp.nextData();
    594       if (!Boolean.valueOf(dataline.get(removedCol)))
    595       {
    596         String name = dataline.get(nameCol);
    597         String commonName = dataline.get(commonNameCol);
    598         String options = dataline.get(optionsCol);
    599         String defaultValue = dataline.get(defaultValueCol);
    600         String enumOptions = dataline.get(enumOptionsCol);
    601 
    602         PluginParameter<?> parameter = null;
    603         switch (dataline.get(valueTypeCol).charAt(0))
    604         {
    605           // String parameter
    606           case 't':
    607           {
    608             StringParameterType type = new StringParameterType(255, defaultValue, false, 1, new Integer(options), 1);
    609             parameter = new PluginParameter<String>(name, commonName, "", type);
    610             jobParameters.add(parameter);
    611             break;
    612           }
    613           // Integer parameter
    614           case 'i':
    615           {
    616             Integer defValue = defaultValue == null ? null : new Integer(defaultValue);
    617             IntegerParameterType type = new IntegerParameterType(null, null, defValue, false, 1, new Integer(options), 1, null);
    618             parameter = new PluginParameter<Integer>(name, commonName, "", type);
    619             jobParameters.add(parameter);
    620             break;
    621           }
    622           // HiddenString parameter
    623           case 'h':
    624           {
    625             StringParameterType type = new StringParameterType(255, defaultValue, false, 1, 0, 1);
    626             parameter = new PluginParameter<String>(name, commonName, "", type);
    627             jobParameters.add(parameter);
    628             break;
    629           }
    630           // Float parameter
    631           case 'f':
    632           {
    633             Float defValue = defaultValue == null ? null : new Float(defaultValue);
    634             FloatParameterType type = new FloatParameterType(null, null, defValue, false, 1, new Integer(options), 1, null);
    635             parameter = new PluginParameter<Float>(name, commonName, "", type);
    636             jobParameters.add(parameter);
    637             break;
    638           }
    639           // TextField parameter
    640           case 'a':
    641           {
    642             String[] wh = options.split(",");
    643             StringParameterType type = new StringParameterType(
    644               null,
    645               defaultValue,
    646               false,
    647               1,
    648               new Integer(wh[0]),
    649               wh.length > 1 ? new Integer(wh[1]) : 1);
    650             parameter = new PluginParameter<String>(name, commonName, "", type);
    651             jobParameters.add(parameter);
    652             break;
    653           }
    654           // Annotation parameter
    655           case 'n':
    656           {
    657             List<AnnotationType> annotations = getAnnotationTypes(dc, bas);
    658             if (!annotations.isEmpty())
    659             {
    660               Enumeration<String, String> enums = new Enumeration<String, String>();
    661               for (AnnotationType at : annotations)
    662               {
    663                 enums.add(at.getName(), at.getName());
    664               }
    665               StringParameterType type = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums);
    666               parameter = new PluginParameter<String>(name, commonName, "", type);
    667               jobParameters.add(parameter);
    668             }
    669             break;
    670           }
    671           // Enum Parameter
    672           case 'e':
    673           {
    674             Enumeration<String, String> enums = new Enumeration<String, String>();
    675             String[] enumOptionsSplit = enumOptions.split("\\\\t");
    676             for (int i = 0; i < enumOptionsSplit.length; i += 2)
    677             {
    678               enums.add(enumOptionsSplit[i], enumOptionsSplit[i + 1]);
    679             }
    680             StringParameterType type = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums);
    681             parameter = new PluginParameter<String>(name, commonName, "", type);
    682             jobParameters.add(parameter);
    683             break;
    684           }
    685         }
    686       }
    687     }
    688 
    689     Directory homeDirectory = null;
    690     try
    691     {
    692       homeDirectory = experiment.getDirectory();
    693       if (!homeDirectory.hasPermission(Permission.WRITE)) homeDirectory = null;
    694     }
    695     catch (Throwable t)
    696     {}
    697     if (homeDirectory == null)
    698     {
    699       homeDirectory = User.getById(dc, sc.getLoggedInUserId()).getHomeDirectory();
    700     }
    701     if (homeDirectory == null)
    702     {
    703       homeDirectory = Directory.getById(dc, SystemItems.getId(Directory.ROOT));
    704     }
    705     sc.getLoggedInUserId();
    706     jobParameters.add(new PluginParameter<String>(
    707       "pluginDirectory",
    708       "Plugin directory",
    709       "The directory where a plugin can store its files.",
    710       new PathParameterType(Path.Type.DIRECTORY, homeDirectory.getPath() + "/" + PluginConfiguration.getById(
    711         dc,
    712         configuration.getId()).getName(), true)));
    713     dc.close();
    714 
    715     return jobParameters;
    716   }
    717 
     672    if (configureJob == null)
     673    {
     674      // Parameters for CONFIGURE_JOB
     675      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
     676      parameters.add(getSourceBioAssaySetParameter("Bioassay set", "The bioassay set that this plugin will run on"));
     677     
     678      parameters.addAll(getJobParameters());
     679      configureJob = new RequestInformation(
     680        Request.COMMAND_CONFIGURE_JOB,
     681        "Configure job",
     682        "Set the parameters needed for this plugin.",
     683        parameters);
     684    }
     685    return configureJob;
     686  }
     687 
     688 
    718689  private RequestInformation getConfigurePluginParameters()
    719690  {
     
    733704  }
    734705
    735   private RequestInformation getConfigureJobParameters()
     706 
     707  private java.io.File getExecDirectory()
     708  {
     709    if (execDirectory == null)
     710    {
     711      execDirectory = new java.io.File(
     712        System.getProperty("java.io.tmpdir") + java.io.File.separator + about.getName() + java.io.File.separator + job.getId());
     713      execDirectory.mkdirs();
     714    }
     715    return execDirectory;
     716  }
     717
     718 
     719  private FlatFileParser getInitializedFlatFileParser(InputStream stream)
     720    throws BaseException
     721  {
     722    FlatFileParser ffp = new FlatFileParser();
     723    ffp.setSectionRegexp(Pattern.compile("section\\t(.*)"));
     724    ffp.setHeaderRegexp(Pattern.compile("(.*?)\\t(.*)"));
     725    ffp.setDataHeaderRegexp(Pattern.compile("%"));
     726    ffp.setDataSplitterRegexp(Pattern.compile("\\t"));
     727
     728    ffp.setInputStream(stream, Config.getCharset());
     729    return ffp;
     730  }
     731 
     732 
     733  private List<PluginParameter<?>> getJobParameters()
    736734    throws IOException
    737735  {
    738     if (configureJob == null)
    739     {
    740       // Parameters for CONFIGURE_JOB
    741       List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
    742       parameters.add(bioAssaySetParameter);
    743       parameters.addAll(getJobParameters());
    744       configureJob = new RequestInformation(
    745         Request.COMMAND_CONFIGURE_JOB,
    746         "Configure job",
    747         "Set the parameters needed for this plugin.",
    748         parameters);
    749     }
    750     return configureJob;
    751   }
    752 
    753   private RequestInformation getConfigureFileParameters()
    754   {
    755     if (configureFile == null)
    756     {
    757       // Parameters for PARSE_CONFIG_FILE
    758 
    759       configureFile = new RequestInformation(
    760         Base1PluginExecuter.PARSE_CONFIG_FILE,
    761         "Parse configuration file",
    762         "These parameters are parsed from the configuration file",
    763         getConfigureParameters());
    764     }
    765 
    766     return configureFile;
    767   }
    768  
    769   private void importFiles(int transformationId)
    770   {
    771     if (!(Boolean) configuration.getValue(leaveStdinParameterName))
    772     {
    773       deleteFile("stdin.txt");
    774     }
    775     if (!(Boolean) configuration.getValue(leaveStdoutParameterName))
    776     {
    777       deleteFile("stdout.txt");
    778     }
    779     DbControl dc = sc.newDbControl();
    780     importTempFiles(dc, getExecDirectory().listFiles(), getPluginDirectory(dc));
    781     dc.commit();
     736    if (jobParameters != null)
     737    {
     738      return jobParameters;
     739    }
     740    jobParameters = new ArrayList<PluginParameter<?>>(); 
     741    DbControl dc = null;
    782742   
    783    
    784     dc = sc.newDbControl();
    785     Transformation t = Transformation.getById(dc, transformationId);
    786     for(File f : getPluginDirectory(dc).getFiles().list(dc))
    787     {
    788       AnyToAny ata = AnyToAny.getNew(dc, t, f, f.getPath().toString(), false);
    789       dc.saveItem(ata);
    790     }
    791     for(Directory d : getPluginDirectory(dc).getSubDirectories().list(dc))
    792     {
    793       AnyToAny ata = AnyToAny.getNew(dc, t, d, d.getPath().toString(), false);
    794       dc.saveItem(ata);
    795     }
    796     dc.commit();
    797   }
    798 
     743    try
     744    {
     745      dc = sc.newDbControl();
     746      AnyToAny ata = AnyToAny.getByName(dc, configuration.getPluginConfiguration(), "Configurationfile");
     747      if (ata == null)
     748      {
     749        throw new BaseException("The plugin needs a configuration file to find the job parameters");
     750      }
     751      File f = File.getById(dc, ata.getTo().getId());
     752      Experiment experiment = getCurrentBioAssaySet(dc).getExperiment();
     753      FlatFileParser ffp = getInitializedFlatFileParser(f.getDownloadStream(0));
     754      ffp.setMinDataColumns(8);
     755      FlatFileParser.Line section = ffp.nextSection();
     756      while (section != null && !section.name().equals("plugin"))
     757      {
     758        section = ffp.nextSection();
     759      }
     760      ffp.parseHeaders();
     761      List<String> columns = Arrays.asList(ffp.getHeader("columns").split("\\t"));
     762      int valueTypeCol = columns.indexOf("valueType");
     763      int nameCol = columns.indexOf("name");
     764      int commonNameCol = columns.indexOf("commonName");
     765      int optionsCol = columns.indexOf("options");
     766      int defaultValueCol = columns.indexOf("defaultValue");
     767      int enumOptionsCol = columns.indexOf("enumOptions");
     768      int removedCol = columns.indexOf("removed");
     769      while (ffp.hasMoreData())
     770      {
     771        FlatFileParser.Data dataline = ffp.nextData();
     772        if (!Boolean.valueOf(dataline.get(removedCol)))
     773        {
     774          String name = dataline.get(nameCol);
     775          String commonName = dataline.get(commonNameCol);
     776          String options = dataline.get(optionsCol);
     777          String defaultValue = dataline.get(defaultValueCol);
     778          String enumOptions = dataline.get(enumOptionsCol);
     779
     780          PluginParameter<?> parameter = null;
     781          switch (dataline.get(valueTypeCol).charAt(0))
     782          {
     783            // String parameter
     784            case 't':
     785            {
     786              StringParameterType type = new StringParameterType(255, defaultValue, false, 1, new Integer(options), 1);
     787              parameter = new PluginParameter<String>(name, commonName, "", type);
     788              jobParameters.add(parameter);
     789              break;
     790            }
     791              // Integer parameter
     792            case 'i':
     793            {
     794              Integer defValue = defaultValue == null ? null : new Integer(defaultValue);
     795              IntegerParameterType type = new IntegerParameterType(null, null, defValue, false, 1, new Integer(options), 1, null);
     796              parameter = new PluginParameter<Integer>(name, commonName, "", type);
     797              jobParameters.add(parameter);
     798              break;
     799            }
     800              // HiddenString parameter
     801            case 'h':
     802            {
     803              StringParameterType type = new StringParameterType(255, defaultValue, false, 1, 0, 1);
     804              parameter = new PluginParameter<String>(name, null, "", type);
     805              jobParameters.add(parameter);
     806              break;
     807            }
     808              // Float parameter
     809            case 'f':
     810            {
     811              Float defValue = defaultValue == null ? null : new Float(defaultValue);
     812              FloatParameterType type = new FloatParameterType(null, null, defValue, false, 1, new Integer(options), 1, null);
     813              parameter = new PluginParameter<Float>(name, commonName, "", type);
     814              jobParameters.add(parameter);
     815              break;
     816            }
     817              // TextField parameter
     818            case 'a':
     819            {
     820              String[] wh = options.split(",");
     821              StringParameterType type = new StringParameterType(
     822                null,
     823                defaultValue,
     824                false,
     825                1,
     826                new Integer(wh[0]),
     827                wh.length > 1 ? new Integer(wh[1]) : 1);
     828              parameter = new PluginParameter<String>(name, commonName, "", type);
     829              jobParameters.add(parameter);
     830              break;
     831            }
     832              // Annotation parameter
     833            case 'n':
     834            {
     835              List<AnnotationType> annotations = getAnnotationTypes(dc, experiment);
     836              if (!annotations.isEmpty())
     837              {
     838                Enumeration<String, String> enums = new Enumeration<String, String>();
     839                for (AnnotationType at : annotations)
     840                {
     841                  enums.add(at.getName(), at.getName());
     842                }
     843                StringParameterType type = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums);
     844                parameter = new PluginParameter<String>(name, commonName, "", type);
     845                jobParameters.add(parameter);
     846              }
     847              break;
     848            }
     849              // Enum Parameter
     850            case 'e':
     851            {
     852              Enumeration<String, String> enums = new Enumeration<String, String>();
     853              String[] enumOptionsSplit = enumOptions.split("\\\\t");
     854              for (int i = 0; i < enumOptionsSplit.length; i += 2)
     855              {
     856                enums.add(enumOptionsSplit[i], enumOptionsSplit[i + 1]);
     857              }
     858              StringParameterType type = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums);
     859              parameter = new PluginParameter<String>(name, commonName, "", type);
     860              jobParameters.add(parameter);
     861              break;
     862            }
     863          }
     864        }
     865      }
     866      String homeDirectoryPath = "";
     867      Directory homeDirectory = experiment.getDirectory();
     868      if (homeDirectory == null)
     869      {
     870        homeDirectoryPath = homeDirectory.getPath() + "/" + PluginConfiguration.getById(dc, configuration.getId()).getName();
     871      }
     872      pluginDirectoryParameter = new PluginParameter<String>(
     873        "pluginDirectory",
     874        "Plugin directory",
     875        "The directory where a plugin can store its files.",
     876        new PathParameterType(Path.Type.DIRECTORY, homeDirectoryPath, true));
     877      jobParameters.add(pluginDirectoryParameter);
     878    }
     879    finally
     880    {
     881      dc.close();
     882    }   
     883
     884    return jobParameters;
     885  }
     886 
     887
     888  private Path getPluginDirectoryPath()
     889  {
     890    Path p = new Path((String) job.getValue(pluginDirectoryParameter.getName()) + "/" + job.getId(), Path.Type.DIRECTORY);
     891    return p;
     892  }
     893 
     894 
    799895  private int importData()
    800896    throws IOException
     
    804900
    805901    Job jobitem = Job.getById(dc, job.getId());
    806     BioAssaySet parentBas = (BioAssaySet) job.getValue(bioAssaySetParameter.getName());
    807     parentBas = BioAssaySet.getById(dc, parentBas.getId());
     902    BioAssaySet parentBas = getSourceBioAssaySet(dc);
    808903    Transformation t = parentBas.newTransformation(jobitem);
    809     t.setName("Something---");
     904    t.setName(getTransformationName(dc));
    810905    dc.saveItem(t);
    811906   
    812907    BioAssaySet bas = null;
    813908    SpotBatcher spotBatcher = null;
    814 //    PositionBatcher posBatcher = null;
    815909
    816910    HashMap<String, BioAssay> idMap = new HashMap<String, BioAssay>();
     
    827921      {
    828922        bas = t.newProduct("new", "new", false);
    829         bas.setName("Something after");
    830 //        dc.saveItem(bas);
     923        bas.setName(getSourceBioAssaySet(dc).getName());
    831924
    832925        List<String> columns = Arrays.asList(ffp.getHeader("columns").split("\\t"));
     
    866959          BioAssay ba = bas.newBioAssay(baParents);
    867960          ba.setName(name);
    868 //          dc.saveItem(ba);
    869961          idMap.put(id, ba);
    870962          dataline = ffp.nextData();
     
    882974          bas = t.newProduct(null, "new", false);
    883975          bas.setName("Something after");
    884 //          dc.saveItem(bas);
    885         }
    886         else
    887         {
    888 //          posBatcher = bas.getPositionBatcher();
    889976        }
    890977        spotBatcher = bas.getSpotBatcher();
     
    898985              BioAssay parent = BioAssay.getById(dc, Integer.parseInt(assayId));
    899986              BioAssay ba = bas.newBioAssay(parent);
    900 //              dc.saveItem(ba);
    901987              idMap.put(assayId, ba);
    902988            }
     
    10451131                  {}
    10461132                }
    1047 //                if (posBatcher != null)
    1048 //                {
    1049 //                  if (reporter != null)
    1050 //                  {
    1051 //                    posBatcher.insert(position, Reporter.getById(dc, reporter));
    1052 //                  }
    1053 //                  else
    1054 //                  {
    1055 //                    posBatcher.insert(position, null);
    1056 //                  }
    1057 //                }
    10581133              }
    10591134              index += assayFields.size();
     
    10771152    return t.getId();
    10781153  }
    1079 
    1080   private void exportData()
    1081     throws IOException, SQLException
    1082   {
    1083     if ((Boolean) configuration.getValue(geneAveragesParameterName))
    1084     {
    1085       throw new BaseException(geneAveragesParameterName + " isnt implemented yet.");
    1086     }
    1087     DbControl dc = sc.newDbControl();
    1088     PrintWriter out = new PrintWriter(new java.io.File(getExecDirectory(), "stdin.txt"));
    1089     BioAssaySet bas = (BioAssaySet) job.getValue(bioAssaySetParameter.getName());
    1090     bas = BioAssaySet.getById(dc, bas.getId());
    1091     getBase1Columns();
    1092 
    1093     // Print parameters
    1094     out.println("BASEfile");
    1095     for (PluginParameter<?> p : getJobParameters())
    1096     {
    1097       Object value = job.getValue(p.getName()) == null ? "" : job.getValue(p.getName());
    1098       out.println(p.getName() + "\t" + value);
    1099     }
    1100     out.println("pluginVersion\t" + job.getValue(versionNumberParameterName));
    1101     out.println("%");
    1102     out.println();
    1103 
    1104     // Print assays
    1105     // Collect annotations
    1106     List<AnnotationType> annotations = getAnnotationTypes(dc, bas);
    1107     String annotationString = "";
    1108     for (AnnotationType at : annotations)
    1109     {
    1110       annotationString += "\t" + at.getName();
    1111     }
    1112     out.println("section\tassays");
    1113     out.println("count\t" + bas.getBioAssays().count(dc));
    1114     out.println("columns\tid\tname" + annotationString);
    1115     out.println("annotationColumns" + annotationString);
    1116     out.println("%");
    1117     for (BioAssay ba : bas.getBioAssays().list(dc))
    1118     {
    1119       out.print(ba.getId() + "\t" + ba.getName());
    1120       for (AnnotationType at : annotations)
    1121       {
    1122         out.print("\t");
    1123         BioAssaySetUtil.getAnnotationValues(dc, ba, at);
    1124         Set<?> v = BioAssaySetUtil.getAnnotationValues(dc, ba, at);
    1125         if (!v.isEmpty())
    1126         {
    1127           out.print(v.iterator().next());
    1128         }
    1129       }
    1130       out.println();
    1131     }
    1132     out.println();
    1133 
    1134     // Print spots
    1135     List<String> columns = new ArrayList<String>(
    1136       Arrays.asList(((String) configuration.getValue(usedColumnsParameterName)).split("\\\\t")));
    1137     List<String> fields = new ArrayList<String>(
    1138       Arrays.asList(((String) configuration.getValue(usedFieldsParameterName)).split("\\\\t")));
    1139     columns.retainAll(base1columns.keySet());
    1140     fields.retainAll(base1columns.keySet());
    1141    
    1142     String fieldString = fields.toString().substring(1, fields.toString().length() - 1).replace(", ", "\t");
    1143     String columnString = columns.toString().substring(1, columns.toString().length() - 1).replace(", ", "\t") + "\tassayData";
    1144     String spotHeader = "section\tspots" + "\nchannels\t" + bas.getRawDataType().getChannels() + "\nassayFields\t" + fieldString + "\ncolumns\t" + columnString;
    1145     if (configuration.getValue(serialFormatParameterName).equals("1"))
    1146     {
    1147       for (BioAssay ba : bas.getBioAssays().list(dc))
    1148       {
    1149         out.println(spotHeader);
    1150         out.println("assays\t" + ba.getId());
    1151         out.println("count\t" + ba.getNumSpots());
    1152         out.println("%");
    1153 
    1154         List<Integer> columnIndex = new ArrayList<Integer>(columns.size());
    1155         List<Integer> fieldIndex = new ArrayList<Integer>(fields.size());
    1156         DynamicSpotQuery q = createSpotQuery(ba.getSpotData(), columns, fields);
    1157         DynamicResultIterator result = q.iterate(dc);
    1158        
    1159         for (String column : columns)
    1160         {
    1161           columnIndex.add(result.getIndex(column));
    1162         }
    1163         for (String field : fields)
    1164         {
    1165           fieldIndex.add(result.getIndex(field));
    1166         }
    1167 
    1168         while (result.hasNext())
    1169         {
    1170           SqlResult r = result.next();
    1171           boolean del = false;
    1172           for (Integer column : columnIndex)
    1173           {
    1174             if (del)
    1175             {
    1176               out.print("\t");
    1177             }
    1178             out.print(r.getString(column) != null ? r.getString(column) : "");
    1179             del = true;
    1180           }
    1181           for (Integer field : fieldIndex)
    1182           {
    1183             out.print("\t");
    1184             out.print(r.getString(field) != null ? r.getString(field) : "");
    1185           }
    1186           out.print("\n");
    1187         }
    1188         out.println();
    1189       }
    1190     }
    1191     else
    1192     {
    1193       ItemQuery<BioAssay> assayQuery = bas.getBioAssays();
    1194       assayQuery.order(Orders.asc(Hql.property("dataCubeColumn.columnNo")));
    1195      
    1196       ArrayList<Short> columnNo = new ArrayList<Short>((int) assayQuery.count(dc));
    1197      
    1198       out.println(spotHeader);
    1199       out.print("assays");
    1200       for (BioAssay ba : assayQuery.list(dc))
    1201       {
    1202         out.print("\t" + ba.getId());
    1203         columnNo.add(ba.getDataCubeColumnNo());
    1204       }
    1205       out.println("\ncount\t" + bas.getNumSpots());
    1206       out.print("%");
    1207 
    1208       List<Integer> columnIndex = new ArrayList<Integer>(columns.size());
    1209       List<Integer> fieldIndex = new ArrayList<Integer>(fields.size());
    1210       DynamicSpotQuery q = createSpotQuery(bas.getSpotData(), columns, fields);
    1211       q.select(Selects.expression(Dynamic.column(VirtualColumn.COLUMN), "column"));
    1212       q.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION)));
    1213       q.order(Orders.asc(Dynamic.column(VirtualColumn.COLUMN)));
    1214       DynamicResultIterator result = q.iterate(dc);
    1215      
    1216 
    1217       for (String column : columns)
    1218       {
    1219         columnIndex.add(result.getIndex(column));
    1220       }
    1221       for (String field : fields)
    1222       {
    1223         fieldIndex.add(result.getIndex(field));
    1224       }
    1225       int columnNoIndex = result.getIndex("column");
    1226       int positionIndex = result.getIndex("position");
    1227      
    1228      
    1229       int i = Integer.MAX_VALUE;
    1230       int prevPos = Integer.MAX_VALUE;
    1231       while (result.hasNext())
    1232       {
    1233         SqlResult r = result.next();
    1234        
    1235         if (prevPos != r.getInt(positionIndex) || i > columnNo.size())
    1236         {
    1237           if (i < columnNo.size())
    1238           {
    1239             out.print(getString(getString("\t", fieldIndex.size()), columnNo.size() - i));
    1240           }
    1241           i = 0;
    1242           out.println();
    1243         }
    1244        
    1245         if (i == 0)
    1246         {
    1247           boolean del = false;
    1248           for (Integer column : columnIndex)
    1249           {
    1250             if (del)
    1251             {
    1252               out.print("\t");
    1253             }
    1254             out.print(r.getString(column) != null ? r.getString(column) : "");
    1255             del = true;
    1256           }
    1257         }
    1258        
    1259         while (i < columnNo.size() && columnNo.get(i) != r.getShort(columnNoIndex))
    1260         {
    1261           out.print(getString("\t", fieldIndex.size()));
    1262           i++;
    1263         }
    1264 
    1265         for (Integer field : fieldIndex)
    1266         {
    1267           out.print("\t");
    1268           out.print(r.getString(field) != null ? r.getString(field) : "");
    1269         }
    1270         i++;
    1271        
    1272         prevPos = r.getInt(positionIndex);
    1273       }
    1274     }
    1275     out.close();
    1276     dc.close();
    1277   }
    1278 
    1279   private Map<String, Select> getBase1Columns()
    1280   {
    1281     if (base1columns == null)
    1282     {
    1283       base1columns = new HashMap<String, Select>();
    1284 
    1285       // Reporter fields
    1286       base1columns.put("accession", Selects.expression(Dynamic.reporter("accession"), "accession"));
    1287       base1columns.put("antibiotics", Selects.expression(Dynamic.reporter("antibiotics"), "antibiotics"));
    1288       base1columns.put("chromosome", Selects.expression(Dynamic.reporter("chromosome"), "chromosome"));
    1289       base1columns.put("clusterId", Selects.expression(Dynamic.reporter("clusterId"), "clusterId"));
    1290       base1columns.put("cytoBand", Selects.expression(Dynamic.reporter("cytoband"), "cytoBand"));
    1291       base1columns.put("length", Selects.expression(Dynamic.reporter("length"), "length"));
    1292       base1columns.put("library", Selects.expression(Dynamic.reporter("library"), "library"));
    1293       base1columns.put("locusLink", Selects.expression(Dynamic.reporter("locusLink"), "locusLink"));
    1294       base1columns.put("markers", Selects.expression(Dynamic.reporter("markers"), "markers"));
    1295       base1columns.put("nid", Selects.expression(Dynamic.reporter("nid"), "nid"));
    1296       base1columns.put("omim", Selects.expression(Dynamic.reporter("omim"), "omim"));
    1297       base1columns.put("reporter", Selects.expression(Dynamic.reporter("id"), "reporter"));
    1298       base1columns.put("reporterId", Selects.expression(Dynamic.reporter("externalId"), "reporterId"));
    1299       base1columns.put("sequence", Selects.expression(Dynamic.reporter("sequence"), "sequence"));
    1300       base1columns.put("species", Selects.expression(Dynamic.reporter("species"), "species"));
    1301       base1columns.put("tissue", Selects.expression(Dynamic.reporter("tissue"), "tissue"));
    1302       base1columns.put("vector", Selects.expression(Dynamic.reporter("vector"), "vector"));
    1303 
    1304       // Spot fields
    1305       base1columns.put("position", Selects.expression(Dynamic.column(VirtualColumn.POSITION), "position"));
    1306       base1columns.put("intensity1", Selects.expression(Dynamic.column(VirtualColumn.channel(1)), "intensity1"));
    1307       base1columns.put("intensity2", Selects.expression(Dynamic.column(VirtualColumn.channel(2)), "intensity2"));
    1308       base1columns.put("l10intgmean1_2", Selects.expression(Expressions.log10(Expressions.sqrt(Expressions.multiply(
    1309         Dynamic.column(VirtualColumn.channel(1)),
    1310         Dynamic.column(VirtualColumn.channel(2))))), "l10intgmean1_2"));
    1311       base1columns.put("l2intsum1_2", Selects.expression(Expressions.log2(Expressions.sqrt(Expressions.add(
    1312         Dynamic.column(VirtualColumn.channel(1)),
    1313         Dynamic.column(VirtualColumn.channel(2))))), "l2intsum1_2"));
    1314       base1columns.put("l2ratio1_2", Selects.expression(Expressions.log2(Expressions.divide(
    1315         Dynamic.column(VirtualColumn.channel(1)),
    1316         Dynamic.column(VirtualColumn.channel(2)))), "l2ratio1_2"));
    1317       base1columns.put("maxint1_2", Selects.expression(Expressions.caseWhen(
    1318         Dynamic.column(VirtualColumn.channel(1)),
    1319         new WhenStatement(
    1320           Restrictions.lt(Dynamic.column(VirtualColumn.channel(1)), Dynamic.column(VirtualColumn.channel(2))),
    1321           Dynamic.column(VirtualColumn.channel(2)))), "maxint1_2"));
    1322       base1columns.put("minint1_2", Selects.expression(Expressions.caseWhen(
    1323         Dynamic.column(VirtualColumn.channel(1)),
    1324         new WhenStatement(
    1325           Restrictions.gt(Dynamic.column(VirtualColumn.channel(1)), Dynamic.column(VirtualColumn.channel(2))),
    1326           Dynamic.column(VirtualColumn.channel(2)))), "minint1_2"));
    1327       base1columns.put("ratio1_2", Selects.expression(Expressions.divide(
    1328         Dynamic.column(VirtualColumn.channel(1)),
    1329         Dynamic.column(VirtualColumn.channel(2))), "ratio1_2"));
    1330 
    1331       // Rawdata fields
    1332       base1columns.put("BCh1Mean", Selects.expression(Dynamic.rawData("ch1BgMean"), "BCh1Mean"));
    1333       base1columns.put("BCh1Median", Selects.expression(Dynamic.rawData("ch1BgMedian"), "BCh1Median"));
    1334       base1columns.put("BCh1SD", Selects.expression(Dynamic.rawData("ch1BgSd"), "BCh1SD"));
    1335       base1columns.put("BCh2Mean", Selects.expression(Dynamic.rawData("ch2BgMean"), "BCh2Mean"));
    1336       base1columns.put("BCh2Median", Selects.expression(Dynamic.rawData("ch2BgMedian"), "BCh2Median"));
    1337       base1columns.put("BCh2SD", Selects.expression(Dynamic.rawData("ch2BgSd"), "BCh2SD"));
    1338       base1columns.put("block", Selects.expression(Dynamic.rawData("block"), "block"));
    1339       base1columns.put("BPixels", Selects.expression(Dynamic.rawData("bgPixels"), "BPixels"));
    1340       base1columns.put("CV", Selects.expression(Dynamic.rawData("CV"), "CV"));
    1341       base1columns.put("dia", Selects.expression(Dynamic.rawData("diameter"), "dia"));
    1342       base1columns.put("FCh1Mean", Selects.expression(Dynamic.rawData("ch1FgMean"), "FCh1Mean"));
    1343       base1columns.put("FCh1Median", Selects.expression(Dynamic.rawData("ch1FgMedian"), "FCh1Mean"));
    1344       base1columns.put("FCh1SD", Selects.expression(Dynamic.rawData("ch1FgSd"), "FCh1SD"));
    1345       base1columns.put("FCh2Mean", Selects.expression(Dynamic.rawData("ch2FgMean"), "FCh2Mean"));
    1346       base1columns.put("FCh2Median", Selects.expression(Dynamic.rawData("ch2FgMedian"), "FCh2Median"));
    1347       base1columns.put("FCh2SD", Selects.expression(Dynamic.rawData("ch2FgSd"), "FCh2SD"));
    1348       base1columns.put("flags", Selects.expression(Dynamic.rawData("flags"), "flags"));
    1349       base1columns.put("FPixels", Selects.expression(Dynamic.rawData("fgPixels"), "FPixels"));
    1350       base1columns.put("MValue", Selects.expression(Dynamic.rawData("mValue"), "MValue"));
    1351       base1columns.put("percCh1Sat", Selects.expression(Dynamic.rawData("ch1PercSat"), "percCh1Sat"));
    1352       base1columns.put("percCh1SD1", Selects.expression(Dynamic.rawData("ch1PercSD1"), "percCh1SD1"));
    1353       base1columns.put("percCh1SD2", Selects.expression(Dynamic.rawData("ch1PercSD2"), "percCh1SD1"));
    1354       base1columns.put("percCh2Sat", Selects.expression(Dynamic.rawData("ch2PercSat"), "percCh2Sat"));
    1355       base1columns.put("percCh2SD1", Selects.expression(Dynamic.rawData("ch2PercSD1"), "percCh2SD1"));
    1356       base1columns.put("percCh2SD2", Selects.expression(Dynamic.rawData("ch2PercSD2"), "percCh2SD2"));
    1357       base1columns.put("ratiosSD", Selects.expression(Dynamic.rawData("ratiosSd"), "ratiosSD"));
    1358       base1columns.put("rgnR2", Selects.expression(Dynamic.rawData("rgnR2"), "rgnR2"));
    1359       base1columns.put("rgnRatio", Selects.expression(Dynamic.rawData("rgnRatio"), "rgnRatio"));
    1360       base1columns.put("numCol", Selects.expression(Dynamic.rawData("metaGridX"), "numCol"));
    1361       base1columns.put("numRow", Selects.expression(Dynamic.rawData("metaGridY"), "numRow"));
    1362       base1columns.put("x", Selects.expression(Dynamic.rawData("x"), "x"));
    1363       base1columns.put("y", Selects.expression(Dynamic.rawData("y"), "y"));
    1364       base1columns.put("rawPosition", Selects.expression(Dynamic.rawData("position"), "rawPosition"));
    1365 
    1366       base1columns.put("SNRCh1Mean", Selects.expression(
    1367         Expressions.divide(Expressions.subtract(
    1368           Expressions.selected(Dynamic.selectRawData("ch1FgMean")),
    1369           Expressions.selected(Dynamic.selectRawData("ch1BgMean"))), Expressions.selected(Dynamic.selectRawData("ch1BgSd"))),
    1370         "SNRCh1Mean"));
    1371       base1columns.put("SNRCh1Median", Selects.expression(
    1372         Expressions.divide(Expressions.subtract(
    1373           Expressions.selected(Dynamic.selectRawData("ch1FgMedian")),
    1374           Expressions.selected(Dynamic.selectRawData("ch1BgMedian"))), Expressions.selected(Dynamic.selectRawData("ch1BgSd"))),
    1375         "SNRCh1Median"));
    1376       base1columns.put("SNRCh2Mean", Selects.expression(
    1377         Expressions.divide(Expressions.subtract(
    1378           Expressions.selected(Dynamic.selectRawData("ch2FgMean")),
    1379           Expressions.selected(Dynamic.selectRawData("ch2BgMean"))), Expressions.selected(Dynamic.selectRawData("ch2BgSd"))),
    1380         "SNRCh2Mean"));
    1381       base1columns.put("SNRCh2Median", Selects.expression(
    1382         Expressions.divide(Expressions.subtract(
    1383           Expressions.selected(Dynamic.selectRawData("ch2FgMedian")),
    1384           Expressions.selected(Dynamic.selectRawData("ch2BgMedian"))), Expressions.selected(Dynamic.selectRawData("ch2BgSd"))),
    1385         "SNRCh2Median"));
    1386 
    1387       /*
    1388        * CCh1Mean CCh1Median CCh2Mean CCh2Median MeanRatio MedianRatio
    1389        */
    1390 
    1391     }
    1392     return base1columns;
    1393 
    1394   }
    1395 
    1396   private DynamicSpotQuery createSpotQuery(DynamicSpotQuery query, List<String> columns, List<String> fields)
    1397   {
    1398     query.joinRawData(JoinType.LEFT);
    1399     query.joinReporters(JoinType.LEFT);
    1400     for (String s : columns)
    1401     {
    1402       Select select = base1columns.get(s);
    1403       query.select(select);
    1404     }
    1405 
    1406     for (String s : fields)
    1407     {
    1408       Select select = base1columns.get(s);
    1409       query.select(select);
    1410     }
    1411 
    1412     return query;
    1413   }
    1414 
    1415   private java.io.File getExecDirectory()
    1416   {
    1417     if (execDirectory == null)
    1418     {
    1419       execDirectory = new java.io.File(
    1420         System.getProperty("java.io.tmpdir") + java.io.File.separator + about.getName() + java.io.File.separator + job.getId());
    1421       execDirectory.mkdirs();
    1422     }
    1423     return execDirectory;
    1424   }
     1154 
     1155
     1156  private void importFiles(int transformationId)
     1157  {
     1158    DbControl dc = null;
     1159    try
     1160    {
     1161      dc = sc.newDbControl();
     1162      Directory homeDirectory = Directory.getByPath(dc, getPluginDirectoryPath());
     1163      importTempFiles(dc, getExecDirectory().listFiles(), homeDirectory);
     1164      dc.commit();
     1165      dc.close();
     1166     
     1167      dc = sc.newDbControl();
     1168      Transformation t = Transformation.getById(dc, transformationId);
     1169      for(File f : homeDirectory.getFiles().list(dc))
     1170      {
     1171        AnyToAny ata = AnyToAny.getNew(dc, t, f, f.getPath().toString(), false);
     1172        dc.saveItem(ata);
     1173      }
     1174      for(Directory d : homeDirectory.getSubDirectories().list(dc))
     1175      {
     1176        AnyToAny ata = AnyToAny.getNew(dc, t, d, d.getPath().toString(), false);
     1177        dc.saveItem(ata);
     1178      }
     1179      dc.commit();
     1180    }
     1181    finally
     1182    {
     1183      if (dc != null)
     1184      {
     1185        dc.close();
     1186      }
     1187    }
     1188  }
     1189
    14251190
    14261191  private void importTempFiles(DbControl dc, java.io.File[] files, Directory d)
     
    14561221    }
    14571222  }
    1458 
    1459   private Directory getPluginDirectory(DbControl dc)
    1460   {
    1461     if (pluginDirectory == null)
    1462     {
    1463       Path p = new Path((String) job.getValue(pluginDirectoryParameterName) + "/" + job.getId(), Path.Type.DIRECTORY);
    1464       try
    1465       {
    1466         int id = Directory.getIdFromPath(dc, p);
    1467         pluginDirectory = Directory.getById(dc, id);
    1468       }
    1469       catch (ItemNotFoundException e)
    1470       {
    1471         pluginDirectory = Directory.getNew(dc, p);
    1472         dc.saveItem(pluginDirectory);
    1473       }
    1474     }
    1475     return pluginDirectory;
    1476   }
    1477 
    1478   public List<AnnotationType> getAnnotationTypes(DbControl dc, BioAssaySet bas)
    1479   {
    1480     ItemQuery<AnnotationType> query = bas.getExperiment().getExperimentalFactors();
    1481     query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
    1482     query.order(Orders.asc(Hql.property("name")));
    1483     return query.list(dc);
    1484   }
    1485 
    1486   private void deleteFile(String name)
    1487   {
    1488     java.io.File file = new java.io.File(getExecDirectory(), name);
    1489     if (file.exists())
    1490     {
    1491       file.delete();
    1492     }
    1493   }
    1494  
    1495   private String getString(String s, int n)
    1496   {
    1497     StringBuffer sb = new StringBuffer(s.length() * n);
    1498     for (int i = 0; i < n; i++)
    1499     {
    1500       sb.append(s);
    1501     }
    1502     return sb.toString();
    1503   }
    15041223   
    15051224 
     
    15361255  }
    15371256
     1257
    15381258  private class PosRep
    15391259  {
     
    15721292      return false;
    15731293    }
    1574 
     1294   
    15751295    @Override
    15761296    public int hashCode()
     
    15781298      return getPosition();
    15791299    }
    1580    
    1581    
    15821300  }
    15831301}
Note: See TracChangeset for help on using the changeset viewer.