Changeset 4631


Ignore:
Timestamp:
Nov 7, 2008, 12:06:05 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1167: Base1PluginExecutor should handle reporter-id=0 as null in some cases

Test case converts all empty reporter values to 0.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r4606 r4631  
    13391339    // Position -> ReporterID mapping for the parent bioassay set
    13401340    Map<Integer, Integer> parentReporterPositions = new HashMap<Integer, Integer>();
     1341    boolean parentHasNullReporter = false;
     1342    boolean parentHasZeroReporter = false;
     1343    boolean mapZeroToNull = false;
     1344
    13411345    // Position -> ReporterID mapping for the child bioassay set
    13421346    Map<Integer, Integer> childReporterPositions = new HashMap<Integer, Integer>();
     
    14661470          {
    14671471            SqlResult result = positionQueryIterator.next();
    1468             parentReporterPositions.put(result.getInt(1), (Integer)result.getObject(2));
    1469           }
     1472            Integer reporterId = (Integer)result.getObject(2);
     1473            if (reporterId == null)
     1474            {
     1475              parentHasNullReporter = true;
     1476            }
     1477            else if (reporterId.intValue() == 0)
     1478            {
     1479              parentHasZeroReporter = true;
     1480            }
     1481            parentReporterPositions.put(result.getInt(1), reporterId);
     1482          }
     1483         
     1484         
     1485          // If we have null reporter (but none with ID=0) in the export
     1486          // we may need to convert 0->null when importing since some
     1487          // BASE1 plug-ins convert null -> 0
     1488          mapZeroToNull = parentHasNullReporter && !parentHasZeroReporter;
    14701489        }
    14711490
     
    15281547                ffp.getParsedLines() + " in file '" + stdout.getName() + "'");
    15291548          }
    1530          
     1549          // Convert 0 -> null since some BASE1 plug-ins convert null -> 0
     1550          if (mapZeroToNull && newReporterId != null && newReporterId.intValue() == 0)
     1551          {
     1552            newReporterId = null;
     1553          }
     1554
    15311555          // Is the new reporter the same as the existing?
    15321556          // A 'null' reporter is considered the same as another 'null' reporter
  • trunk/src/test/Base1TestPlugin.java

    r4514 r4631  
    131131          {
    132132            FlatFileParser.Data data = ffp.nextData();
    133             System.out.println(offset + data.line());
     133            System.out.println(offset + data.line().replaceFirst("\\t\\t", "\t0\t"));
    134134          }
    135135          System.out.println();
Note: See TracChangeset for help on using the changeset viewer.