Changeset 3264


Ignore:
Timestamp:
Apr 23, 2007, 4:48:43 PM (15 years ago)
Author:
Johan Enell
Message:

Merged log:branches/2.2.3#3188:3260 to trunk.

Location:
trunk
Files:
16 edited
1 copied

Legend:

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

    r2992 r3264  
    195195  /**
    196196    Get the current database schema version number.
    197     @return The schema version number, or -1 if it could not be loaded
     197    @return The schema version number, or -2 if a connection to the database couldn't be established,
     198    or -1 if schemaVersion could not be loaded
    198199  */
    199200  public static int getSchemaVersion()
     
    201202    org.hibernate.Session session = null;
    202203    org.hibernate.Transaction tx = null;
    203     int schemaVersion = -1;
     204    int schemaVersion = -2;
    204205    try
    205206    {
    206207      session = HibernateUtil.newSession();
     208      schemaVersion++;
    207209      tx = HibernateUtil.newTransaction(session);
    208210      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SCHEMA_VERSION");
     
    370372        if (schemaVersion != Install.NEW_SCHEMA_VERSION)
    371373        {
    372           String msg = "Schema version mismatch: database schema version=" +
    373             schemaVersion + "; expected=" + Install.NEW_SCHEMA_VERSION;
    374          
    375           if (schemaVersion < Install.NEW_SCHEMA_VERSION)
     374          String msg = null;
     375          if (schemaVersion == -2)
    376376          {
    377             msg += "; Please update the database with the 'updatedb.sh' script before starting BASE.";
     377            msg = "Couldn't connect to the database; Please check that the base.config file has the correct settings " +
     378                "and that the database server is running.";
     379          }
     380          else if(schemaVersion == -1)
     381          {
     382            msg = "Couldn't find any schema version in the database; Please check that BASE has been installed properly";
    378383          }
    379384          else
    380           {
    381             msg += "; Please update the BASE code before starting.";
     385          {
     386            msg = "Schema version mismatch: database schema version=" +
     387              schemaVersion + "; expected=" + Install.NEW_SCHEMA_VERSION;
     388           
     389            if (schemaVersion < Install.NEW_SCHEMA_VERSION)
     390            {
     391              msg += "; Please update the database with the 'updatedb.sh' script before starting BASE.";
     392            }
     393            else
     394            {
     395              msg += "; Please update the BASE code before starting.";
     396            }
    382397          }
    383398          log.error(msg);
  • trunk/src/core/net/sf/basedb/core/PositionExtraValueBatcher.java

    r2981 r3264  
    3131import java.sql.PreparedStatement;
    3232import java.sql.SQLException;
     33import java.sql.Types;
    3334
    3435/**
     
    218219    @param position The position coordinate
    219220    @param value The extra value
    220     @throws InvalidDataException If the value is null
    221221    @throws BaseException If there is another error
    222222  */
     
    226226    if (isClosed()) throw new ConnectionClosedException();
    227227    updateLastAccess();
    228     if (value == null) throw new InvalidUseOfNullException("value");
     228   
     229    if (sqlType == Types.FLOAT && value != null && ((Float)value).isNaN())
     230    {
     231      // Convert Float.NaN to NULL
     232      value = null;
     233    }
    229234
    230235    // TODO - should we verify max position?
     
    235240      extraSql.setObject(2, value, sqlType);
    236241      extraSql.addBatch();
    237       bytes += bytesPerRow + (valueType == Type.STRING ? value.toString().length() : 0);
     242      bytes += bytesPerRow + (valueType == Type.STRING && value != null ? value.toString().length() : 0);
    238243      totalInsertCount++;
    239244    }
  • trunk/src/core/net/sf/basedb/core/SpotBatcher.java

    r2669 r3264  
    3131import java.sql.PreparedStatement;
    3232import java.sql.SQLException;
     33import java.sql.Types;
    3334
    3435/**
     
    228229      for (float intensity : intensities)
    229230      {
    230         spotSql.setFloat(i, intensity);
     231        if (Float.isNaN(intensity))
     232        {
     233          spotSql.setNull(i, Types.FLOAT);
     234        }
     235        else
     236        {
     237          spotSql.setFloat(i, intensity);
     238        }
    231239        i++;
    232240      }
  • trunk/src/core/net/sf/basedb/core/SpotExtraValueBatcher.java

    r2981 r3264  
    3131import java.sql.PreparedStatement;
    3232import java.sql.SQLException;
     33import java.sql.Types;
    3334
    3435/**
     
    209210    @param position The position coordinate
    210211    @param value The extra value
    211     @throws InvalidDataException If the value is null
    212212    @throws BaseException If there is another error
    213213  */
     
    217217    if (isClosed()) throw new ConnectionClosedException();
    218218    updateLastAccess();
    219     if (value == null) throw new InvalidUseOfNullException("value");
     219
     220    if (sqlType == Types.FLOAT && value != null && ((Float)value).isNaN())
     221    {
     222      // Convert Float.NaN to NULL
     223      value = null;
     224    }
    220225
    221226    // TODO - should we verify max column and position?
     
    227232      extraSql.setObject(3, value, sqlType);
    228233      extraSql.addBatch();
    229       bytes += bytesPerRow + (valueType == Type.STRING ? value.toString().length() : 0);
     234      bytes += bytesPerRow + (valueType == Type.STRING && value != null ? value.toString().length() : 0);
    230235      totalInsertCount++;
    231236    }
  • trunk/src/core/net/sf/basedb/core/Type.java

    r3023 r3264  
    418418      if (pos.getIndex() < value.length())
    419419      {
    420         throw new NumberFormatException("For input string: \"" + value + "\"");
     420        if (value.indexOf('e') >= 0)
     421        {
     422          // Convert 'e' to 'E' (in scientific notation only 'E' is allowed) and try again
     423          return parseString(value.replace('e', 'E'), numberFormat);
     424        }
     425        else
     426        {
     427          throw new NumberFormatException("For input string: \"" + value + "\"");
     428        }
    421429      }
    422430      return convertNumber(num);
  • trunk/src/core/net/sf/basedb/core/VirtualColumn.java

    r2304 r3264  
    130130  */
    131131  public static final VirtualColumn EXTRA_INT =
    132     new VirtualColumn("extraInt", "value", Hibernate.INTEGER, 0, !INDEXED, !NULLABLE, !PRIMARY_KEY);
     132    new VirtualColumn("extraInt", "value", Hibernate.INTEGER, 0, !INDEXED, NULLABLE, !PRIMARY_KEY);
    133133
    134134  /**
     
    136136  */
    137137  public static final VirtualColumn EXTRA_FLOAT =
    138     new VirtualColumn("extraFloat", "value", Hibernate.FLOAT, 0, !INDEXED, !NULLABLE, !PRIMARY_KEY);
     138    new VirtualColumn("extraFloat", "value", Hibernate.FLOAT, 0, !INDEXED, NULLABLE, !PRIMARY_KEY);
    139139
    140140  /**
     
    142142  */
    143143  public static final VirtualColumn EXTRA_STRING =
    144     new VirtualColumn("extraString", "value", Hibernate.STRING, 255, !INDEXED, !NULLABLE, !PRIMARY_KEY);
     144    new VirtualColumn("extraString", "value", Hibernate.STRING, 255, !INDEXED, NULLABLE, !PRIMARY_KEY);
    145145
    146146  /**
  • trunk/src/core/net/sf/basedb/core/data/FileData.java

    r2962 r3264  
    160160  /**
    161161    Get the associated {@link FileTypeData} item.
    162     @hibernate.many-to-one column="`filetype_id`" not-null="false"
     162    @hibernate.many-to-one column="`filetype_id`" not-null="false" outer-join="false"
    163163  */
    164164  public FileTypeData getFileType()
  • trunk/src/core/net/sf/basedb/util/parser/CompoundMapper.java

    r2302 r3264  
    2424package net.sf.basedb.util.parser;
    2525
     26import java.text.NumberFormat;
    2627import java.util.List;
    2728
     29import net.sf.basedb.core.Type;
    2830import net.sf.basedb.util.parser.FlatFileParser.Data;
    2931
     
    4143{
    4244  private final List<Mapper> mappers;
     45  private final NumberFormat parser;
    4346 
    4447  /**
     
    4649    @param mappers A list of other mappers that will be invoked in
    4750      the order they appear in the list
    48    */
     51  */
    4952  public CompoundMapper(List<Mapper> mappers)
    5053  {
     54    this(mappers, null);
     55  }
     56 
     57  /**
     58    Create a new compound mapper, using a specific number formatter as it's parser.
     59    @param mappers A list of other mappers that will be invoked in
     60      the order they appear in the list
     61    @param parser The number format to use or null to use Float.valueOf()
     62    @since 2.2.3
     63   */
     64  public CompoundMapper(List<Mapper> mappers, NumberFormat parser)
     65  {
    5166    this.mappers = mappers;
     67    this.parser = parser;
    5268  }
    53 
    5469  /*
    5570    From the Mapper interface
     
    7388  {
    7489    String stringValue = getValue(data);
    75     return stringValue == null ? null : Integer.parseInt(stringValue);
     90    Integer intValue = null;
     91    if (stringValue != null)
     92    {
     93      if (parser != null)
     94      {
     95        intValue = (Integer)Type.INT.parseString(stringValue, parser);
     96      }
     97      else
     98      {
     99        intValue = Integer.parseInt(stringValue);
     100      }
     101    }
     102    return intValue;
    76103  }
    77104  public Float getFloat(Data data)
    78105  {
    79106    String stringValue = getValue(data);
    80     return stringValue == null ? null : Float.parseFloat(stringValue);
     107    Float floatValue = null;
     108    if (stringValue != null)
     109    {
     110      if (parser != null)
     111      {
     112        floatValue = (Float)Type.FLOAT.parseString(stringValue, parser);
     113      }
     114      else
     115      {
     116        floatValue = Float.parseFloat(stringValue);
     117      }
     118    }
     119    return floatValue;
    81120  }
    82121  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/util/parser/ConstantMapper.java

    r3023 r3264  
    2727import java.text.ParsePosition;
    2828
     29import net.sf.basedb.core.Type;
    2930import net.sf.basedb.util.parser.FlatFileParser.Data;
    3031
     
    4142{
    4243  private final String constant;
     44  private final NumberFormat parser;
     45  private boolean needToParseNumeric;
     46  private Float asFloat;
    4347  private Integer asInteger;
    44   private NumberFormatException integerException;
    45   private Float asFloat;
    46   private NumberFormatException floatException;
     48  private NumberFormatException parseException;
    4749 
    4850  /**
     
    6365  {
    6466    this.constant = constant;
    65     if (constant != null)
    66     {
    67       if (parser != null)
    68       {
    69         ParsePosition pos = new ParsePosition(0);
    70         asFloat = parser.parse(constant, pos).floatValue();
    71         if (pos.getIndex() < constant.length())
    72         {
    73           asFloat = null;
    74           floatException = new NumberFormatException("For input string: \"" + constant + "\"");
    75           integerException = floatException;
    76         }
    77         else
    78         {
    79           asInteger = asFloat.intValue();
    80         }
    81       }
    82       else
    83       {
    84         try
    85         {
    86           asFloat = Float.valueOf(constant);
    87         }
    88         catch (NumberFormatException ex)
    89         {
    90           floatException = ex;
    91         }
    92         if (asFloat != null)
    93         {
    94           asInteger = asFloat.intValue();
    95         }
    96         else
    97         {
    98           integerException = floatException;
    99         }
    100       }
    101     }
     67    this.parser = parser;
     68    this.needToParseNumeric = constant != null;
    10269  }
    10370 
     
    10774    this.asInteger = constant;
    10875    this.asFloat = new Float(constant.floatValue());
     76    this.parser = null;
     77    this.needToParseNumeric = false;
    10978  }
    11079 
     
    11483    this.asFloat = constant;
    11584    this.asInteger = new Integer(constant.intValue());
     85    this.parser = null;
     86    this.needToParseNumeric = false;
    11687  }
    11788 
     
    129100  public Integer getInt(Data data)
    130101  {
    131     if (integerException != null) throw integerException;
     102    if (parseException != null) throw parseException;
     103    if (needToParseNumeric) parseNumeric();
    132104    return asInteger;
    133105  }
    134106  public Float getFloat(Data data)
    135107  {
    136     if (floatException != null) throw floatException;
     108    if (parseException != null) throw parseException;
     109    if (needToParseNumeric) parseNumeric();
    137110    return asFloat;
    138111  }
     
    148121  }
    149122  // -------------------------------------------
     123
     124  private void parseNumeric()
     125  {
     126    assert constant != null : "constant == null";
     127    needToParseNumeric = false;
     128    try
     129    {
     130      if (parser != null)
     131      {
     132        asFloat = (Float)Type.FLOAT.parseString(constant, parser);
     133      }
     134      else
     135      {
     136        asFloat = Float.valueOf(constant);
     137      }
     138    }
     139    catch (NumberFormatException ex)
     140    {
     141      parseException = ex;
     142    }
     143    if (asFloat != null)
     144    {
     145      asInteger = asFloat.intValue();
     146    }
     147  }
    150148}
  • trunk/src/core/net/sf/basedb/util/parser/FlatFileParser.java

    r3023 r3264  
    871871      else
    872872      {
    873         mapper = new CompoundMapper(mappers);
     873        mapper = new CompoundMapper(mappers, numberFormat);
    874874      }
    875875    }
  • trunk/src/install/net/sf/basedb/install/Webclient.java

    r3260 r3264  
    144144      simpleExport = PluginDefinition.getNew(dc, simpleExportClassName, null, true);
    145145      simpleExport.setItemKey(everyoneUse);
     146      simpleExport.setAllowImmediateExecution(true);
    146147      dc.saveItem(simpleExport);
    147148    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r3128 r3264  
    5858import net.sf.basedb.core.Transformation;
    5959import net.sf.basedb.core.Type;
     60import net.sf.basedb.core.User;
    6061import net.sf.basedb.core.plugin.About;
    6162import net.sf.basedb.core.plugin.AboutImpl;
     
    10121013        }
    10131014      }
    1014       String homeDirectoryPath = "";
     1015      String homeDirectoryPath = "/" + PluginConfiguration.getById(dc, configuration.getId()).getName();
    10151016      Directory homeDirectory = experiment.getDirectory();
    1016       if (homeDirectory == null)
    1017       {
    1018         homeDirectoryPath = homeDirectory.getPath() + "/" + PluginConfiguration.getById(dc, configuration.getId()).getName();
     1017      if (homeDirectory != null)
     1018      {
     1019        homeDirectoryPath = homeDirectory.getPath() + homeDirectoryPath;
     1020      }
     1021      else
     1022      {
     1023        homeDirectory = User.getById(dc, sc.getLoggedInUserId()).getHomeDirectory();
     1024        if (homeDirectory != null)
     1025        {
     1026          homeDirectoryPath = homeDirectory.getPath() + homeDirectoryPath;
     1027        }
    10191028      }
    10201029      pluginDirectoryParameter = new PluginParameter<String>(
  • trunk/src/test/TestAll.java

    r3062 r3264  
    122122    results.put("TestDbInfo", TestDbInfo.test_all());
    123123    results.put("TestPresets", TestPresets.test_all());
     124    results.put("TestNumberFormat", TestNumberFormat.test_all());
    124125
    125126    // Plugins, jobs
  • trunk/src/test/TestExperiment.java

    r2993 r3264  
    791791        numSpots++;
    792792        SqlResult r = spots.next();
    793         if (intBatcher != null) intBatcher.insert(r.getShort(column), r.getInt(position), numSpots);
    794         if (floatBatcher != null) floatBatcher.insert(r.getShort(column), r.getInt(position), r.getFloat(ch1) * r.getFloat(ch2));
    795         if (stringBatcher != null) stringBatcher.insert(r.getShort(column), r.getInt(position), "Spot number " + numSpots);
     793       
     794        if (numSpots == 1)
     795        {
     796          // Test NULL and Float.NaN
     797          if (intBatcher != null) intBatcher.insert(r.getShort(column), r.getInt(position), null);
     798          if (floatBatcher != null) floatBatcher.insert(r.getShort(column), r.getInt(position), Float.NaN);
     799          if (stringBatcher != null) stringBatcher.insert(r.getShort(column), r.getInt(position), null);
     800        }
     801        else
     802        {
     803          if (intBatcher != null) intBatcher.insert(r.getShort(column), r.getInt(position), numSpots);
     804          if (floatBatcher != null) floatBatcher.insert(r.getShort(column), r.getInt(position), r.getFloat(ch1) * r.getFloat(ch2));
     805          if (stringBatcher != null) stringBatcher.insert(r.getShort(column), r.getInt(position), "Spot number " + numSpots);
     806        }
    796807      }
    797808
     
    873884        numSpots++;
    874885        SqlResult r = spots.next();
    875         if (intBatcher != null) intBatcher.insert(r.getInt(position), numSpots);
    876         if (floatBatcher != null) floatBatcher.insert(r.getInt(position), r.getFloat(prod));
    877         if (stringBatcher != null) stringBatcher.insert(r.getInt(position), "Spot number " + numSpots);
     886        if (numSpots == 1)
     887        {
     888          if (intBatcher != null) intBatcher.insert(r.getInt(position), null);
     889          if (floatBatcher != null) floatBatcher.insert(r.getInt(position), Float.NaN);
     890          if (stringBatcher != null) stringBatcher.insert(r.getInt(position), null);
     891        }
     892        else
     893        {
     894          if (intBatcher != null) intBatcher.insert(r.getInt(position), numSpots);
     895          if (floatBatcher != null) floatBatcher.insert(r.getInt(position), r.getFloat(prod));
     896          if (stringBatcher != null) stringBatcher.insert(r.getInt(position), "Spot number " + numSpots);
     897        }
    878898      }
    879899
  • trunk/www/admin/plugindefinitions/edit_plugin.jsp

    r2978 r3264  
    726726      <tr>
    727727        <td class="prompt">Max memory</td>
    728         <td><input <%=clazz%> type="text" name="maxMemory" '
     728        <td><input <%=clazz%> type="text" name="maxMemory"
    729729          value="<%=Values.formatBytes(plugin == null ? Values.parseBytes(cc.getPropertyValue("maxMemory"), null) : plugin.getMaxMemory())%>"
    730730          size="16" maxlength="16"> (Use KB, MB or GB to specify units)</td>
  • trunk/www/my_base/index.jsp

    r2978 r3264  
    261261    <%
    262262      long myPrimaryUsage = user.getDiskUsage(totalQuotaType, Location.PRIMARY);
    263       long myPrimaryQuota = quota.getQuotaValue(totalQuotaType, Location.SECONDARY);
     263      long myPrimaryQuota = quota.getQuotaValue(totalQuotaType, Location.PRIMARY);
    264264      long groupPrimaryQuota = groupQuota == null ? Quota.UNDEFINED : groupQuota.getQuotaValue(totalQuotaType, Location.PRIMARY);
    265265      long mySecondaryUsage = user.getDiskUsage(totalQuotaType, Location.SECONDARY);
     
    281281    {
    282282      myPrimaryUsage = user.getDiskUsage(qt, Location.PRIMARY);
    283       myPrimaryQuota = quota.getQuotaValue(qt, Location.SECONDARY);
     283      myPrimaryQuota = quota.getQuotaValue(qt, Location.PRIMARY);
    284284      groupPrimaryQuota = groupQuota == null ? Quota.UNDEFINED : groupQuota.getQuotaValue(qt, Location.PRIMARY);
    285285      mySecondaryUsage = user.getDiskUsage(qt, Location.SECONDARY);
Note: See TracChangeset for help on using the changeset viewer.