Changeset 2998


Ignore:
Timestamp:
Dec 4, 2006, 10:28:39 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #215: Incorrect use of DynamicSpotQuery?...

Fixed problem with DataCube?.onBeforeCommit() never beeing called, and no spot count was generated.

Location:
trunk/src/core/net/sf/basedb
Files:
12 edited

Legend:

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

    r2875 r2998  
    5959      as = AnnotationSet.getNew(dc, this);
    6060      getData().setAnnotationSet(as.getData());
    61       dc.saveItemIf(this, as);
     61      dc.saveItemIf(this, as, false);
    6262    }
    6363    return as;
  • trunk/src/core/net/sf/basedb/core/AnnotationSet.java

    r2992 r2998  
    280280      a = Annotation.getNew(dc, annotationType, this);
    281281      getData().getAnnotations().put(annotationType.getData(), a.getData());
    282       dc.saveItemIf(this, a);
     282      dc.saveItemIf(this, a, false);
    283283    }
    284284    return a;
  • trunk/src/core/net/sf/basedb/core/BioAssay.java

    r2892 r2998  
    186186      as = AnnotationSet.getNew(dc, this);
    187187      getData().setAnnotationSet(as.getData());
    188       dc.saveItemIf(this, as);
     188      dc.saveItemIf(this, as, false);
    189189    }
    190190    return as;
  • trunk/src/core/net/sf/basedb/core/BioAssaySet.java

    r2993 r2998  
    245245      as = AnnotationSet.getNew(dc, this);
    246246      getData().setAnnotationSet(as.getData());
    247       dc.saveItemIf(this, as);
     247      dc.saveItemIf(this, as, false);
    248248    }
    249249    return as;
  • trunk/src/core/net/sf/basedb/core/DbControl.java

    r2929 r2998  
    9696    @see #saveItemIf(BasicItem, BasicItem)
    9797  */
    98   private Map<BasicItem, List<BasicItem>> saveIfQueue;
     98  private Map<BasicItem, List<SaveIf>> saveIfQueue;
    9999 
    100100  /**
     
    815815    item.initPermissions(0, 0);
    816816    item.checkPermission(Permission.CREATE);
     817
     818    // Check save-if queue
     819    List<SaveIf> saveIfItems = saveIfQueue == null ? null : saveIfQueue.remove(item);
     820   
     821    // Save items with before=TRUE
     822    if (saveIfItems != null)
     823    {
     824      for (SaveIf ifItem : saveIfItems)
     825      {
     826        if (ifItem.before && !ifItem.item.isInDatabase())
     827        {
     828          saveItem(ifItem.item);
     829        }
     830      }
     831    }
     832   
     833    // Save the item
    817834    commitQueue.put(item, Transactional.Action.CREATE);
    818835   
    819     // Check save-if queue
    820     if (saveIfQueue != null)
    821     {
    822       List<BasicItem> items = saveIfQueue.remove(item);
    823       if (items != null)
    824       {
    825         for (BasicItem cItem : items)
    826         {
    827           if (!cItem.isInDatabase()) saveItem(cItem);
     836    // Save items with before=FALSE
     837    if (saveIfItems != null)
     838    {
     839      for (SaveIf ifItem : saveIfItems)
     840      {
     841        if (!ifItem.before && !ifItem.item.isInDatabase())
     842        {
     843          saveItem(ifItem.item);
    828844        }
    829845      }
     
    842858    @param itemIf The parent item that must be saved
    843859    @param item The item to save when the parent item is saved
     860    @param before TRUE if the <code>item</code> should be saved before the <code>itemIf</code>,
     861      FALSE to save <code>itemIf</code> first
    844862    @see #saveItem(BasicItem)
    845    */
    846   public void saveItemIf(BasicItem itemIf, BasicItem item)
     863  */
     864  public void saveItemIf(BasicItem itemIf, BasicItem item, boolean before)
    847865  {
    848866    if (itemIf == null || item == null) return;
     
    853871    else
    854872    {
    855       if (saveIfQueue == null) saveIfQueue = new HashMap<BasicItem, List<BasicItem>>();
    856       List<BasicItem> items = saveIfQueue.get(itemIf);
     873      if (saveIfQueue == null) saveIfQueue = new HashMap<BasicItem, List<SaveIf>>();
     874      List<SaveIf> items = saveIfQueue.get(itemIf);
    857875      if (items == null)
    858876      {
    859         items = new LinkedList<BasicItem>();
     877        items = new LinkedList<SaveIf>();
    860878        saveIfQueue.put(itemIf, items);
    861879      }
    862       items.add(item);
     880      items.add(new SaveIf(item, before));
    863881    }
    864882  }
     
    10291047  }
    10301048 
     1049  private static class SaveIf
     1050  {
     1051    private final BasicItem item;
     1052    private final boolean before;
     1053   
     1054    private SaveIf(BasicItem item, boolean before)
     1055    {
     1056      this.item = item;
     1057      this.before = before;
     1058    }
     1059  }
     1060 
     1061 
    10311062}
  • trunk/src/core/net/sf/basedb/core/DynamicResultIterator.java

    r2601 r2998  
    4545
    4646  /**
     47    Logger.
     48  */
     49  private static final org.apache.log4j.Logger log =
     50    org.apache.log4j.LogManager.getLogger("net.sf.basedb.core.query.DynamicResultIterator");
     51 
     52  /**
    4753    The results of the query.
    4854  */
     
    104110      try
    105111      {
     112        results.getStatement().close();
    106113        results.close();
    107         results.getStatement().close();
    108114      }
    109115      catch (SQLException ex)
    110116      {
    111         throw new DatabaseException(ex);
     117        log.warn("Exception when closing result set", ex);
    112118      }
    113119    }
  • trunk/src/core/net/sf/basedb/core/RawBioAssay.java

    r2898 r2998  
    492492    {
    493493      spotImages = SpotImages.getNew(getDbControl(), this);
    494       getDbControl().saveItemIf(this, spotImages);
     494      getDbControl().saveItemIf(this, spotImages, false);
    495495    }
    496496    else
  • trunk/src/core/net/sf/basedb/core/Transformation.java

    r2498 r2998  
    447447    }
    448448    DataCubeLayer layer = namedLayers.get(namedLayer);
     449    DbControl dc = getDbControl();
     450    DataCube cube = null;
    449451    if (layer == null)
    450452    {
    451       DataCube cube = namedCubes.get(namedCube);
     453      cube = namedCubes.get(namedCube);
    452454      if (cube == null)
    453455      {
     
    458460      namedLayers.put(namedLayer, layer);
    459461    }
    460     BioAssaySet newBas = BioAssaySet.getNew(getDbControl(), this, layer);
     462    BioAssaySet newBas = BioAssaySet.getNew(dc, this, layer);
     463    if (cube != null && !cube.isInDatabase()) dc.saveItemIf(newBas, cube, true);
     464    if (!layer.isInDatabase()) dc.saveItemIf(newBas, layer, true);
    461465   
    462466    if (namedCube == null && createChildBioAssays)
    463467    {
    464       DbControl dc = getDbControl();
    465468      BioAssaySet source = getSource();
    466469      for (BioAssay parentBa : source.getBioAssays().list(dc))
    467470      {
    468471        BioAssay childBa = newBas.newBioAssay(parentBa);
    469         dc.saveItemIf(newBas, childBa);
     472        dc.saveItemIf(newBas, childBa, false);
    470473      }
    471474    }
  • trunk/src/core/net/sf/basedb/core/Well.java

    r2898 r2998  
    128128      as = AnnotationSet.getNew(dc, this);
    129129      getData().setAnnotationSet(as.getData());
    130       dc.saveItemIf(this, as);
     130      dc.saveItemIf(this, as, false);
    131131    }
    132132    return as;
  • trunk/src/core/net/sf/basedb/core/data/BioAssaySetData.java

    r2962 r2998  
    138138    Get the layer this bioassayset stores it's data in.
    139139    @hibernate.many-to-one column="`datacubelayer_id`" not-null="true" outer-join="false"
    140       update="false" cascade="save-update"
     140      update="false"
    141141  */
    142142  public DataCubeLayerData getDataCubeLayer()
  • trunk/src/core/net/sf/basedb/core/data/DataCubeLayerData.java

    r2962 r2998  
    4444    Get the data cube this layer belongs to.
    4545    @hibernate.many-to-one column="`datacube_id`" not-null="true" outer-join="false"
    46       update="false" unique-key="uniquelayer" cascade="save-update"
     46      update="false" unique-key="uniquelayer"
    4747  */
    4848  public DataCubeData getDataCube()
  • trunk/src/core/net/sf/basedb/util/BioAssaySetFilterUtil.java

    r2981 r2998  
    130130    {
    131131      BioAssay childBa = child.newBioAssay(parentBa);
    132       dc.saveItemIf(child, childBa);
     132      dc.saveItemIf(child, childBa, false);
    133133      spotsDone += parentBa.getNumSpots();
    134134      query.setParameter("column", (int)parentBa.getDataCubeColumnNo(), Type.INT);
     
    193193        BioAssay ba = bioAssays.get(i);
    194194        BioAssay childBa = child.newBioAssay(ba);
    195         dc.saveItemIf(child, childBa);
     195        dc.saveItemIf(child, childBa, false);
    196196        selectedColumns[i] = Expressions.integer(ba.getDataCubeColumnNo());
    197197        spotsTotal += ba.getNumSpots();
Note: See TracChangeset for help on using the changeset viewer.