Changeset 2998
- Timestamp:
- Dec 4, 2006, 10:28:39 AM (16 years ago)
- 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 59 59 as = AnnotationSet.getNew(dc, this); 60 60 getData().setAnnotationSet(as.getData()); 61 dc.saveItemIf(this, as );61 dc.saveItemIf(this, as, false); 62 62 } 63 63 return as; -
trunk/src/core/net/sf/basedb/core/AnnotationSet.java
r2992 r2998 280 280 a = Annotation.getNew(dc, annotationType, this); 281 281 getData().getAnnotations().put(annotationType.getData(), a.getData()); 282 dc.saveItemIf(this, a );282 dc.saveItemIf(this, a, false); 283 283 } 284 284 return a; -
trunk/src/core/net/sf/basedb/core/BioAssay.java
r2892 r2998 186 186 as = AnnotationSet.getNew(dc, this); 187 187 getData().setAnnotationSet(as.getData()); 188 dc.saveItemIf(this, as );188 dc.saveItemIf(this, as, false); 189 189 } 190 190 return as; -
trunk/src/core/net/sf/basedb/core/BioAssaySet.java
r2993 r2998 245 245 as = AnnotationSet.getNew(dc, this); 246 246 getData().setAnnotationSet(as.getData()); 247 dc.saveItemIf(this, as );247 dc.saveItemIf(this, as, false); 248 248 } 249 249 return as; -
trunk/src/core/net/sf/basedb/core/DbControl.java
r2929 r2998 96 96 @see #saveItemIf(BasicItem, BasicItem) 97 97 */ 98 private Map<BasicItem, List< BasicItem>> saveIfQueue;98 private Map<BasicItem, List<SaveIf>> saveIfQueue; 99 99 100 100 /** … … 815 815 item.initPermissions(0, 0); 816 816 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 817 834 commitQueue.put(item, Transactional.Action.CREATE); 818 835 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); 828 844 } 829 845 } … … 842 858 @param itemIf The parent item that must be saved 843 859 @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 844 862 @see #saveItem(BasicItem) 845 846 public void saveItemIf(BasicItem itemIf, BasicItem item )863 */ 864 public void saveItemIf(BasicItem itemIf, BasicItem item, boolean before) 847 865 { 848 866 if (itemIf == null || item == null) return; … … 853 871 else 854 872 { 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); 857 875 if (items == null) 858 876 { 859 items = new LinkedList< BasicItem>();877 items = new LinkedList<SaveIf>(); 860 878 saveIfQueue.put(itemIf, items); 861 879 } 862 items.add( item);880 items.add(new SaveIf(item, before)); 863 881 } 864 882 } … … 1029 1047 } 1030 1048 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 1031 1062 } -
trunk/src/core/net/sf/basedb/core/DynamicResultIterator.java
r2601 r2998 45 45 46 46 /** 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 /** 47 53 The results of the query. 48 54 */ … … 104 110 try 105 111 { 112 results.getStatement().close(); 106 113 results.close(); 107 results.getStatement().close();108 114 } 109 115 catch (SQLException ex) 110 116 { 111 throw new DatabaseException(ex);117 log.warn("Exception when closing result set", ex); 112 118 } 113 119 } -
trunk/src/core/net/sf/basedb/core/RawBioAssay.java
r2898 r2998 492 492 { 493 493 spotImages = SpotImages.getNew(getDbControl(), this); 494 getDbControl().saveItemIf(this, spotImages );494 getDbControl().saveItemIf(this, spotImages, false); 495 495 } 496 496 else -
trunk/src/core/net/sf/basedb/core/Transformation.java
r2498 r2998 447 447 } 448 448 DataCubeLayer layer = namedLayers.get(namedLayer); 449 DbControl dc = getDbControl(); 450 DataCube cube = null; 449 451 if (layer == null) 450 452 { 451 DataCubecube = namedCubes.get(namedCube);453 cube = namedCubes.get(namedCube); 452 454 if (cube == null) 453 455 { … … 458 460 namedLayers.put(namedLayer, layer); 459 461 } 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); 461 465 462 466 if (namedCube == null && createChildBioAssays) 463 467 { 464 DbControl dc = getDbControl();465 468 BioAssaySet source = getSource(); 466 469 for (BioAssay parentBa : source.getBioAssays().list(dc)) 467 470 { 468 471 BioAssay childBa = newBas.newBioAssay(parentBa); 469 dc.saveItemIf(newBas, childBa );472 dc.saveItemIf(newBas, childBa, false); 470 473 } 471 474 } -
trunk/src/core/net/sf/basedb/core/Well.java
r2898 r2998 128 128 as = AnnotationSet.getNew(dc, this); 129 129 getData().setAnnotationSet(as.getData()); 130 dc.saveItemIf(this, as );130 dc.saveItemIf(this, as, false); 131 131 } 132 132 return as; -
trunk/src/core/net/sf/basedb/core/data/BioAssaySetData.java
r2962 r2998 138 138 Get the layer this bioassayset stores it's data in. 139 139 @hibernate.many-to-one column="`datacubelayer_id`" not-null="true" outer-join="false" 140 update="false" cascade="save-update"140 update="false" 141 141 */ 142 142 public DataCubeLayerData getDataCubeLayer() -
trunk/src/core/net/sf/basedb/core/data/DataCubeLayerData.java
r2962 r2998 44 44 Get the data cube this layer belongs to. 45 45 @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" 47 47 */ 48 48 public DataCubeData getDataCube() -
trunk/src/core/net/sf/basedb/util/BioAssaySetFilterUtil.java
r2981 r2998 130 130 { 131 131 BioAssay childBa = child.newBioAssay(parentBa); 132 dc.saveItemIf(child, childBa );132 dc.saveItemIf(child, childBa, false); 133 133 spotsDone += parentBa.getNumSpots(); 134 134 query.setParameter("column", (int)parentBa.getDataCubeColumnNo(), Type.INT); … … 193 193 BioAssay ba = bioAssays.get(i); 194 194 BioAssay childBa = child.newBioAssay(ba); 195 dc.saveItemIf(child, childBa );195 dc.saveItemIf(child, childBa, false); 196 196 selectedColumns[i] = Expressions.integer(ba.getDataCubeColumnNo()); 197 197 spotsTotal += ba.getNumSpots();
Note: See TracChangeset
for help on using the changeset viewer.