Changeset 7666


Ignore:
Timestamp:
Mar 20, 2019, 4:21:26 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2161: Import data from Excel files

Introduced Mapper.getString() method and changed all places in the code that calls Mapper.getValue() to the new method where it is apparent that a string value is wanted. Most remaining places that call Mapper.getValue() need dates or a value based on a generic Type.

Location:
trunk/src
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/parser/ColumnMapper.java

    r7665 r7666  
    7676    -------------------------------------------
    7777  */
    78   /**
    79     Get the value in the data objects column with the index specified
    80     in the constructor.
    81     @return The value or null if the index is out of bounds
    82   */
    8378  @Override
     79  @Deprecated
    8480  public String getValue(Data data)
     81  {
     82    return getString(data);
     83  }
     84  @Override
     85  public String getString(Data data)
    8586  {
    8687    return index < data.columns() ? data.getString(index) : null;
  • trunk/src/core/net/sf/basedb/util/parser/CompoundMapper.java

    r6127 r7666  
    7575    -------------------------------------------
    7676  */
     77  @Override
     78  @Deprecated
     79  public String getValue(Data data)
     80  {
     81    return getString(data);
     82  }
    7783  /**
    7884    Get a value by invoking each mapper in the order they appear in
     
    8187  */
    8288  @Override
    83   public String getValue(Data data)
     89  public String getString(Data data)
    8490  {
    8591    StringBuilder sb = new StringBuilder();
    8692    for (Mapper m : mappers)
    8793    {
    88       sb.append(m.getValue(data));
     94      sb.append(m.getString(data));
    8995    }
    9096    return sb.toString();
  • trunk/src/core/net/sf/basedb/util/parser/ConstantMapper.java

    r6127 r7666  
    100100  */
    101101  @Override
     102  @Deprecated
    102103  public String getValue(Data data)
     104  {
     105    return constant;
     106  }
     107  @Override
     108  public String getString(Data data)
    103109  {
    104110    return constant;
  • trunk/src/core/net/sf/basedb/util/parser/CropStringMapper.java

    r6127 r7666  
    5454    -------------------------------------------
    5555  */
     56  @Override
     57  @Deprecated
     58  public String getValue(Data data)
     59  {
     60    return getString(data);
     61  }
    5662  /**
    5763    Use the parent mapper to get the string value. Then check the
     
    5965  */
    6066  @Override
    61   public String getValue(Data data)
     67  public String getString(Data data)
    6268  {
    63     String s = parent.getValue(data);
     69    String s = parent.getString(data);
    6470    if (s != null && s.length() > maxLength) s = s.substring(0, maxLength);
    6571    return s;
  • trunk/src/core/net/sf/basedb/util/parser/JepMapper.java

    r7664 r7666  
    121121  */
    122122  @Override
     123  @Deprecated
    123124  public String getValue(Data data)
     125  {
     126    return getString(data);
     127  }
     128  @Override
     129  public String getString(Data data)
    124130  {
    125131    setData(data, Type.STRING);
  • trunk/src/core/net/sf/basedb/util/parser/Mapper.java

    r7664 r7666  
    5555 
    5656  /**
     57    Get the value for the line of data as a string.
     58    @param data The line of data
     59    @return A string value
     60    @since 3.15
     61  */
     62  public String getString(Data data);
     63 
     64  /**
    5765    Get the value for the line of data as an integer.
    5866
  • trunk/src/core/net/sf/basedb/util/parser/NullIfExceptionMapper.java

    r6127 r7666  
    5252  */
    5353  @Override
     54  @Deprecated
    5455  public String getValue(Data data)
     56  {
     57    return getString(data);
     58  }
     59  @Override
     60  public String getString(Data data)
    5561  {
    5662    try
    5763    {
    58       return parent.getValue(data);
     64      return parent.getString(data);
    5965    }
    6066    catch (Throwable t)
  • trunk/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java

    r7657 r7666  
    763763
    764764    // Find the item(s) to annotate. Mapper gives us name OR external ID
    765     String nameOrId = itemMapper.getValue(data);
     765    String nameOrId = itemMapper.getString(data);
    766766    // 1. check the cache
    767767    Set<NewAnnotations> items = itemCache.get(nameOrId);
  • trunk/src/plugins/core/net/sf/basedb/plugins/IlluminaRawDataImporter.java

    r7605 r7666  
    530530    throws BaseException
    531531  {
    532     String externalId = reporterMapper.getValue(data);
     532    String externalId = reporterMapper.getString(data);
    533533    int lineNo = data.dataLineNo();
    534534    for (BatchAndMapHolder holder : holders)
  • trunk/src/plugins/core/net/sf/basedb/plugins/PlateFlatFileImporter.java

    r6898 r7666  
    441441    throws BaseException
    442442  {
    443     String plateName = nameMapper.getValue(data);
     443    String plateName = nameMapper.getString(data);
    444444    if (plateName != null)
    445445    {
     
    454454        }
    455455        plate.setName(plateNamePrefix + plateName);
    456         plate.setBarcode(barcodeMapper.getValue(data));
     456        plate.setBarcode(barcodeMapper.getString(data));
    457457        dc.saveItem(plate);
    458458        numPlates++;
     
    460460
    461461      // Find well from coordinates
    462       String row = rowMapper.getValue(data);
    463       String column = columnMapper.getValue(data);
     462      String row = rowMapper.getString(data);
     463      String column = columnMapper.getString(data);
    464464      if (row == null) throw new InvalidUseOfNullException("row");
    465465      if (column == null) throw new InvalidUseOfNullException("column");
     
    474474
    475475      // Find reporter
    476       String reporterId = reporterMapper.getValue(data);
     476      String reporterId = reporterMapper.getString(data);
    477477      if (reporterId != null)
    478478      {
  • trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java

    r6898 r7666  
    835835    RawData raw = batcher.newRawData();
    836836
    837     String externalId = reporterMapper.getValue(data);
    838     String featureId = featureIdMapper.getValue(data);
     837    String externalId = reporterMapper.getString(data);
     838    String featureId = featureIdMapper.getString(data);
    839839    Integer position = positionMapper.getInt(data);
    840840    if (position != null) raw.setPosition(position);
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterFlatFileImporter.java

    r6870 r7666  
    565565    throws BaseException
    566566  {
    567     String externalId = idMapper.getValue(data);
     567    String externalId = idMapper.getString(data);
    568568    if (externalId == null) throw new InvalidUseOfNullException("externalId");
    569569    ReporterData reporter =  null;
     
    659659          else if (reporterTypeMapper != null)
    660660          {
    661             Reporter.setReporterType(reporter, getReporterType(reporterTypeMapper.getValue(data)));
    662           }
    663           String name = nameMapper == null ? reporter.getName() : nameMapper.getValue(data);
     661            Reporter.setReporterType(reporter, getReporterType(reporterTypeMapper.getString(data)));
     662          }
     663          String name = nameMapper == null ? reporter.getName() : nameMapper.getString(data);
    664664          reporter.setName(name == null ? externalId : name);
    665665         
    666           if (symbolMapper != null) reporter.setSymbol(symbolMapper.getValue(data));
    667           if (descriptionMapper != null) reporter.setDescription(descriptionMapper.getValue(data));
     666          if (symbolMapper != null) reporter.setSymbol(symbolMapper.getString(data));
     667          if (descriptionMapper != null) reporter.setDescription(descriptionMapper.getString(data));
    668668          for (Map.Entry<ExtendedProperty, Mapper> entry : extendedMappers.entrySet())
    669669          {
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java

    r7605 r7666  
    583583    throws BaseException
    584584  {
    585     String externalId = reporterMapper.getValue(data);
    586     String featureId = featureIdMapper.getValue(data);
     585    String externalId = reporterMapper.getString(data);
     586    String featureId = featureIdMapper.getString(data);
    587587    ReporterData reporter = externalId == null ?
    588588      null : reporterBatcher.getByExternalId(externalId, errorIfNotFound);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r7657 r7666  
    701701  {
    702702    // Find the item(s) to update. Mapper gives us name, internal ID, or some other identifer
    703     String identifier = idMapper.getValue(data);
     703    String identifier = idMapper.getString(data);
    704704    String cacheKey = itemQuery.getItemType().name() + ":" + identifier;
    705705    boolean sameAsLast = StringUtil.isEqualOrNull(identifier, lastIdentifier);
     
    12051205  protected void updatePermissions(DbControl dc, Shareable item, FlatFileParser.Data data, boolean merge)
    12061206  {
    1207     String nameOrId = permissionTemplateMapper.getValue(data);
     1207    String nameOrId = permissionTemplateMapper.getString(data);
    12081208    PermissionTemplate template = findPermissionTemplate(dc, FallbackIdMethod.NAME_OR_ID, nameOrId);
    12091209    if (template != null)
     
    12331233    if (subtypeMapper != null)
    12341234    {
    1235       String nameOrId = subtypeMapper.getValue(data);
     1235      String nameOrId = subtypeMapper.getString(data);
    12361236      ItemSubtype subtype = findItemSubtype(dc, FallbackIdMethod.NAME_OR_SYSTEMID_OR_ID, item.getType(), nameOrId);
    12371237      if (nameOrId == null || subtype != null) item.setItemSubtype(subtype);
     
    12581258    if (subtypeMapper != null)
    12591259    {
    1260       String nameOrId = subtypeMapper.getValue(data);
     1260      String nameOrId = subtypeMapper.getString(data);
    12611261      subtype = findItemSubtype(dc, FallbackIdMethod.NAME_OR_SYSTEMID_OR_ID, mainItemType, nameOrId);
    12621262    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AnnotationTypeImporter.java

    r7618 r7666  
    442442  protected AnnotationType createItem(DbControl dc, FlatFileParser.Data data)
    443443  {
    444     Type valueType = Type.valueOf(valueTypeMapper.getValue(data));
     444    Type valueType = Type.valueOf(valueTypeMapper.getString(data));
    445445    AnnotationType at = AnnotationType.getNew(dc, valueType);
    446446    if (registeredMapper != null)
     
    454454  protected void updateItem(DbControl dc, AnnotationType at, FlatFileParser.Data data)
    455455  {
    456     if (nameMapper != null) at.setName(nameMapper.getValue(data));
    457     if (descriptionMapper != null) at.setDescription(descriptionMapper.getValue(data));
    458     if (externalIdMapper != null) at.setExternalId(externalIdMapper.getValue(data));
     456    if (nameMapper != null) at.setName(nameMapper.getString(data));
     457    if (descriptionMapper != null) at.setDescription(descriptionMapper.getString(data));
     458    if (externalIdMapper != null) at.setExternalId(externalIdMapper.getString(data));
    459459    if (multiplicityMapper != null) at.setMultiplicity(multiplicityMapper.getInt(data));
    460     if (defaultValueMapper != null) at.setDefaultValue(defaultValueMapper.getValue(data));
    461     if (isIdentifierMapper != null) at.setIdentifier(Values.getBoolean(isIdentifierMapper.getValue(data)));
    462     if (miameMapper != null) at.setRequiredForMiame(Values.getBoolean(miameMapper.getValue(data)));
    463     if (protocolParameterMapper != null) at.setProtocolParameter(Values.getBoolean(protocolParameterMapper.getValue(data)));
    464     if (disableChangeLogMapper != null) at.setDisableLogOfValues(Values.getBoolean(disableChangeLogMapper.getValue(data)));
    465     if (disableInheritanceMapper != null) at.setDisableInheritance(Values.getBoolean(disableInheritanceMapper.getValue(data)));
     460    if (defaultValueMapper != null) at.setDefaultValue(defaultValueMapper.getString(data));
     461    if (isIdentifierMapper != null) at.setIdentifier(Values.getBoolean(isIdentifierMapper.getString(data)));
     462    if (miameMapper != null) at.setRequiredForMiame(Values.getBoolean(miameMapper.getString(data)));
     463    if (protocolParameterMapper != null) at.setProtocolParameter(Values.getBoolean(protocolParameterMapper.getString(data)));
     464    if (disableChangeLogMapper != null) at.setDisableLogOfValues(Values.getBoolean(disableChangeLogMapper.getString(data)));
     465    if (disableInheritanceMapper != null) at.setDisableInheritance(Values.getBoolean(disableInheritanceMapper.getString(data)));
    466466    if (itemTypesMapper != null)
    467467    {
    468       String itemTypes = itemTypesMapper.getValue(data);
     468      String itemTypes = itemTypesMapper.getString(data);
    469469      Set<Item> items = new HashSet<Item>();
    470470      if (itemTypes != null)
     
    479479    if (defaultUnitMapper != null && at.getValueType().isNumerical())
    480480    {
    481       String nameOrSymbolOrId = defaultUnitMapper.getValue(data);
     481      String nameOrSymbolOrId = defaultUnitMapper.getString(data);
    482482      Unit unit = findUnit(dc, FallbackIdMethod.NAME_OR_UNITSYMBOL_OR_ID, nameOrSymbolOrId);
    483483      if (unit != null)
     
    491491    if (enumerationMapper != null && valueType.canEnumerate())
    492492    {
    493       String enumeration = enumerationMapper.getValue(data);
     493      String enumeration = enumerationMapper.getString(data);
    494494      at.setEnumeration(enumeration != null);
    495495      if (enumeration != null)
     
    540540    if (categoryMapper != null)
    541541    {
    542       String nameOrId = categoryMapper.getValue(data);
     542      String nameOrId = categoryMapper.getString(data);
    543543      AnnotationTypeCategory category = findAnnotationTypeCategory(dc, FallbackIdMethod.NAME_OR_ID, nameOrId);
    544544      if (category != null) at.addCategory(category);
     
    546546    if (usableUnitMapper != null && at.supportUnits())
    547547    {
    548       String nameOrSymbolOrId = usableUnitMapper.getValue(data);
     548      String nameOrSymbolOrId = usableUnitMapper.getString(data);
    549549      Unit unit = findUnit(dc, FallbackIdMethod.NAME_OR_UNITSYMBOL_OR_ID, nameOrSymbolOrId);
    550550      if (unit != null) at.addUsableUnit(unit);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ArrayBatchImporter.java

    r7589 r7666  
    176176    if (arrayDesignMapper != null)
    177177    {
    178       design = findArrayDesign(dc, FallbackIdMethod.NAME_OR_ID, arrayDesignMapper.getValue(data));
     178      design = findArrayDesign(dc, FallbackIdMethod.NAME_OR_ID, arrayDesignMapper.getString(data));
    179179    }
    180180
     
    191191  protected void updateItem(DbControl dc, ArrayBatch batch, FlatFileParser.Data data)
    192192  {
    193     if (nameMapper != null) batch.setName(nameMapper.getValue(data));
    194     if (descriptionMapper != null) batch.setDescription(descriptionMapper.getValue(data));
     193    if (nameMapper != null) batch.setName(nameMapper.getString(data));
     194    if (descriptionMapper != null) batch.setDescription(descriptionMapper.getString(data));
    195195    if (protocolMapper != null)
    196196    {
    197197      ItemSubtype type = ItemSubtype.getById(dc, SystemItems.getId(Protocol.PRINTING));
    198198      defaultProtocolFunction.setCurrentSubtype(type);
    199       String nameOrId = protocolMapper.getValue(data);
     199      String nameOrId = protocolMapper.getString(data);
    200200      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    201201      if (nameOrId == null || protocol != null) batch.setProtocol(protocol);
     
    205205      ItemSubtype type = ItemSubtype.getById(dc, SystemItems.getId(Hardware.PRINT_ROBOT));
    206206      defaultHardwareFunction.setCurrentSubtype(type);
    207       String nameOrId = hardwareMapper.getValue(data);
     207      String nameOrId = hardwareMapper.getString(data);
    208208      Hardware robot = findHardware(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    209209      if (nameOrId == null || robot != null) batch.setPrintRobot(robot);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ArrayDesignImporter.java

    r7589 r7666  
    243243    if (platformMapper != null)
    244244    {
    245       platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getValue(data));
     245      platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getString(data));
    246246    }
    247247    else
     
    251251    if (variantMapper != null)
    252252    {
    253       variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getValue(data));
     253      variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getString(data));
    254254    }
    255255    else
     
    279279  protected void updateItem(DbControl dc, ArrayDesign design, FlatFileParser.Data data)
    280280  {
    281     if (nameMapper != null) design.setName(nameMapper.getValue(data));
    282     if (descriptionMapper != null) design.setDescription(descriptionMapper.getValue(data));
     281    if (nameMapper != null) design.setName(nameMapper.getString(data));
     282    if (descriptionMapper != null) design.setDescription(descriptionMapper.getString(data));
    283283    if (numArraysMapper != null)
    284284    {
     
    292292      if (platformMapper != null)
    293293      {
    294         String nameOrId = platformMapper.getValue(data);
     294        String nameOrId = platformMapper.getString(data);
    295295        platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
    296296      }
    297297      if (variantMapper != null)
    298298      {
    299         String nameOrId = variantMapper.getValue(data);
     299        String nameOrId = variantMapper.getString(data);
    300300        variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
    301301        if (nameOrId == null || variant != null) design.setVariant(variant);
     
    321321    if (fileTypeMapper != null && fileMapper != null)
    322322    {
    323       String nameOrId = fileTypeMapper.getValue(data);
    324       String filePath = fileMapper.getValue(data);
     323      String nameOrId = fileTypeMapper.getString(data);
     324      String filePath = fileMapper.getString(data);
    325325      DataFileType fileType = findDataFileType(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
    326326      if (fileType != null)
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ArraySlideImporter.java

    r7589 r7666  
    194194    if (arrayBatchMapper != null)
    195195    {
    196       batch = findArrayBatch(dc, FallbackIdMethod.NAME_OR_ID, arrayBatchMapper.getValue(data));
     196      batch = findArrayBatch(dc, FallbackIdMethod.NAME_OR_ID, arrayBatchMapper.getString(data));
    197197    }
    198198
     
    209209  protected void updateItem(DbControl dc, ArraySlide slide, FlatFileParser.Data data)
    210210  {
    211     if (nameMapper != null) slide.setName(nameMapper.getValue(data));
    212     if (descriptionMapper != null) slide.setDescription(descriptionMapper.getValue(data));
    213     if (barcodeMapper != null) slide.setBarcode(barcodeMapper.getValue(data));
     211    if (nameMapper != null) slide.setName(nameMapper.getString(data));
     212    if (descriptionMapper != null) slide.setDescription(descriptionMapper.getString(data));
     213    if (barcodeMapper != null) slide.setBarcode(barcodeMapper.getString(data));
    214214    if (indexMapper != null)
    215215    {
     
    219219    if (destroyedMapper != null)
    220220    {
    221       slide.setDestroyed(Values.getBoolean(destroyedMapper.getValue(data)));
     221      slide.setDestroyed(Values.getBoolean(destroyedMapper.getString(data)));
    222222    }
    223223  }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/BioPlateImporter.java

    r7589 r7666  
    241241    if (bioPlateTypeMapper != null)
    242242    {
    243       plateType = findBioPlateType(dc, FallbackIdMethod.NAME_OR_ID, bioPlateTypeMapper.getValue(data));
     243      plateType = findBioPlateType(dc, FallbackIdMethod.NAME_OR_ID, bioPlateTypeMapper.getString(data));
    244244    }
    245245    if (plateGeometryMapper != null)
    246246    {
    247       geometry = findPlateGeometry(dc, FallbackIdMethod.NAME_OR_ID, plateGeometryMapper.getValue(data));
     247      geometry = findPlateGeometry(dc, FallbackIdMethod.NAME_OR_ID, plateGeometryMapper.getString(data));
    248248    }
    249249
     
    260260  protected void updateItem(DbControl dc, BioPlate plate, FlatFileParser.Data data)
    261261  {
    262     if (nameMapper != null) plate.setName(nameMapper.getValue(data));
    263     if (descriptionMapper != null) plate.setDescription(descriptionMapper.getValue(data));
     262    if (nameMapper != null) plate.setName(nameMapper.getString(data));
     263    if (descriptionMapper != null) plate.setDescription(descriptionMapper.getString(data));
    264264    if (createdMapper != null) plate.setEventDate(parseDate(createdMapper.getValue(data)));
    265     if (barcodeMapper != null) plate.setBarcode(barcodeMapper.getValue(data));
     265    if (barcodeMapper != null) plate.setBarcode(barcodeMapper.getString(data));
    266266    if (hardwareMapper != null)
    267267    {
    268268      ItemSubtype type = ItemSubtype.getById(dc, SystemItems.getId(Hardware.FREEZER));
    269269      defaultHardwareFunction.setCurrentSubtype(type);
    270       String nameOrId = hardwareMapper.getValue(data);
     270      String nameOrId = hardwareMapper.getString(data);
    271271      Hardware freezer = findHardware(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    272272      if (nameOrId == null || freezer != null) plate.setFreezer(freezer);
    273273    }
    274     if (sectionMapper != null) plate.setSection(sectionMapper.getValue(data));
    275     if (trayMapper != null) plate.setTray(trayMapper.getValue(data));
    276     if (positionMapper != null) plate.setPosition(positionMapper.getValue(data));
     274    if (sectionMapper != null) plate.setSection(sectionMapper.getString(data));
     275    if (trayMapper != null) plate.setTray(trayMapper.getString(data));
     276    if (positionMapper != null) plate.setPosition(positionMapper.getString(data));
    277277  }
    278278  // ------------------------------------
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/BioSourceImporter.java

    r7588 r7666  
    153153  protected void updateItem(DbControl dc, BioSource biosource, FlatFileParser.Data data)
    154154  {
    155     if (nameMapper != null) biosource.setName(nameMapper.getValue(data));
    156     if (descriptionMapper != null) biosource.setDescription(descriptionMapper.getValue(data));
    157     if (externalIdMapper != null) biosource.setExternalId(externalIdMapper.getValue(data));
     155    if (nameMapper != null) biosource.setName(nameMapper.getString(data));
     156    if (descriptionMapper != null) biosource.setDescription(descriptionMapper.getString(data));
     157    if (externalIdMapper != null) biosource.setExternalId(externalIdMapper.getString(data));
    158158    updateItemSubtype(dc, biosource, data);
    159159  }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/DerivedBioAssayImporter.java

    r7589 r7666  
    299299    {
    300300      // Is the parent type explicitely mappped?
    301       String type = parentTypeMapper.getValue(data);
     301      String type = parentTypeMapper.getString(data);
    302302      if (type != null) parentType = Item.valueOf(type);
    303303    }
     
    343343  protected void updateItem(DbControl dc, DerivedBioAssay bioAssay, FlatFileParser.Data data)
    344344  {
    345     if (nameMapper != null) bioAssay.setName(nameMapper.getValue(data));
    346     if (descriptionMapper != null) bioAssay.setDescription(descriptionMapper.getValue(data));
     345    if (nameMapper != null) bioAssay.setName(nameMapper.getString(data));
     346    if (descriptionMapper != null) bioAssay.setDescription(descriptionMapper.getString(data));
    347347    if (bioAssay.isInDatabase()) updateItemSubtype(dc, bioAssay, data);
    348348    if (extractMapper != null)
    349349    {
    350       String nameOrId = extractMapper.getValue(data);
     350      String nameOrId = extractMapper.getString(data);
    351351      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, bioAssay, Item.EXTRACT, 0);
    352352      Extract extract = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
     
    357357      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, bioAssay, Item.PROTOCOL, 0);
    358358      defaultProtocolFunction.setCurrentSubtype(type);
    359       String nameOrId = protocolMapper.getValue(data);
     359      String nameOrId = protocolMapper.getString(data);
    360360      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    361361      if (nameOrId == null || protocol != null) bioAssay.setProtocol(protocol);
     
    364364    {
    365365      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, bioAssay, Item.KIT, 0);
    366       String nameOrId = kitMapper.getValue(data);
     366      String nameOrId = kitMapper.getString(data);
    367367      Kit kit = findKit(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    368368      if (nameOrId == null || kit != null) bioAssay.setKit(kit);
     
    372372      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, bioAssay, Item.HARDWARE, 0);
    373373      defaultHardwareFunction.setCurrentSubtype(type);
    374       String nameOrId = hardwareMapper.getValue(data);
     374      String nameOrId = hardwareMapper.getString(data);
    375375      Hardware hardware = findHardware(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    376376      if (nameOrId == null || hardware != null) bioAssay.setHardware(hardware);
     
    380380      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, bioAssay, Item.SOFTWARE, 0);
    381381      defaultSoftwareFunction.setCurrentSubtype(type);
    382       String nameOrId = softwareMapper.getValue(data);
     382      String nameOrId = softwareMapper.getString(data);
    383383      Software software = findSoftware(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    384384      if (nameOrId == null || software != null) bioAssay.setSoftware(software);
     
    397397    if (fileTypeMapper != null && fileMapper != null)
    398398    {
    399       String fileTypeNameOrId = fileTypeMapper.getValue(data);
    400       String filePath = fileMapper.getValue(data);
     399      String fileTypeNameOrId = fileTypeMapper.getString(data);
     400      String filePath = fileMapper.getString(data);
    401401      DataFileType fileType = findDataFileType(dc,
    402402          FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, fileTypeNameOrId);
     
    418418    if (parentMapper != null)
    419419    {
    420       String nameOrId = parentMapper.getValue(data);
     420      String nameOrId = parentMapper.getString(data);
    421421      Item parentType = bioAssay.isRoot() ? Item.PHYSICALBIOASSAY : Item.DERIVEDBIOASSAY;
    422422     
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ExtractImporter.java

    r7589 r7666  
    216216  protected void updateItem(DbControl dc, Extract extract, FlatFileParser.Data data)
    217217  {
    218     if (nameMapper != null) extract.setName(nameMapper.getValue(data));
    219     if (descriptionMapper != null) extract.setDescription(descriptionMapper.getValue(data));
    220     if (externalIdMapper != null) extract.setExternalId(externalIdMapper.getValue(data));
     218    if (nameMapper != null) extract.setName(nameMapper.getString(data));
     219    if (descriptionMapper != null) extract.setDescription(descriptionMapper.getString(data));
     220    if (externalIdMapper != null) extract.setExternalId(externalIdMapper.getString(data));
    221221    if (originalQuantityMapper != null) extract.setOriginalQuantity(originalQuantityMapper.getFloat(data));
    222222    BioMaterialEvent creationEvent = extract.getCreationEvent();
     
    226226    if (tagMapper != null)
    227227    {
    228       String nameOrId = tagMapper.getValue(data);
     228      String nameOrId = tagMapper.getString(data);
    229229      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.TAG, 0);
    230230      Tag tag = findTag(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
     
    236236      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.PROTOCOL, SystemItems.getId(Protocol.EXTRACTION));
    237237      if (defaultPrototolFunction != null) defaultPrototolFunction.setCurrentSubtype(type);
    238       String nameOrId = protocolMapper.getValue(data);
     238      String nameOrId = protocolMapper.getString(data);
    239239      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    240240      if (nameOrId == null || protocol != null) creationEvent.setProtocol(protocol);
     
    243243    {
    244244      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.KIT, SystemItems.getId(Kit.EXTRACTION));
    245       String nameOrId = kitMapper.getValue(data);
     245      String nameOrId = kitMapper.getString(data);
    246246      Kit kit = findKit(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    247247      if (nameOrId == null || kit != null) creationEvent.setKit(kit);
     
    249249    if (bioPlateMapper != null && bioWellRowMapper != null && bioWellColMapper != null)
    250250    {
    251       String plateNameOrId = bioPlateMapper.getValue(data);
    252       String row = bioWellRowMapper.getValue(data);
    253       String column = bioWellColMapper.getValue(data);
     251      String plateNameOrId = bioPlateMapper.getString(data);
     252      String row = bioWellRowMapper.getString(data); // NOTE! Row/columns are typically alphanumeric: A1, B2, etc.
     253      String column = bioWellColMapper.getString(data);
    254254      BioPlate plate = findBioPlate(dc, FallbackIdMethod.NAME_OR_ID, plateNameOrId);
    255255      BioWell well = findBioWell(dc, plate, row, column);
     
    268268      if (parentTypeMapper != null)
    269269      {
    270         String type = parentTypeMapper.getValue(data);
     270        String type = parentTypeMapper.getString(data);
    271271        if (type != null) parentType = Item.valueOf(type);
    272272      }
     
    286286
    287287      // Try to find either a sample or a biosource
    288       String nameOrId = parentMapper.getValue(data);
     288      String nameOrId = parentMapper.getString(data);
    289289      BioMaterial parent = null;
    290290      if (parentType == Item.EXTRACT)
     
    317317    if (parentMapper != null && extract.getParentType() == Item.EXTRACT)
    318318    {
    319       String nameOrId = parentMapper.getValue(data);
     319      String nameOrId = parentMapper.getString(data);
    320320      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, extract, Item.EXTRACT, 0);
    321321      Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/FileImporter.java

    r6520 r7666  
    210210  protected File createItem(DbControl dc, FlatFileParser.Data data)
    211211  {
    212     String path = pathMapper.getValue(data);
     212    String path = pathMapper.getString(data);
    213213    Path filePath = new Path(resolvePath(path, getRootPath(dc)), Path.Type.FILE);
    214214    Directory d = getDirectory(dc, filePath);
     
    224224    if (pathMapper != null && file.isInDatabase())
    225225    {
    226       String path = pathMapper.getValue(data);
     226      String path = pathMapper.getString(data);
    227227      Path filePath = new Path(resolvePath(path, getRootPath(dc)), Path.Type.FILE);
    228228      file.setDirectory(getDirectory(dc, filePath));
     
    231231    if (fileServerMapper != null)
    232232    {
    233       String nameOrId = fileServerMapper.getValue(data);
     233      String nameOrId = fileServerMapper.getString(data);
    234234      FileServer server = findFileServer(dc, FallbackIdMethod.NAME_OR_ID, nameOrId);
    235235      if (nameOrId == null || server != null) file.setFileServer(server);
     
    237237    if (urlMapper != null)
    238238    {
    239       String url = urlMapper.getValue(data);
     239      String url = urlMapper.getString(data);
    240240      if (url == null)
    241241      {
     
    253253      }
    254254    }
    255     if (mimeTypeMapper != null) file.setMimeType(mimeTypeMapper.getValue(data));
     255    if (mimeTypeMapper != null) file.setMimeType(mimeTypeMapper.getString(data));
    256256    if (file.getMimeType() == null) file.setMimeTypeAuto(null, null);
    257     if (characterSetMapper != null) file.setMimeType(characterSetMapper.getValue(data));
    258     if (descriptionMapper != null) file.setDescription(descriptionMapper.getValue(data));
     257    if (characterSetMapper != null) file.setMimeType(characterSetMapper.getString(data));
     258    if (descriptionMapper != null) file.setDescription(descriptionMapper.getString(data));
    259259    updateItemSubtype(dc, file, data);
    260260  }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/KitImporter.java

    r7589 r7666  
    181181  protected void updateItem(DbControl dc, Kit kit, FlatFileParser.Data data)
    182182  {
    183     if (nameMapper != null) kit.setName(nameMapper.getValue(data));
    184     if (descriptionMapper != null) kit.setDescription(descriptionMapper.getValue(data));
     183    if (nameMapper != null) kit.setName(nameMapper.getString(data));
     184    if (descriptionMapper != null) kit.setDescription(descriptionMapper.getString(data));
    185185    if (expirationDateMapper != null) kit.setExpirationDate(parseDate(expirationDateMapper.getValue(data)));
    186     if (inactiveMapper != null) kit.setInactive(Values.getBoolean(inactiveMapper.getValue(data)));
     186    if (inactiveMapper != null) kit.setInactive(Values.getBoolean(inactiveMapper.getString(data)));
    187187
    188188    updateItemSubtype(dc, kit, data);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/PhysicalBioAssayImporter.java

    r7589 r7666  
    262262  protected void updateItem(DbControl dc, PhysicalBioAssay pba, FlatFileParser.Data data)
    263263  {
    264     if (nameMapper != null) pba.setName(nameMapper.getValue(data));
    265     if (descriptionMapper != null) pba.setDescription(descriptionMapper.getValue(data));
     264    if (nameMapper != null) pba.setName(nameMapper.getString(data));
     265    if (descriptionMapper != null) pba.setDescription(descriptionMapper.getString(data));
    266266    if (sizeMapper != null) pba.setSize(sizeMapper.getInt(data));
    267267    BioMaterialEvent creationEvent = pba.getCreationEvent();
     
    272272      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, pba, Item.PROTOCOL, 0);
    273273      defaultProtocolFunction.setCurrentSubtype(type);
    274       String nameOrId = protocolMapper.getValue(data);
     274      String nameOrId = protocolMapper.getString(data);
    275275      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    276276      if (nameOrId == null || protocol != null) creationEvent.setProtocol(protocol);
     
    279279    {
    280280      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, pba, Item.KIT, 0);
    281       String nameOrId = kitMapper.getValue(data);
     281      String nameOrId = kitMapper.getString(data);
    282282      Kit kit = findKit(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    283283      if (nameOrId == null || kit != null) creationEvent.setKit(kit);
     
    287287      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, pba, Item.HARDWARE, 0);
    288288      defaultHardwareFunction.setCurrentSubtype(type);
    289       String nameOrId = hardwareMapper.getValue(data);
     289      String nameOrId = hardwareMapper.getString(data);
    290290      Hardware hardware = findHardware(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    291291      if (nameOrId == null || hardware != null) creationEvent.setHardware(hardware);
     
    293293    if (arraySlideMapper != null)
    294294    {
    295       String nameOrId = arraySlideMapper.getValue(data);
     295      String nameOrId = arraySlideMapper.getString(data);
    296296      ArraySlide slide = findArraySlide(dc, FallbackIdMethod.NAME_OR_BARCODE_OR_ID, nameOrId);
    297297      if (slide != null && slide.isUsedByOther(pba))
     
    331331    if (parentMapper != null)
    332332    {
    333       String nameOrId = parentMapper.getValue(data);
     333      String nameOrId = parentMapper.getString(data);
    334334      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, pba, Item.EXTRACT, 0);
    335335      Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/RawBioAssayImporter.java

    r7589 r7666  
    313313    if (platformMapper != null)
    314314    {
    315       platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getValue(data));
     315      platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getString(data));
    316316    }
    317317    else
     
    321321    if (variantMapper != null)
    322322    {
    323       variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getValue(data));
     323      variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getString(data));
    324324    }
    325325    else
     
    327327      variant = getProjectDefaultVariant(dc);
    328328    }
    329     if (rawDataTypeMapper != null) rawDataTypeId = rawDataTypeMapper.getValue(data);
     329    if (rawDataTypeMapper != null) rawDataTypeId = rawDataTypeMapper.getString(data);
    330330    RawDataType rawDataType = findRawDataType(dc, platform, variant, rawDataTypeId);
    331331   
     
    353353  protected void updateItem(DbControl dc, RawBioAssay rba, FlatFileParser.Data data)
    354354  {
    355     if (nameMapper != null) rba.setName(nameMapper.getValue(data));
    356     if (descriptionMapper != null) rba.setDescription(descriptionMapper.getValue(data));
     355    if (nameMapper != null) rba.setName(nameMapper.getString(data));
     356    if (descriptionMapper != null) rba.setDescription(descriptionMapper.getString(data));
    357357    ArrayDesign designFromBioAssay = null;
    358358    Extract extractFromBioAssay = null;
    359359    if (bioAssayMapper != null)
    360360    {
    361       String nameOrId = bioAssayMapper.getValue(data);
     361      String nameOrId = bioAssayMapper.getString(data);
    362362      DerivedBioAssay bioAssay = findDerivedBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, null);
    363363      if (nameOrId == null || bioAssay != null) rba.setParentBioAssay(bioAssay);
     
    381381    if (extractMapper != null)
    382382    {
    383       String nameOrId = extractMapper.getValue(data);
     383      String nameOrId = extractMapper.getString(data);
    384384      Extract extract = nameOrId == null ?
    385385          extractFromBioAssay : findExtract(dc, FallbackIdMethod.NAME_OR_ID, nameOrId);
     
    395395      if (arrayDesignMapper != null)
    396396      {
    397         String nameOrId = arrayDesignMapper.getValue(data);
     397        String nameOrId = arrayDesignMapper.getString(data);
    398398        ArrayDesign design = nameOrId == null ?
    399399            designFromBioAssay : findArrayDesign(dc, FallbackIdMethod.NAME_OR_ID, nameOrId);
     
    412412        if (platformMapper != null)
    413413        {
    414           platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getValue(data));
     414          platform = findPlatform(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, platformMapper.getString(data));
    415415        }
    416416        else
     
    420420        if (variantMapper != null)
    421421        {
    422           variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getValue(data));
     422          variant = findVariant(dc, platform, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, variantMapper.getString(data));
    423423        }
    424424        else
     
    428428        if (rawDataTypeMapper != null)
    429429        {
    430           rawDataTypeId = rawDataTypeMapper.getValue(data);
     430          rawDataTypeId = rawDataTypeMapper.getString(data);
    431431        }
    432432        else
     
    449449      ItemSubtype type = ItemSubtype.getById(dc, SystemItems.getId(Protocol.FEATURE_EXTRACTION));
    450450      defaultProtocolFunction.setCurrentSubtype(type);
    451       String nameOrId = protocolMapper.getValue(data);
     451      String nameOrId = protocolMapper.getString(data);
    452452      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    453453      if (nameOrId == null || protocol != null) rba.setProtocol(protocol);
     
    457457      ItemSubtype type = ItemSubtype.getById(dc, SystemItems.getId(Software.FEATURE_EXTRACTION));
    458458      defaultSoftwareFunction.setCurrentSubtype(type);
    459       String nameOrId = softwareMapper.getValue(data);
     459      String nameOrId = softwareMapper.getString(data);
    460460      Software software = findSoftware(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    461461      if (nameOrId == null || software != null) rba.setSoftware(software);
     
    472472    if (fileTypeMapper != null && fileMapper != null)
    473473    {
    474       String fileTypeNameOrId = fileTypeMapper.getValue(data);
    475       String filePath = fileMapper.getValue(data);
     474      String fileTypeNameOrId = fileTypeMapper.getString(data);
     475      String filePath = fileMapper.getString(data);
    476476      DataFileType fileType = findDataFileType(dc,
    477477          FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, fileTypeNameOrId);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/SampleImporter.java

    r7588 r7666  
    313313  protected void updateItem(DbControl dc, Sample sample, FlatFileParser.Data data)
    314314  {
    315     if (nameMapper != null) sample.setName(nameMapper.getValue(data));
    316     if (descriptionMapper != null) sample.setDescription(descriptionMapper.getValue(data));
    317     if (externalIdMapper != null) sample.setExternalId(externalIdMapper.getValue(data));
     315    if (nameMapper != null) sample.setName(nameMapper.getString(data));
     316    if (descriptionMapper != null) sample.setDescription(descriptionMapper.getString(data));
     317    if (externalIdMapper != null) sample.setExternalId(externalIdMapper.getString(data));
    318318    if (originalQuantityMapper != null) sample.setOriginalQuantity(originalQuantityMapper.getFloat(data));
    319319    BioMaterialEvent creationEvent = sample.getCreationEvent();
     
    324324      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.PROTOCOL, SystemItems.getId(Protocol.SAMPLING));
    325325      if (defaultPrototolFunction != null) defaultPrototolFunction.setCurrentSubtype(type);
    326       String nameOrId = protocolMapper.getValue(data);
     326      String nameOrId = protocolMapper.getString(data);
    327327      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    328328      if (nameOrId == null || protocol != null) creationEvent.setProtocol(protocol);
     
    331331    {
    332332      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.KIT, SystemItems.getId(Kit.SAMPLING));
    333       String nameOrId = kitMapper.getValue(data);
     333      String nameOrId = kitMapper.getString(data);
    334334      Kit kit = findKit(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    335335      if (nameOrId == null || kit != null) creationEvent.setKit(kit);
     
    337337    if (bioPlateMapper != null && bioWellColMapper != null && bioWellRowMapper != null)
    338338    {
    339       String plateNameOrId = bioPlateMapper.getValue(data);
    340       String row = bioWellRowMapper.getValue(data);
    341       String column = bioWellColMapper.getValue(data);
     339      String plateNameOrId = bioPlateMapper.getString(data);
     340      String row = bioWellRowMapper.getString(data);
     341      String column = bioWellColMapper.getString(data);
    342342      BioPlate plate = findBioPlate(dc, FallbackIdMethod.NAME_OR_ID, plateNameOrId);
    343343      BioWell well = findBioWell(dc, plate, row, column);
     
    355355      if (parentTypeMapper != null)
    356356      {
    357         String type = parentTypeMapper.getValue(data);
     357        String type = parentTypeMapper.getString(data);
    358358        if (type != null) parentType = Item.valueOf(type);
    359359      }
     
    373373     
    374374      // Try to find either a sample or a biosource
    375       String nameOrId = parentMapper.getValue(data);
     375      String nameOrId = parentMapper.getString(data);
    376376      BioMaterial parent = null;
    377377      if (parentType == Item.SAMPLE)
     
    405405    if (parentMapper != null && sample.getParentType() == Item.SAMPLE)
    406406    {
    407       String nameOrId = parentMapper.getValue(data);
     407      String nameOrId = parentMapper.getString(data);
    408408      ItemSubtype type = ItemSubtype.getRelatedSubtype(dc, sample, Item.SAMPLE, 0);
    409409      Sample parent = findSample(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
  • trunk/src/test/TestFlatFileParser.java

    r7665 r7666  
    213213        for (Mapper m : mappings)
    214214        {
    215           sb.append(m+"={" + m.getValue(data) + "}\t");
     215          sb.append(m+"={" + m.getString(data) + "}\t");
    216216        }
    217217      }
Note: See TracChangeset for help on using the changeset viewer.