Changeset 3541


Ignore:
Timestamp:
Jun 29, 2007, 4:46:10 PM (16 years ago)
Author:
Johan Enell
Message:

Fixes #661, #662

Location:
branches/2.3.2/src/plugins/core/net/sf/basedb/plugins
Files:
2 edited

Legend:

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

    r3538 r3541  
    9090import java.net.URL;
    9191import java.sql.SQLException;
     92import java.util.AbstractSet;
    9293import java.util.ArrayList;
    9394import java.util.Arrays;
    9495import java.util.Collection;
    9596import java.util.Collections;
    96 import java.util.Comparator;
    9797import java.util.EnumSet;
    9898import java.util.HashMap;
     
    745745      Boolean mergeReporters = (Boolean) configuration.getValue(geneAveragesParameter.getName());
    746746     
    747       TreeMap<String, String> parameters = new TreeMap<String, String>(new Comparator<String>()
    748       {
    749         /**
    750          * To make the keys orderd by the same order they are added
    751          */
    752         public int compare(String o1, String o2)
    753         {
    754           return 1;
    755         }
    756       });
     747      ListMap<String, String> parameters = new ListMap<String, String>();
    757748      for (PluginParameter<?> pp : getJobParametersFromXML(String.valueOf(configuration.getValue(jobParametersParameter.getName()))))
    758749      {
    759         if (pp != null)
    760         {
    761           String name = pp.getName();
    762           Object value = job.getValue(name);
    763           parameters.put(name, value == null ? "" : value.toString());
    764         }
     750        String name = pp.getName();
     751        Object value = job.getValue(name);
     752        parameters.put(name, value == null ? "" : value.toString());
    765753      }
    766754     
     
    18251813    }
    18261814  }
     1815 
     1816  private class ListMap<K, V> extends java.util.AbstractMap<K, V>
     1817  {
     1818    private List<K> keys = new ArrayList<K>();
     1819    private List<V> values = new ArrayList<V>();
     1820
     1821    @Override
     1822    public Set<java.util.Map.Entry<K, V>> entrySet()
     1823    {
     1824      throw new UnsupportedOperationException();
     1825    }
     1826
     1827    @Override
     1828    public V put(K key, V value)
     1829    {
     1830      V ret = null;
     1831      int index = keys.indexOf(key);
     1832      if (index == -1)
     1833      {
     1834        keys.add(key);
     1835        values.add(value);
     1836      }
     1837      else
     1838      {
     1839        keys.set(index, key);
     1840        ret = values.set(index, value);
     1841      }
     1842      return ret;
     1843    }
     1844
     1845    @Override
     1846    public V get(Object key)
     1847    {
     1848      if (key == null) throw new NullPointerException();
     1849      int index = keys.indexOf(key);
     1850      V ret = null;
     1851      if (index != -1)
     1852      {
     1853        ret = values.get(index);
     1854      }
     1855      return ret;
     1856    }
     1857
     1858    @Override
     1859    public boolean isEmpty()
     1860    {
     1861      return keys.isEmpty();
     1862    }
     1863
     1864    @Override
     1865    public Set<K> keySet()
     1866    {
     1867      return new AbstractSet<K>()
     1868      {
     1869        @Override
     1870        public Iterator<K> iterator()
     1871        {
     1872          return Collections.unmodifiableList(keys).iterator();
     1873        }
     1874
     1875        @Override
     1876        public int size()
     1877        {
     1878          return keys.size();
     1879        }
     1880      };
     1881    }
     1882   
     1883  }
    18271884
    18281885  private enum Base1JobParameterType
  • branches/2.3.2/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java

    r3470 r3541  
    246246  }
    247247 
    248  
    249248  private void exportBaseFileSectionAssays(PrintWriter out, DbControl dc, BioAssaySet bas)
    250249  {
     
    273272  }
    274273 
    275  
    276274  private void exportBaseFileSectionHead(PrintWriter out, Map<String, String> parameters)
    277275  {
    278276    out.println("BASEfile");
     277   
    279278    if (!parameters.isEmpty())
    280279    {
    281       Set<String> keys = new HashSet<String>(parameters.keySet());
    282       if (keys.remove("section"))
     280      List<String> keys = new ArrayList<String>(parameters.keySet());
     281      if ("section".equals(keys.get(0)))
    283282      {
    284283        out.println("section\t"+parameters.get("section"));
     284        keys = keys.subList(1, keys.size());
     285      }
     286      if (keys.contains("section"))
     287      {
     288        throw new BaseException("The parameters can't have a parameter 'section' in the middle of the list.");
    285289      }
    286290      for (String key : keys)
     
    872876
    873877
     878  @Override
    874879  public Plugin.MainType getMainType()
    875880  {
     
    938943  private DbControl dc;
    939944  private BioAssaySet bas;
     945  @Override
    940946  protected void begin(DbControl dc)
    941947  {
     
    943949  }
    944950 
     951  @Override
    945952  @SuppressWarnings("unchecked")
    946953  protected void performExport(ExportOutputStream out, ProgressReporter progress)
     
    9951002  }
    9961003 
     1004  @Override
    9971005  protected void end(boolean success)
    9981006  {
    9991007    this.dc = null;
    10001008  }
     1009 
     1010  @Override
    10011011  protected String getSuccessMessage()
    10021012  {
    10031013    return "Bioassay set '" + bas.getName() + "' exported successfully";
    10041014  }
    1005 
    10061015 
    10071016  @Override
Note: See TracChangeset for help on using the changeset viewer.