Changeset 5930


Ignore:
Timestamp:
Jan 20, 2012, 8:17:31 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1658: Batch importers fail to associate items with parent items

I have added a test case for this issue to the Sample importer.

Location:
branches/3.0-stable/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0-stable/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r5719 r5930  
    598598      if (subtypes.size() == 1)
    599599      {
    600         selectedSubtype = subtypes.get(0);
     600        selectedSubtype = ItemSubtype.getById(dc, subtypes.get(0).getId());
    601601        itemQuery.restrict(Restrictions.eq(Hql.property("itemSubtype"), subtypeParameter));
    602602        itemQuery.setEntityParameter("subtypes", selectedSubtype);
  • branches/3.0-stable/src/test/TestItemImporter.java

    r5696 r5930  
    2020  along with BASE. If not, see <http://www.gnu.org/licenses/>.
    2121*/
     22
     23import java.util.Collections;
    2224
    2325import net.sf.basedb.core.BaseException;
     
    2830import net.sf.basedb.core.Hardware;
    2931import net.sf.basedb.core.Item;
     32import net.sf.basedb.core.ItemSubtype;
    3033import net.sf.basedb.core.Job;
    3134import net.sf.basedb.core.ParameterType;
     
    7679    int freezerId = TestHardware.test_create(SystemItems.getId(Hardware.FREEZER), "Freezer", false);
    7780    int childScanId = TestItemSubtype.test_create(Item.DERIVEDBIOASSAY, "ChildScan", SystemItems.getId(DerivedBioAssay.SCAN));
     81    int allSamplesSubtypeId = TestItemSubtype.test_create(Item.SAMPLE, "All samples");
    7882   
    7983    // Import bioplates
    8084    int bioPlateFileId = TestFile.test_create("data/test.batchimport.bioplates.txt", false, false);
    8185    int bioPlateImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.BioPlateImporter");
    82     int bioPlateJobId = test_create_item_import_job(Item.BIOPLATE, bioPlateImporterId, bioPlateFileId);
     86    int bioPlateJobId = test_create_item_import_job(Item.BIOPLATE, bioPlateImporterId, bioPlateFileId, 0);
    8387    ok = ok & TestJob.test_execute(bioPlateJobId, false);
    8488    ok = ok & TestBioPlate.test_list(2);
     
    8791    int bioSourceFileId = TestFile.test_create("data/test.batchimport.biosources.txt", false, false);
    8892    int bioSourceImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.BioSourceImporter");
    89     int bioSourceJobId = test_create_item_import_job(Item.BIOSOURCE, bioSourceImporterId, bioSourceFileId);
     93    int bioSourceJobId = test_create_item_import_job(Item.BIOSOURCE, bioSourceImporterId, bioSourceFileId, 0);
    9094    ok = ok & TestJob.test_execute(bioSourceJobId, false);
    9195    ok = ok & TestBioSource.test_list(3);
     
    9498    int sampleFileId = TestFile.test_create("data/test.batchimport.samples.txt", false, false);
    9599    int sampleImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.SampleImporter");
    96     int sampleJobId = test_create_item_import_job(Item.SAMPLE, sampleImporterId, sampleFileId);
     100    int sampleJobId = test_create_item_import_job(Item.SAMPLE, sampleImporterId, sampleFileId, allSamplesSubtypeId);
    97101    ok = ok & TestJob.test_execute(sampleJobId, false);
    98102    ok = ok & TestSample.test_list(4);
     
    101105    int extractFileId = TestFile.test_create("data/test.batchimport.extracts.txt", false, false);
    102106    int extractImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.ExtractImporter");
    103     int extractJobId = test_create_item_import_job(Item.EXTRACT, extractImporterId, extractFileId);
     107    int extractJobId = test_create_item_import_job(Item.EXTRACT, extractImporterId, extractFileId, 0);
    104108    ok = ok & TestJob.test_execute(extractJobId, false);
    105109    ok = ok & TestExtract.test_list(0, 4);
     
    108112    int labledExtractFileId = TestFile.test_create("data/test.batchimport.labeledextracts.txt", false, false);
    109113    int labledExtractImporterId  = extractImporterId;
    110     int labledExtractJobId = test_create_item_import_job(Item.EXTRACT, labledExtractImporterId, labledExtractFileId);
     114    int labledExtractJobId = test_create_item_import_job(Item.EXTRACT, labledExtractImporterId, labledExtractFileId, 0);
    111115    ok = ok & TestJob.test_execute(labledExtractJobId, false);
    112116    ok = ok & TestExtract.test_list(SystemItems.getId(Extract.LABELED), 7);
     
    119123    int designFileId = TestFile.test_create("data/test.batchimport.arraydesigns.txt", false, false);
    120124    int designImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.ArrayDesignImporter");
    121     int designJobId = test_create_item_import_job(Item.ARRAYDESIGN, designImporterId, designFileId);
     125    int designJobId = test_create_item_import_job(Item.ARRAYDESIGN, designImporterId, designFileId, 0);
    122126    ok = ok & TestJob.test_execute(designJobId, false);
    123127    ok = ok & TestArrayDesign.test_list(3);
     
    126130    int arrayBatchFileId = TestFile.test_create("data/test.batchimport.arraybatches.txt", false, false);
    127131    int arrayBatchImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.ArrayBatchImporter");
    128     int arrayBatchJobId = test_create_item_import_job(Item.ARRAYBATCH, arrayBatchImporterId, arrayBatchFileId);
     132    int arrayBatchJobId = test_create_item_import_job(Item.ARRAYBATCH, arrayBatchImporterId, arrayBatchFileId, 0);
    129133    ok = ok & TestJob.test_execute(arrayBatchJobId, false);
    130134    ok = ok & TestArrayBatch.test_list(3);
     
    133137    int arraySlideFileId = TestFile.test_create("data/test.batchimport.arrayslides.txt", false, false);
    134138    int arraySlideImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.ArraySlideImporter");
    135     int arraySlideJobId = test_create_item_import_job(Item.ARRAYSLIDE, arraySlideImporterId, arraySlideFileId);
     139    int arraySlideJobId = test_create_item_import_job(Item.ARRAYSLIDE, arraySlideImporterId, arraySlideFileId, 0);
    136140    ok = ok & TestJob.test_execute(arraySlideJobId, false);
    137141    ok = ok & TestArraySlide.test_list(5);
     
    140144    int hybFileId = TestFile.test_create("data/test.batchimport.hybridizations.txt", false, false);
    141145    int hybImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.PhysicalBioAssayImporter");
    142     int hybJobId = test_create_item_import_job(Item.PHYSICALBIOASSAY, hybImporterId, hybFileId);
     146    int hybJobId = test_create_item_import_job(Item.PHYSICALBIOASSAY, hybImporterId, hybFileId, 0);
    143147    ok = ok & TestJob.test_execute(hybJobId, false);
    144148    ok = ok & TestPhysicalBioAssay.test_list(3);
     
    149153    int scanFileId = TestFile.test_create("data/test.batchimport.scans.txt", false, false);
    150154    int scanImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.DerivedBioAssayImporter");
    151     int scanJobId = test_create_item_import_job(Item.DERIVEDBIOASSAY, scanImporterId, scanFileId);
     155    int scanJobId = test_create_item_import_job(Item.DERIVEDBIOASSAY, scanImporterId, scanFileId, 0);
    152156    ok = ok & TestJob.test_execute(scanJobId, false);
    153157    ok = ok & TestDerivedBioAssay.test_list(0, 4);
     
    160164    int rbaFileId = TestFile.test_create("data/test.batchimport.rawbioassays.txt", false, false);
    161165    int rbaImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.RawBioAssayImporter");
    162     int rbaJobId = test_create_item_import_job(Item.RAWBIOASSAY, rbaImporterId, rbaFileId);
     166    int rbaJobId = test_create_item_import_job(Item.RAWBIOASSAY, rbaImporterId, rbaFileId, 0);
    163167    ok = ok & TestJob.test_execute(rbaJobId, false);
    164168    ok = ok & TestRawBioAssay.test_list(4);
     
    242246    TestPlatform.test_delete_variant(variantId);
    243247    TestItemSubtype.test_delete(childScanId);
     248    TestItemSubtype.test_delete(allSamplesSubtypeId);
    244249
    245250    write("++Testing item import using plugin "+(ok ? "OK" : "Failed")+"\n");
     
    247252  }
    248253
    249   static int test_create_item_import_job(Item itemType, int pluginDefinitionId, int fileId)
     254  static int test_create_item_import_job(Item itemType, int pluginDefinitionId, int fileId, int subtypeId)
    250255  {
    251256    if (pluginDefinitionId == 0 || fileId == 0) return 0;
     
    267272      setParserParameters(request);
    268273      setColumnMappingParameters(request, itemType, file);
     274      if (subtypeId != 0)
     275      {
     276        request.setParameterValues("itemSubtypes", Collections.singletonList(ItemSubtype.getById(dc, subtypeId)));
     277      }
     278     
     279     
    269280      PluginResponse response = request.invoke();
    270281      if (response.getStatus() != Response.Status.CONTINUE)
Note: See TracChangeset for help on using the changeset viewer.