Changeset 3647


Ignore:
Timestamp:
Aug 9, 2007, 11:11:10 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #718: BioAssaySet? tries to calculate number of spots and reporter on non-existing table

Location:
trunk/src
Files:
2 edited

Legend:

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

    r2998 r3647  
    313313    if (action == Transactional.Action.CREATE)
    314314    {
     315      checkAndCreateTables();
    315316      countSpotsAndReporters();
    316317    }
     
    11771178  }
    11781179 
     1180  private void checkAndCreateTables()
     1181  {
     1182    VirtualDb vdb = getVirtualDb();
     1183    vdb.createTables(VirtualTable.SPOT, VirtualTable.POSITION);
     1184    if (getDataCubeFilterNo() != 0)
     1185    {
     1186      vdb.createTables(VirtualTable.FILTER);
     1187    }
     1188  }
     1189 
    11791190  /**
    11801191    Called when a bioassayset is about to be deleted. Finds which data cubes, layers,
  • trunk/src/test/TestExperiment.java

    r3626 r3647  
    3838import net.sf.basedb.util.ConsoleProgressReporter;
    3939
     40import java.util.Collections;
    4041import java.util.Date;
    4142import java.util.Set;
     
    8889    test_list_rawbioassays(id, 2);
    8990
     91    int emptyRootId = test_create_empty_root_bioassayset(id, rbaId1, rbaId2);
     92   
    9093    int rootBasId = test_create_root_bioassayset_using_calculator(id, "mean", rbaId1, rbaId2);
    9194    int rootBasId2 = test_create_root_bioassayset_using_query(id, "mean", rbaId1, rbaId2);
     
    109112    //int mergedBasId = test_merge_bioassays(filterBasId);
    110113   
    111     test_list_bioassaysets(id, 7);
     114    test_list_bioassaysets(id, 8);
    112115   
    113116    test_list_bioassays(basId, 2);
     
    600603    return id;
    601604  }
     605 
     606  static int test_create_empty_root_bioassayset(int experimentId, int... rawBioAssays)
     607  {
     608    if (experimentId == 0) return 0;
     609    int id = 0;
     610    DbControl dc = null;
     611    try
     612    {
     613      dc = TestUtil.getDbControl();
     614      Experiment e = Experiment.getById(dc, experimentId);
     615     
     616      Set<RawBioAssay> rbaCollection = new HashSet<RawBioAssay>();
     617      for (int rbaId : rawBioAssays)
     618      {
     619        rbaCollection.add(RawBioAssay.getById(dc, rbaId)); 
     620      }
     621     
     622      Transformation t = e.newTransformation(null, rbaCollection);
     623      BioAssaySet root = t.newProduct("new", "new", false);
     624      root.setName("No spots");
     625      dc.saveItem(t);
     626      dc.saveItem(root);
     627     
     628      for (RawBioAssay rba : rbaCollection)
     629      {
     630        // Create a new BioAssay for each raw bioassay
     631        BioAssay ba = root.newRootBioAssay(Collections.singleton(rba));
     632        ba.setName(rba.getName());
     633        dc.saveItem(ba);
     634      }
     635      dc.commit();
     636
     637      int numSpots = root.getNumSpots();
     638      id = root.getId();
     639      dc = TestUtil.getDbControl();
     640      dc.reattachItem(root);
     641      write_item(0, root);
     642      write("--Create empty root bioassayset OK ("+numSpots+" spots inserted)");
     643    }
     644    catch (Throwable ex)
     645    {
     646      write("--Create empty root bioassayset FAILED");
     647      ex.printStackTrace();
     648      ok = false;
     649    }
     650    finally
     651    {
     652      if (dc != null) dc.close();
     653    }
     654    return id;
     655  }
     656 
    602657 
    603658  static int test_create_bioassayset(int bioAssaySetId)
Note: See TracChangeset for help on using the changeset viewer.