Changeset 3545


Ignore:
Timestamp:
Jul 2, 2007, 3:45:01 PM (16 years ago)
Author:
Johan Enell
Message:

Merged log:branches/2.3.2#3537:3542 to trunk.

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

Legend:

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

    r3505 r3545  
    9393import java.net.URL;
    9494import java.sql.SQLException;
     95import java.util.AbstractSet;
    9596import java.util.ArrayList;
    9697import java.util.Arrays;
     
    104105import java.util.Map;
    105106import java.util.Set;
     107import java.util.TreeMap;
    106108import java.util.regex.Matcher;
    107109import java.util.regex.Pattern;
     
    744746      Boolean mergeReporters = (Boolean) configuration.getValue(geneAveragesParameter.getName());
    745747     
    746       Map<String, String> parameters = new HashMap<String, String>();
     748      ListMap<String, String> parameters = new ListMap<String, String>();
    747749      for (PluginParameter<?> pp : getJobParametersFromXML(String.valueOf(configuration.getValue(jobParametersParameter.getName()))))
    748750      {
     
    908910    try
    909911    {
    910       List<PluginParameter<?>> p = new ArrayList<PluginParameter<?>>();
    911912      String doctype = "<!DOCTYPE jobparameters SYSTEM \"base1-plugin-configuration-file.dtd\">";
    912913      Document doc = XMLUtil.getValidatedXml(doctype+xml, dtdFile);
     
    923924        }
    924925      });
     926     
     927      TreeMap<Integer, PluginParameter<?>> positionParameter = new TreeMap<Integer, PluginParameter<?>>();
    925928      while (it.hasNext())
    926929      {
    927930        Element e = it.next();
    928931        JobParameter jp = new JobParameter(e);
    929         p.add(jp.getPluginParameter());
    930       }
    931       return p;
     932        if (positionParameter.containsKey(jp.getPosition()))
     933        {
     934          throw new BaseException("Duplicate parameter at position "+jp.getPosition());
     935        }
     936        positionParameter.put(jp.getPosition(), jp.getPluginParameter());
     937      }
     938      return new ArrayList<PluginParameter<?>>(positionParameter.values());
    932939    }
    933940    catch (JDOMException e1)
     
    14301437
    14311438                // int2 = 10^a / 2^(0.5*m)
    1432                 // int1 = int2  2^m
     1439                // int1 = int2 * 2^m
    14331440                intensities[1] = new Float(Math.pow(10, a) / Math.pow(2, 0.5 * m));
    1434                 intensities[0] = new Float(intensities[1] * Math.pow(2, m));
     1441                intensities[0] = new Float(intensities[1] * Math.pow(2, m));
    14351442              }
    14361443
     
    18481855    }
    18491856  }
     1857 
     1858  private class ListMap<K, V> extends java.util.AbstractMap<K, V>
     1859  {
     1860    private List<K> keys = new ArrayList<K>();
     1861    private List<V> values = new ArrayList<V>();
     1862
     1863    @Override
     1864    public Set<java.util.Map.Entry<K, V>> entrySet()
     1865    {
     1866      throw new UnsupportedOperationException();
     1867    }
     1868
     1869    @Override
     1870    public V put(K key, V value)
     1871    {
     1872      V ret = null;
     1873      int index = keys.indexOf(key);
     1874      if (index == -1)
     1875      {
     1876        keys.add(key);
     1877        values.add(value);
     1878      }
     1879      else
     1880      {
     1881        keys.set(index, key);
     1882        ret = values.set(index, value);
     1883      }
     1884      return ret;
     1885    }
     1886
     1887    @Override
     1888    public V get(Object key)
     1889    {
     1890      if (key == null) throw new NullPointerException();
     1891      int index = keys.indexOf(key);
     1892      V ret = null;
     1893      if (index != -1)
     1894      {
     1895        ret = values.get(index);
     1896      }
     1897      return ret;
     1898    }
     1899
     1900    @Override
     1901    public boolean isEmpty()
     1902    {
     1903      return keys.isEmpty();
     1904    }
     1905
     1906    @Override
     1907    public Set<K> keySet()
     1908    {
     1909      return new AbstractSet<K>()
     1910      {
     1911        @Override
     1912        public Iterator<K> iterator()
     1913        {
     1914          return Collections.unmodifiableList(keys).iterator();
     1915        }
     1916
     1917        @Override
     1918        public int size()
     1919        {
     1920          return keys.size();
     1921        }
     1922      };
     1923    }
     1924   
     1925  }
    18501926
    18511927  private enum Base1JobParameterType
  • trunk/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java

    r3509 r3545  
    302302  }
    303303 
    304  
    305304  private void exportBaseFileSectionAssays(PrintWriter out, DbControl dc, BioAssaySet bas)
    306305  {
     
    329328  }
    330329 
    331  
    332330  private void exportBaseFileSectionHead(PrintWriter out, Map<String, String> parameters)
    333331  {
    334332    out.println("BASEfile");
     333   
    335334    if (!parameters.isEmpty())
    336335    {
    337       Set<String> keys = new HashSet<String>(parameters.keySet());
    338       if (keys.remove("section"))
     336      List<String> keys = new ArrayList<String>(parameters.keySet());
     337      if ("section".equals(keys.get(0)))
    339338      {
    340339        out.println("section\t"+parameters.get("section"));
     340        keys = keys.subList(1, keys.size());
     341      }
     342      if (keys.contains("section"))
     343      {
     344        throw new BaseException("The parameters can't have a parameter 'section' in the middle of the list.");
    341345      }
    342346      for (String key : keys)
     
    10251029
    10261030
     1031  @Override
    10271032  public Plugin.MainType getMainType()
    10281033  {
     
    10921097  private DbControl dc;
    10931098  private BioAssaySet bas;
     1099  @Override
    10941100  protected void begin(DbControl dc)
    10951101  {
     
    10971103  }
    10981104 
     1105  @Override
    10991106  @SuppressWarnings("unchecked")
    11001107  protected void performExport(ExportOutputStream out, ProgressReporter progress)
     
    11501157  }
    11511158 
     1159  @Override
    11521160  protected void end(boolean success)
    11531161  {
    11541162    this.dc = null;
    11551163  }
     1164 
     1165  @Override
    11561166  protected String getSuccessMessage()
    11571167  {
    11581168    return "Bioassay set '" + bas.getName() + "' exported successfully";
    11591169  }
    1160 
    11611170 
    11621171  @Override
Note: See TracChangeset for help on using the changeset viewer.