Changeset 5662
- Timestamp:
- Jun 20, 2011, 1:55:13 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 2 deleted
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/BioMaterialEvent.java
r5650 r5662 26 26 import net.sf.basedb.core.query.Hql; 27 27 28 import net.sf.basedb.core.data.BioMaterialData; 28 29 import net.sf.basedb.core.data.BioMaterialEventData; 30 import net.sf.basedb.core.data.BioMaterialEventSourceData; 29 31 import net.sf.basedb.core.data.HardwareData; 30 32 import net.sf.basedb.core.data.MeasuredBioMaterialData; 31 33 import net.sf.basedb.core.data.ProtocolData; 32 34 import net.sf.basedb.core.data.UserData; 33 import net.sf.basedb.core.data.UsedQuantity;34 35 import net.sf.basedb.core.data.SharedData; 35 36 … … 37 38 import java.util.HashMap; 38 39 import java.util.Date; 39 import java.util.Iterator;40 40 41 41 /** … … 599 599 else 600 600 { 601 UsedQuantity used = getData().getSources().get((MeasuredBioMaterialData)bioMaterial.getData()); 602 return used == null ? null : used.getUsedQuantity(); 603 } 604 } 605 606 /** 607 Get the source group of the biomaterial 608 @param bioMaterial The source biomaterial 609 @return The source group index or 0 if the biomaterial is not a source of this event 610 @since 2.6 611 @see #setSourceGroup(MeasuredBioMaterial, int) 612 */ 613 public int getSourceGroup(MeasuredBioMaterial bioMaterial) 614 { 615 UsedQuantity used = getData().getSources().get(bioMaterial.getData()); 616 return used != null ? used.getSourceGroup() : 0; 617 } 618 619 /** 620 Add a source biomaterial to this event or update 621 the used quantity of an existing source. Sources can only be specified if 622 the produced biomaterial is a pooled biomaterial and this is a creation event. 623 624 @param bioMaterial The biomaterial used as a source 625 @param usedQuantity The quantity that was used from the source biomaterial 626 @throws PermissionDeniedException If the logged in user doesn't have 627 write permission for this event of use permission for the source 628 @throws InvalidDataException If this is not a creation event or 629 if the produced biomaterial is not pooled or if the source 630 biomaterial is of another type 631 @throws BaseException If there is another error 632 */ 633 public void addSource(MeasuredBioMaterial bioMaterial, Float usedQuantity) 634 throws PermissionDeniedException, InvalidDataException, BaseException 601 BioMaterialEventSourceData src = getData().getSources().get(bioMaterial.getData()); 602 return src == null ? null : src.getUsedQuantity(); 603 } 604 } 605 606 /** 607 Get information about a biomaterial used as a source to this event. 608 @param bioMaterial The biomaterial 609 @return A BioMaterialEventSource object or null if the given biomaterial 610 is not a source to the event 611 @see #addSource(BioMaterial) 612 */ 613 public BioMaterialEventSource getEventSource(BioMaterial bioMaterial) 614 { 615 BioMaterialEventSourceData src = getData().getSources().get(bioMaterial.getData()); 616 return src == null ? null : new BioMaterialEventSource(getDbControl(), src); //(this); 617 } 618 619 /** 620 Add a biomaterial as a source to this event. If the given biomaterial 621 already is a source, the existing information is returned. 622 623 @param bioMaterial The biomaterial 624 @return A BioMaterialEventSource object 625 */ 626 public BioMaterialEventSource addSource(BioMaterial bioMaterial) 635 627 { 636 628 checkPermission(Permission.RESTRICTED_WRITE); … … 638 630 bioMaterial.checkPermission(Permission.USE); 639 631 checkAllowedSource(bioMaterial); 640 MeasuredBioMaterialData data = (MeasuredBioMaterialData)bioMaterial.getData(); 641 UsedQuantity used = getData().getSources().get(data); 642 if (used != null) 643 { 644 // There is already an entry for this biomaterial 645 if (used.getUsedQuantity() != null) 646 { 647 // Return the old value to the biomaterial 648 MeasuredBioMaterial.updateRemainingQuantity(getDbControl(), data, -used.getUsedQuantity()); 649 } 650 // Set the new value 651 used.setUsedQuantity(usedQuantity); 652 } 653 else 654 { 655 // This is a new entry 656 used = new UsedQuantity(usedQuantity, 1); 657 getData().getSources().put(data, used); 658 } 659 if (usedQuantity != null) 660 { 661 // Take away the new used quantity from the biomaterial 662 MeasuredBioMaterial.updateRemainingQuantity(getDbControl(), data, usedQuantity); 663 } 664 } 665 666 /** 667 Set the source group for a biomaterial that was used as a source in this event. 668 The source group value is used to group sources that are related. The only 669 example and use case is when using multi-array hybridizations 670 where it is essential to know which array a labeled extract goes on. The source 671 group is then simply the number of the array on the hybridization and should be 672 a value between 1 and {@link PhysicalBioAssay#getSize()}. 673 <p> 674 A single labeled extract can only be used in a single group. Experiments using a n-channel 675 platform and a common reference must first split the reference labeled extract 676 into individual labeled extracts. This can be done with the 'pooling' functionality. 677 <p> 678 If the source biomaterial has not been added with {@link #addSource(MeasuredBioMaterial, Float)} 679 this method will automatically add it with usedQuantity = null. 680 681 @param bioMaterial The source biomaterial 682 @param sourceGroup The source group 683 @throws PermissionDeniedException If the logged in user doesn't have 684 write permission for this event of use permission for the source 685 @throws InvalidDataException If this is not a creation event or 686 if the produced biomaterial is not pooled or if the source 687 biomaterial is of another type 688 @since 2.6 689 */ 690 public void setSourceGroup(MeasuredBioMaterial bioMaterial, int sourceGroup) 691 throws PermissionDeniedException, InvalidDataException, BaseException 692 { 693 checkPermission(Permission.RESTRICTED_WRITE); 694 if (bioMaterial == null) throw new InvalidUseOfNullException("bioMaterial"); 695 MeasuredBioMaterialData data = (MeasuredBioMaterialData)bioMaterial.getData(); 696 697 UsedQuantity used = getData().getSources().get(data); 698 if (used == null) 699 { 700 addSource(bioMaterial, null); 701 used = getData().getSources().get(data); 702 } 703 if (used != null) 704 { 705 used.setSourceGroup(sourceGroup); 706 } 707 } 708 632 return addCheckedSource(bioMaterial); 633 } 634 635 private BioMaterialEventSource addCheckedSource(BioMaterial bioMaterial) 636 { 637 BioMaterialData bmData = (BioMaterialData)bioMaterial.getData(); 638 BioMaterialEventSourceData src = getData().getSources().get(bmData); 639 if (src == null) 640 { 641 src = new BioMaterialEventSourceData(); 642 src.setBioMaterial(bmData); 643 src.setEvent(this.getData()); 644 getData().getSources().put(bmData, src); 645 } 646 return new BioMaterialEventSource(getDbControl(), src); 647 } 648 709 649 /** 710 650 Remove a biomaterial used as a source. Sources can only be specified if … … 718 658 @throws BaseException If there is another error 719 659 */ 720 public void removeSource( MeasuredBioMaterial bioMaterial)660 public void removeSource(BioMaterial bioMaterial) 721 661 throws PermissionDeniedException, InvalidDataException, BaseException 722 662 { … … 724 664 if (bioMaterial == null) throw new InvalidUseOfNullException("bioMaterial"); 725 665 checkAllowedSource(bioMaterial); 726 MeasuredBioMaterialData data = (MeasuredBioMaterialData)bioMaterial.getData(); 727 UsedQuantity used = getData().getSources().remove(data); 728 Float usedQuantity = used == null ? null : used.getUsedQuantity(); 729 if (usedQuantity != null) MeasuredBioMaterial.updateRemainingQuantity(getDbControl(), data, -usedQuantity); 666 BioMaterialData data = (BioMaterialData)bioMaterial.getData(); 667 BioMaterialEventSourceData src = getData().getSources().remove(data); 668 if (src == null) return; 669 670 if (src.getId() != 0) getDbControl().getHibernateSession().delete(src); 671 if (data instanceof MeasuredBioMaterialData) 672 { 673 Float used = src.getUsedQuantity(); 674 if (used != null) 675 { 676 MeasuredBioMaterial.updateRemainingQuantity(getDbControl(), (MeasuredBioMaterialData)data, -used); 677 } 678 } 730 679 } 731 680 … … 739 688 </ul> 740 689 */ 741 private void checkAllowedSource( MeasuredBioMaterial bioMaterial)690 private void checkAllowedSource(BioMaterial bioMaterial) 742 691 throws PermissionDeniedException, InvalidDataException, BaseException 743 692 { … … 784 733 Set a single source. This method is used for non-pooled biomaterial 785 734 to specify the parent. 786 @see Extract#setSample(Sample , Float)787 */ 788 void setSource(MeasuredBioMaterial bioMaterial, Float usedQuantity)735 @see Extract#setSample(Sample) 736 */ 737 BioMaterialEventSource setSource(MeasuredBioMaterial bioMaterial) 789 738 throws PermissionDeniedException, InvalidDataException 790 739 { 791 740 clearSources(); 792 if (bioMaterial != null) 793 { 794 MeasuredBioMaterialData data = (MeasuredBioMaterialData)bioMaterial.getData(); 795 getData().getSources().put(data, new UsedQuantity(usedQuantity, 1)); 796 if (usedQuantity != null) MeasuredBioMaterial.updateRemainingQuantity(getDbControl(), data, usedQuantity); 797 } 741 return bioMaterial == null ? null : addCheckedSource(bioMaterial); 798 742 } 799 743 … … 804 748 void clearSources() 805 749 { 806 Iterator<Map.Entry<MeasuredBioMaterialData, UsedQuantity>> i = getData().getSources().entrySet().iterator(); 807 while (i.hasNext()) 808 { 809 Map.Entry<MeasuredBioMaterialData, UsedQuantity> entry = i.next(); 810 MeasuredBioMaterialData source = entry.getKey(); 811 UsedQuantity used = entry.getValue(); 812 Float usedQuantity = used == null ? null : used.getUsedQuantity(); 813 if (usedQuantity != null) MeasuredBioMaterial.updateRemainingQuantity(getDbControl(), source, -usedQuantity); 814 i.remove(); 815 } 750 DbControl dc = getDbControl(); 751 for (BioMaterialEventSourceData src : getData().getSources().values()) 752 { 753 BioMaterialData bioMaterial = src.getBioMaterial(); 754 Float used = src.getUsedQuantity(); 755 if (used != null && bioMaterial instanceof MeasuredBioMaterialData) 756 { 757 MeasuredBioMaterial.updateRemainingQuantity(dc, (MeasuredBioMaterialData)bioMaterial, -used); 758 } 759 dc.getHibernateSession().delete(src); 760 } 761 getData().getSources().clear(); 816 762 } 817 763 818 764 /** 819 765 Get a query that return all biomaterials used as sources 820 for this event. To filter or sort on the used quantity or source groupcolumns821 use 'srcevt' as alias. For example to only return sources in source group2766 for this event. To filter or sort on the used quantity or position columns 767 use 'srcevt' as alias. For example to only return sources in position 2 822 768 and to order the result by used quantity: 823 769 <pre class="code"> 824 770 query = event.getSources(); 825 771 query.restrict(Expressions.gteq( 826 Hql.property("srcevt", " sourceGroup"), Expressions.integer(2))772 Hql.property("srcevt", "position"), Expressions.integer(2)) 827 773 ); 828 774 query.order(Orders.asc(Hql.property("srcevt", "usedQuantity"))); … … 870 816 } 871 817 872 query.joinPermanent(Hql.innerJoin(" sourceEvents", "srcevt"));818 query.joinPermanent(Hql.innerJoin("childCreationEvents", "srcevt")); 873 819 query.joinPermanent(Hql.innerJoin("srcevt", "event", TYPE.getAlias())); 874 820 query.restrictPermanent( … … 882 828 883 829 /** 830 Create a special query that return BioMaterialEventSource objects. 831 The objects are not {@link BasicItem}:s but can be used to get information 832 about and modify the source biomaterials used in the event. Note 833 that the query may return objects that link to biomaterial that the 834 logged in used doesn't have read access to. 835 @return A special query 836 @since 3.0 837 */ 838 public SpecialQuery<BioMaterialEventSource> getEventSources() 839 { 840 SpecialQuery<BioMaterialEventSource> query = 841 new SpecialQuery<BioMaterialEventSource>(null, "BioMaterialEventSourceData", "es", 842 new BioMaterialEventSource.BioMaterialEventSourceTransformer()); 843 query.restrictPermanent(Restrictions.eq(Hql.property("es", "event"), Hql.entity(this))); 844 return query; 845 } 846 847 /** 884 848 The maximum length of the comment about this event. Check the length 885 849 against this value before calling the {@link #setComment(String)} -
trunk/src/core/net/sf/basedb/core/Extract.java
r5648 r5662 258 258 of this extract. 259 259 @param sample The new <code>Sample</code> item 260 @param usedQuantity The quantity that was used from the sample when261 the extract was created262 260 @throws PermissionDeniedException If the logged in user doesn't have 263 261 write permission for this extract or use permission for the sample 264 262 @throws InvalidDataException If this is a pooled extract 265 263 @throws BaseException If there is another error 266 */ 267 public void setSample(Sample sample, Float usedQuantity) 264 @since 3.0 265 */ 266 public BioMaterialEventSource setSample(Sample sample) 268 267 throws PermissionDeniedException, InvalidDataException, BaseException 269 268 { … … 275 274 } 276 275 getData().setParent(sample == null ? null : sample.getData()); 277 getCreationEvent().setSource(sample, usedQuantity);278 } 279 280 281 public void setExtract(Extract extract, Float usedQuantity)276 return getCreationEvent().setSource(sample); 277 } 278 279 280 public BioMaterialEventSource setExtract(Extract extract) 282 281 throws PermissionDeniedException, InvalidDataException, BaseException 283 282 { … … 286 285 287 286 getData().setPooled(true); 288 289 287 getData().setParent(extract == null ? null : extract.getData()); 290 getCreationEvent().setSource(extract, usedQuantity);288 return getCreationEvent().setSource(extract); 291 289 } 292 290 -
trunk/src/core/net/sf/basedb/core/Sample.java
r5643 r5662 281 281 { 282 282 Extract e = Extract.getNew(getDbControl(), master); 283 e.setSample(this ,usedQuantity);283 e.setSample(this).setUsedQuantity(usedQuantity); 284 284 return e; 285 285 } -
trunk/src/core/net/sf/basedb/core/data/BioMaterialData.java
r5643 r5662 120 120 } 121 121 122 private Set<BioMaterialEventSourceData> childCreationEvents; 123 /** 124 This is the inverse end. 125 @see BioMaterialEventSourceData#getBioMaterial() 126 @hibernate.set lazy="true" inverse="true" 127 @hibernate.collection-key column="`biomaterial_id`" 128 @hibernate.collection-one-to-many class="net.sf.basedb.core.data.BioMaterialEventSourceData" 129 */ 130 Set<BioMaterialEventSourceData> getChildCreationEvents() 131 { 132 return childCreationEvents; 133 } 134 void setChildCreationEvents(Set<BioMaterialEventSourceData> childCreationEvents) 135 { 136 this.childCreationEvents = childCreationEvents; 137 } 138 122 139 } -
trunk/src/core/net/sf/basedb/core/data/BioMaterialEventData.java
r5642 r5662 26 26 import java.util.Map; 27 27 import java.util.HashMap; 28 import java.util.Set;29 28 30 29 /** … … 123 122 private PhysicalBioAssayData bioassay; 124 123 /** 125 Get the hybridizationthat was created by this event.124 Get the physical bioassay that was created by this event. 126 125 @hibernate.many-to-one column="`physicalbioassay_id`" not-null="false" outer-join="false" update="false" 127 126 */ … … 210 209 } 211 210 212 private Map<MeasuredBioMaterialData, UsedQuantity> sources; 213 /** 214 Get a map containing the source biomaterials and the used quantity for 215 this event. 216 @hibernate.map table="`BioMaterialEventSources`" lazy="true" cascade="delete" 211 private Map<BioMaterialData, BioMaterialEventSourceData> sources; 212 /** 213 Get a map containing information about the source biomaterials used 214 in the event. This is only used for events that create child biomaterial or 215 physical bioassay. This is the inverse end. See 216 {@link BioMaterialEventSourceData#getEvent()} 217 @hibernate.map inverse="true" lazy="true" cascade="all" 217 218 @hibernate.collection-key column="`event_id`" 218 @hibernate.index-many-to-many column="`biomaterial_id`" class="net.sf.basedb.core.data.MeasuredBioMaterialData" 219 @hibernate.collection-composite-element class="net.sf.basedb.core.data.UsedQuantity" 220 */ 221 public Map<MeasuredBioMaterialData, UsedQuantity> getSources() 222 { 223 if (sources == null) sources = new HashMap<MeasuredBioMaterialData, UsedQuantity>(); 219 @hibernate.index-many-to-many column="`biomaterial_id`" class="net.sf.basedb.core.data.BioMaterialData" 220 @hibernate.collection-one-to-many class="net.sf.basedb.core.data.BioMaterialEventSourceData" 221 @since 3.0 222 */ 223 public Map<BioMaterialData, BioMaterialEventSourceData> getSources() 224 { 225 if (sources == null) 226 { 227 sources = new HashMap<BioMaterialData, BioMaterialEventSourceData>(); 228 } 224 229 return sources; 225 230 } 226 void setSources(Map< MeasuredBioMaterialData, UsedQuantity> sources)231 void setSources(Map<BioMaterialData, BioMaterialEventSourceData> sources) 227 232 { 228 233 this.sources = sources; 229 234 } 230 235 231 private Set<MeasuredBioMaterialData> sourceBioMaterials;232 /**233 This is the inverse end. The children is the non-pooled biomaterials234 that has this item as a parent.235 @see MeasuredBioMaterialData#getParent()236 @since 2.9237 @hibernate.set table="`BioMaterialEventSources`" inverse="true" lazy="true"238 @hibernate.collection-key column="`event_id`"239 @hibernate.collection-many-to-many column="`biomaterial_id`" class="net.sf.basedb.core.data.MeasuredBioMaterialData"240 */241 Set<MeasuredBioMaterialData> getSourceBioMaterials()242 {243 return sourceBioMaterials;244 }245 void setSourceBioMaterials(Set<MeasuredBioMaterialData> sourceBioMaterials)246 {247 this.sourceBioMaterials = sourceBioMaterials;248 }249 250 236 } -
trunk/src/core/net/sf/basedb/core/data/MeasuredBioMaterialData.java
r5643 r5662 133 133 } 134 134 135 private Set<BioMaterialSourceEventData> sourceEvents;136 /**137 This is the inverse end.138 @see BioMaterialEventData#getSources()139 @hibernate.set table="`BioMaterialEventSources`" lazy="true" inverse="true"140 @hibernate.collection-key column="`biomaterial_id`"141 @hibernate.collection-composite-element class="net.sf.basedb.core.data.BioMaterialSourceEventData"142 hibernate.collection-many-to-many column="`event_id`" class="net.sf.basedb.core.data.BioMaterialEventData"143 */144 Set<BioMaterialSourceEventData> getSourceEvents()145 {146 return sourceEvents;147 }148 void setSourceEvents(Set<BioMaterialSourceEventData> sourceEvents)149 {150 this.sourceEvents = sourceEvents;151 }152 153 135 private BioWellData bioWell; 154 136 /** -
trunk/src/core/net/sf/basedb/util/biomaterial/PooledChildrenTransformer.java
r4723 r5662 61 61 query.include(Include.ALL); 62 62 query.join(Hql.innerJoin("creationEvent", "ce")); 63 query.join(Hql.innerJoin("ce", "sourceBioMaterials", "sbm")); 63 query.join(Hql.innerJoin("ce", "sources", "sbm")); 64 query.join(Hql.innerJoin("sbm", "bioMaterial", "bm")); 64 65 query.restrict( 65 66 Restrictions.in( 66 Hql.alias(" sbm"),67 Hql.alias("bm"), 67 68 Expressions.parameter("sources") 68 69 ) -
trunk/src/core/net/sf/basedb/util/biomaterial/PooledParentsTransformer.java
r4723 r5662 60 60 this.query = query; 61 61 query.include(Include.ALL); 62 query.join(Hql.innerJoin(" sourceEvents", "se"));63 query.join(Hql.innerJoin(" se", "event", "evt"));62 query.join(Hql.innerJoin("childCreationEvents", "ce")); 63 query.join(Hql.innerJoin("ce", "event", "evt")); 64 64 query.restrict( 65 65 Restrictions.in( -
trunk/src/core/net/sf/basedb/util/overview/loader/PhysicalBioAssayLoader.java
r5657 r5662 200 200 { 201 201 PhysicalBioAssay bioAssay = it.next(); 202 int arrayNum = bioAssay.getCreationEvent().getSourceGroup(extract);203 Object cacheKey = arrayNum == 0 ? bioAssay : new IndexedCacheKey(bioAssay, arrayNum);202 int position = bioAssay.getCreationEvent().getEventSource(extract).getPosition(); 203 Object cacheKey = position == 0 ? bioAssay : new IndexedCacheKey(bioAssay, position); 204 204 if (folderNode == null) 205 205 { -
trunk/src/core/net/sf/basedb/util/overview/loader/RawBioAssayLoader.java
r5652 r5662 23 23 24 24 25 import net.sf.basedb.core.BioMaterialEventSource; 25 26 import net.sf.basedb.core.DbControl; 26 27 import net.sf.basedb.core.DerivedBioAssay; … … 82 83 // to be able to load the correct raw bioassays -- The same physical bioassay 83 84 // may have other raw bioassays that are NOT related to the same extract 84 int arrayNum= 0;85 int position = 0; 85 86 PhysicalBioAssay pba = null; 86 87 Node physicalBioAssayNode = bioAssayNode.getFirstParent(new ItemTypeFilter(Item.PHYSICALBIOASSAY)); … … 92 93 pba = (PhysicalBioAssay)physicalBioAssayNode.getItem(dc); 93 94 Extract extract = (Extract)extractNode.getItem(); 94 arrayNum = pba.getCreationEvent().getSourceGroup(extract); 95 BioMaterialEventSource eventSource = pba.getCreationEvent().getEventSource(extract); 96 position = eventSource == null ? 0 : eventSource.getPosition(); 95 97 } 96 98 } 97 if ( arrayNum> 0)99 if (position > 0) 98 100 { 99 query.restrict(Restrictions.eq(Hql.property("arrayNum"), Expressions.integer( arrayNum)));101 query.restrict(Restrictions.eq(Hql.property("arrayNum"), Expressions.integer(position))); 100 102 } 101 103 -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ExtractImporter.java
r5648 r5662 27 27 28 28 import net.sf.basedb.core.BioMaterialEvent; 29 import net.sf.basedb.core.BioMaterialEventSource; 29 30 import net.sf.basedb.core.BioPlate; 30 31 import net.sf.basedb.core.BioWell; … … 241 242 Float usedQuantity = usedQuantityMapper == null ? 242 243 null : usedQuantityMapper.getFloat(data); 243 if (nameOrId == null || sample != null) extract.setSample(sample, usedQuantity); 244 if (nameOrId == null || sample != null) 245 { 246 BioMaterialEventSource evtSrc = extract.setSample(sample); 247 if (evtSrc != null) evtSrc.setUsedQuantity(usedQuantity); 248 } 244 249 } 245 250 } … … 266 271 Float usedQuantity = usedQuantityMapper == null ? 267 272 null : usedQuantityMapper.getFloat(data); 268 extract.getCreationEvent().addSource(parent ,usedQuantity);273 extract.getCreationEvent().addSource(parent).setUsedQuantity(usedQuantity); 269 274 // Use same tag as parent if not yet set and not mapped in the file 270 275 if (tagMapper == null && parent.getTag() != null && extract.getTag() == null) -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/HybridizationImporter.java
r5649 r5662 29 29 import net.sf.basedb.core.ArraySlide; 30 30 import net.sf.basedb.core.BioMaterialEvent; 31 import net.sf.basedb.core.BioMaterialEventSource; 31 32 import net.sf.basedb.core.DbControl; 32 33 import net.sf.basedb.core.Extract; … … 305 306 { 306 307 BioMaterialEvent creationEvent = hyb.getCreationEvent(); 307 int currentIndex = creationEvent.getSourceGroup(parent); 308 BioMaterialEventSource eventSource = creationEvent.addSource(parent); 309 int currentIndex = eventSource.getPosition(); 308 310 Float usedQuantity = usedQuantityMapper == null ? 309 311 null : usedQuantityMapper.getFloat(data); 310 creationEvent.addSource(parent,usedQuantity);312 eventSource.setUsedQuantity(usedQuantity); 311 313 if (arrayIndexMapper != null) 312 314 { … … 321 323 "also associate it with array index " + arrayIndex); 322 324 } 323 creationEvent.setSourceGroup(parent,arrayIndex);325 eventSource.setPosition(arrayIndex); 324 326 } 325 327 } -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/LabeledExtractImporter.java
r5648 r5662 27 27 28 28 import net.sf.basedb.core.BioMaterialEvent; 29 import net.sf.basedb.core.BioMaterialEventSource; 29 30 import net.sf.basedb.core.BioPlate; 30 31 import net.sf.basedb.core.BioWell; … … 244 245 Float usedQuantity = usedQuantityMapper == null ? 245 246 null : usedQuantityMapper.getFloat(data); 246 if (nameOrId == null || parent != null) extract.setExtract(parent, usedQuantity); 247 if (nameOrId == null || parent != null) 248 { 249 BioMaterialEventSource evtSrc = extract.setExtract(parent); 250 if (evtSrc != null) evtSrc.setUsedQuantity(usedQuantity); 251 } 247 252 } 248 253 } … … 268 273 Float usedQuantity = usedQuantityMapper == null ? 269 274 null : usedQuantityMapper.getFloat(data); 270 extract.getCreationEvent().addSource(parent ,usedQuantity);275 extract.getCreationEvent().addSource(parent).setUsedQuantity(usedQuantity); 271 276 // Use same tag as parent if not yet set and not mapped in the file 272 277 if (labelMapper == null && parent.getTag() != null && extract.getTag() == null) -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/PhysicalBioAssayImporter.java
r5649 r5662 29 29 import net.sf.basedb.core.ArraySlide; 30 30 import net.sf.basedb.core.BioMaterialEvent; 31 import net.sf.basedb.core.BioMaterialEventSource; 31 32 import net.sf.basedb.core.DbControl; 32 33 import net.sf.basedb.core.Extract; … … 301 302 { 302 303 BioMaterialEvent creationEvent = pba.getCreationEvent(); 303 int currentPosition = creationEvent.getSourceGroup(parent); 304 Float usedQuantity = usedQuantityMapper == null ? 305 null : usedQuantityMapper.getFloat(data); 306 creationEvent.addSource(parent, usedQuantity); 304 BioMaterialEventSource eventSource = creationEvent.addSource(parent); 305 int currentPosition = eventSource.getPosition(); 306 if (usedQuantityMapper != null) 307 { 308 eventSource.setUsedQuantity(usedQuantityMapper.getFloat(data)); 309 } 307 310 if (extractPositionMapper != null) 308 311 { … … 317 320 "also associate it with position " + position); 318 321 } 319 creationEvent.setSourceGroup(parent,position);322 eventSource.setPosition(position); 320 323 } 321 324 } -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/SampleImporter.java
r5648 r5662 351 351 Float usedQuantity = usedQuantityMapper == null ? 352 352 null : usedQuantityMapper.getFloat(data); 353 sample.getCreationEvent().addSource(parent ,usedQuantity);353 sample.getCreationEvent().addSource(parent).setUsedQuantity(usedQuantity); 354 354 } 355 355 } -
trunk/src/test/TestExtract.java
r5653 r5662 97 97 { 98 98 Sample s = (Sample)parent; 99 e.setSample(s ,200.0f);99 e.setSample(s).setUsedQuantity(200.0f); 100 100 } 101 101 else 102 102 { 103 103 e.setPooled(true); 104 e.getCreationEvent().addSource( (MeasuredBioMaterial)parent,200.0f);104 e.getCreationEvent().addSource(parent).setUsedQuantity(200.0f); 105 105 } 106 106 } … … 153 153 Extract s = Extract.getById(dc, sourceId); 154 154 Float original = s.getOriginalQuantity(); 155 evt.addSource(s, original == null ? null : original/2); 155 BioMaterialEventSource eventSource = evt.addSource(s); 156 if (original != null) 157 { 158 eventSource.setUsedQuantity(original/2); 159 } 156 160 } 157 161 dc.saveItem(e); -
trunk/src/test/TestPhysicalBioAssay.java
r5653 r5662 106 106 { 107 107 Extract le = Extract.getById(dc, extractId); 108 evt.addSource(le, 100.0f); 108 BioMaterialEventSource eventSource = evt.addSource(le); 109 eventSource.setUsedQuantity(100.0f); 109 110 } 110 111 dc.saveItem(h); … … 265 266 } 266 267 267 static void test_add_extract(int hybId, int extractId, int arrayNum, Float usedQuantity)268 static void test_add_extract(int hybId, int extractId, int position, Float usedQuantity) 268 269 { 269 270 if (hybId == 0 || extractId == 0) return; … … 275 276 Extract le = Extract.getById(dc, extractId); 276 277 BioMaterialEvent event = h.getCreationEvent(); 277 event.addSource(le, usedQuantity); 278 event.setSourceGroup(le, arrayNum); 278 BioMaterialEventSource eventSource = event.addSource(le); 279 eventSource.setUsedQuantity(usedQuantity); 280 eventSource.setPosition(position); 279 281 dc.commit(); 280 282 write("--Add extract to bioassay OK"); -
trunk/src/test/TestSample.java
r5340 r5662 142 142 Sample src = Sample.getById(dc, sourceId); 143 143 Float original = src.getOriginalQuantity(); 144 evt.addSource(src, original == null ? null : original/2); 144 BioMaterialEventSource eventSource = evt.addSource(src); 145 if (original != null) 146 { 147 eventSource.setUsedQuantity(original/2); 148 } 145 149 } 146 150 dc.saveItem(s); -
trunk/src/test/TestTag.java
r5632 r5662 76 76 dc.commit(); 77 77 id = t.getId(); 78 dc = TestUtil.getDbControl(); 79 dc.reattachItem(t, false); 78 80 write_item(0, t); 79 81 write("--Create tag OK"); -
trunk/src/test/net/sf/basedb/test/roles/UserTest.java
r5652 r5662 398 398 extract.setName(name); 399 399 extract.setOriginalQuantity(100.0f); 400 extract.setSample(sample ,50.0f);400 extract.setSample(sample).setUsedQuantity(50.0f); 401 401 extract.getCreationEvent().setProtocol(Util.findProtocol(dc, "Extraction A")); 402 402 dc.saveItem(extract); … … 418 418 labeledExtract.setPooled(true); 419 419 labeledExtract.getCreationEvent().setProtocol(Util.findProtocol(dc, "Labeling A")); 420 labeledExtract.getCreationEvent().addSource(extract ,50.0f);420 labeledExtract.getCreationEvent().addSource(extract).setUsedQuantity(50.0f); 421 421 dc.saveItem(labeledExtract); 422 422 return labeledExtract; … … 450 450 for (Extract le : extracts) 451 451 { 452 creationEvent.addSource(le ,50.0f);452 creationEvent.addSource(le).setUsedQuantity(50.0f); 453 453 } 454 454 dc.saveItem(hyb); -
trunk/www/biomaterials/extracts/index.jsp
r5648 r5662 24 24 @version 2.0 25 25 --%> 26 <%@page import="net.sf.basedb.core.BioMaterialEventSource"%> 26 27 <%@ page pageEncoding="UTF-8" session="false" 27 28 import="net.sf.basedb.core.SessionControl" … … 283 284 { 284 285 Sample s = sampleId == 0 ? null : Sample.getById(dc, sampleId); 285 extract.setSample(s, s == null ? null : Values.getFloat(request.getParameter("used_from_sample"), null)); 286 BioMaterialEventSource evtSrc = extract.setSample(s); 287 if (evtSrc != null) 288 { 289 evtSrc.setUsedQuantity(Values.getFloat(request.getParameter("used_from_sample"), null)); 290 } 286 291 if (s != null) cc.setRecent(s, maxRecent); 287 292 } … … 296 301 { 297 302 Extract e = Extract.getById(dc, eId); 298 creationEvent.addSource(e ,Values.getFloat(request.getParameter("E"+eId), null));303 creationEvent.addSource(e).setUsedQuantity(Values.getFloat(request.getParameter("E"+eId), null)); 299 304 } 300 305 } -
trunk/www/biomaterials/extracts/list_extracts.jsp
r5648 r5662 118 118 119 119 final ItemQuery<Extract> parentExtractsQuery = Extract.getQuery(); 120 parentExtractsQuery.join(Hql.innerJoin(" sourceEvents", "srcevt"));121 parentExtractsQuery.join(Hql.innerJoin(" srcevt", "event", "evt"));120 parentExtractsQuery.join(Hql.innerJoin("childCreationEvents", "cce")); 121 parentExtractsQuery.join(Hql.innerJoin("cce", "event", "evt")); 122 122 parentExtractsQuery.restrict(Restrictions.eq(Hql.alias("evt"), Hql.entityParameter("creationEvent", Item.BIOMATERIALEVENT))); 123 123 parentExtractsQuery.order(Orders.asc(Hql.property("name"))); … … 398 398 id="parents" 399 399 title="Parent extracts" 400 property="&creationEvent.source BioMaterials(name)"400 property="&creationEvent.sources(bioMaterial.name)" 401 401 datatype="string" 402 402 filterable="true" … … 406 406 id="children" 407 407 title="Child extracts" 408 property="& sourceEvents(event.bioMaterial.name)"408 property="&childCreationEvents(event.bioMaterial.name)" 409 409 datatype="string" 410 410 filterable="true" … … 414 414 id="physicalBioAssays" 415 415 title="Physical bioassays" 416 property="& sourceEvents(event.physicalBioAssay.name)"416 property="&childCreationEvents(event.physicalBioAssay.name)" 417 417 datatype="string" 418 418 filterable="true" -
trunk/www/biomaterials/samples/index.jsp
r5645 r5662 284 284 { 285 285 Sample s = Sample.getById(dc, sId); 286 creationEvent.addSource(s ,Values.getFloat(request.getParameter("S"+sId), null));286 creationEvent.addSource(s).setUsedQuantity(Values.getFloat(request.getParameter("S"+sId), null)); 287 287 } 288 288 } -
trunk/www/biomaterials/samples/list_samples.jsp
r5645 r5662 115 115 116 116 final ItemQuery<Sample> parentSamplesQuery = Sample.getQuery(); 117 parentSamplesQuery.join(Hql.innerJoin(" sourceEvents", "srcevt"));118 parentSamplesQuery.join(Hql.innerJoin(" srcevt", "event", "evt"));117 parentSamplesQuery.join(Hql.innerJoin("childCreationEvents", "cce")); 118 parentSamplesQuery.join(Hql.innerJoin("cce", "event", "evt")); 119 119 parentSamplesQuery.restrict(Restrictions.eq(Hql.alias("evt"), Hql.entityParameter("creationEvent", Item.BIOMATERIALEVENT))); 120 120 parentSamplesQuery.order(Orders.asc(Hql.property("name"))); … … 395 395 id="parents" 396 396 title="Parent samples" 397 property="&creationEvent.source BioMaterials(name)"397 property="&creationEvent.sources(bioMaterial.name)" 398 398 datatype="string" 399 399 filterable="true" … … 403 403 id="children" 404 404 title="Child samples" 405 property="& sourceEvents(event.bioMaterial.name)"405 property="&childCreationEvents(event.bioMaterial.name)" 406 406 datatype="string" 407 407 filterable="true" -
trunk/www/biomaterials/samples/view_sample.jsp
r5645 r5662 34 34 import="net.sf.basedb.core.Sample" 35 35 import="net.sf.basedb.core.BioSource" 36 import="net.sf.basedb.core.BioMaterial" 36 37 import="net.sf.basedb.core.BioMaterialEvent" 38 import="net.sf.basedb.core.BioMaterialEventSource" 37 39 import="net.sf.basedb.core.BioWell" 38 40 import="net.sf.basedb.core.Protocol" … … 42 44 import="net.sf.basedb.core.ItemQuery" 43 45 import="net.sf.basedb.core.ItemResultList" 46 import="net.sf.basedb.core.query.ResultList" 47 import="net.sf.basedb.core.SpecialQuery" 44 48 import="net.sf.basedb.core.Include" 45 49 import="net.sf.basedb.core.MultiPermissions" … … 365 369 if (sample.isPooled()) 366 370 { 367 ItemQuery<Sample> samplesQuery = (ItemQuery<Sample>)creationEvent.getSources(); 368 samplesQuery.include(Include.ALL); 369 samplesQuery.order(Orders.asc(Hql.property("name"))); 370 ItemResultList<Sample> samples = samplesQuery.list(dc); 371 SpecialQuery<BioMaterialEventSource> sourceQuery = creationEvent.getEventSources(); 372 sourceQuery.order(Orders.asc(Hql.property("bioMaterial.name"))); 373 ResultList<BioMaterialEventSource> sources = sourceQuery.list(dc); 371 374 %> 372 375 <h4 class="docked">Pooled from samples</h4> … … 393 396 <tbl:rows> 394 397 <% 395 for ( Sample item : samples)398 for (BioMaterialEventSource item : sources) 396 399 { 400 BioMaterial bm = null; 401 try 402 { 403 bm = item.getBioMaterial(); 404 } 405 catch (PermissionDeniedException ex) 406 {} 397 407 %> 398 408 <tbl:row> … … 400 410 image="deleted.gif" 401 411 tooltip="This item has been scheduled for deletion" 402 visible="<%= item.isRemoved()%>"403 /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>404 <tbl:cell column="quantity"><%=Values.formatNumber( creationEvent.getUsedQuantity(item), 2)%></tbl:cell>405 <tbl:cell column="description"><%=HTML.encodeTags( item.getDescription())%></tbl:cell>412 visible="<%=bm != null && bm.isRemoved()%>" 413 /><%=Base.getLinkedName(ID, bm, bm == null, true)%></tbl:cell> 414 <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(), 2)%></tbl:cell> 415 <tbl:cell column="description"><%=HTML.encodeTags(bm == null ? "" : bm.getDescription())%></tbl:cell> 406 416 </tbl:row> 407 417 <% -
trunk/www/biomaterials/wizards/index.jsp
r5642 r5662 22 22 @author Nicklas 23 23 --%> 24 <%@page import="net.sf.basedb.core.BioMaterialEventSource"%> 24 25 <%@ page pageEncoding="UTF-8" session="false" 25 26 import="net.sf.basedb.core.SessionControl" … … 293 294 if (isBioAssayEvent) 294 295 { 295 pbaCreationEvent.addSource(parent, usedQuantity); 296 pbaCreationEvent.setSourceGroup(parent, column+1); 296 BioMaterialEventSource evtSrc = pbaCreationEvent.addSource(parent); 297 evtSrc.setUsedQuantity(usedQuantity); 298 evtSrc.setPosition(column+1); 297 299 } 298 300 else … … 308 310 { 309 311 child = Extract.getNew(dc, destParticipant); 310 if (!pooled) ((Extract)child).setSample((Sample)parent ,usedQuantity);312 if (!pooled) ((Extract)child).setSample((Sample)parent).setUsedQuantity(usedQuantity); 311 313 } 312 314 /* … … 329 331 if (pooled) 330 332 { 331 child.getCreationEvent().addSource(parent ,usedQuantity);333 child.getCreationEvent().addSource(parent).setUsedQuantity(usedQuantity); 332 334 } 333 335 dc.saveItem(child); -
trunk/www/views/physicalbioassays/edit_bioassay.jsp
r5657 r5662 35 35 import="net.sf.basedb.core.PhysicalBioAssay" 36 36 import="net.sf.basedb.core.BioMaterialEvent" 37 import="net.sf.basedb.core.BioMaterialEventSource" 37 38 import="net.sf.basedb.core.ItemSubtype" 38 39 import="net.sf.basedb.core.ArraySlide" … … 553 554 else 554 555 { 555 Float used = creationEvent.getUsedQuantity(extract); 556 BioMaterialEventSource evtSrc = creationEvent.getEventSource(extract); 557 Float used = evtSrc.getUsedQuantity(); 556 558 String usedQuantity = Values.formatNumber(used, -1); 557 559 String usedWithUnit = used == null ? "-" : usedQuantity + " µg"; 558 int arrayIndex = creationEvent.getSourceGroup(extract);560 int position = evtSrc.getPosition(); 559 561 %> 560 Link.addNewItem(extracts, new Item('E', <%=extract.getId()%>, '<%= arrayIndex + ": " + HTML.javaScriptEncode(extract.getName())%> [<%=usedWithUnit%>]', '<%=usedQuantity%>:<%=arrayIndex%>'));562 Link.addNewItem(extracts, new Item('E', <%=extract.getId()%>, '<%=position + ": " + HTML.javaScriptEncode(extract.getName())%> [<%=usedWithUnit%>]', '<%=usedQuantity%>:<%=position%>')); 561 563 <% 562 564 } -
trunk/www/views/physicalbioassays/index.jsp
r5657 r5662 32 32 import="net.sf.basedb.core.ArraySlide" 33 33 import="net.sf.basedb.core.BioMaterialEvent" 34 import="net.sf.basedb.core.BioMaterialEventSource" 34 35 import="net.sf.basedb.core.Extract" 35 36 import="net.sf.basedb.core.Protocol" … … 242 243 Float usedQuantity = Values.getFloat(extra[0], null); 243 244 int position = extra.length > 1 ? Values.getInt(extra[1], 1) : 1; 244 creationEvent.addSource(e, usedQuantity); 245 creationEvent.setSourceGroup(e, position); 245 BioMaterialEventSource evtSrc = creationEvent.addSource(e); 246 evtSrc.setUsedQuantity(usedQuantity); 247 evtSrc.setPosition(position); 246 248 } 247 249 } -
trunk/www/views/physicalbioassays/list_bioassays.jsp
r5657 r5662 33 33 import="net.sf.basedb.core.DerivedBioAssaySet" 34 34 import="net.sf.basedb.core.BioMaterialEvent" 35 import="net.sf.basedb.core.BioMaterialEventSource" 35 36 import="net.sf.basedb.core.AnnotationType" 36 37 import="net.sf.basedb.core.AnnotationSet" … … 100 101 final ItemQuery<Extract> extractQuery = Extract.getQuery(); 101 102 extractQuery.include(cc.getInclude()); 102 extractQuery.join(Hql.innerJoin(" sourceEvents", "srcevt"));103 extractQuery.join(Hql.innerJoin(" srcevt", "event", "evt"));103 extractQuery.join(Hql.innerJoin("childCreationEvents", "cce")); 104 extractQuery.join(Hql.innerJoin("cce", "event", "evt")); 104 105 extractQuery.restrict(Restrictions.eq(Hql.property("evt", "physicalBioAssay"), Expressions.parameter("bioAssay"))); 105 extractQuery.order(Orders.asc(Hql.property(" srcevt", "sourceGroup")));106 extractQuery.order(Orders.asc(Hql.property("cce", "position"))); 106 107 extractQuery.order(Orders.asc(Hql.property("name"))); 107 108 … … 292 293 id="extracts" 293 294 title="Extracts" 294 property="&creationEvent.source BioMaterials(name)"295 property="&creationEvent.sources(bioMaterial.name)" 295 296 datatype="string" 296 297 filterable="true" … … 609 610 if (needIndex) 610 611 { 611 out.write(creationEvent.get SourceGroup(extract) + ": ");612 out.write(creationEvent.getEventSource(extract).getPosition() + ": "); 612 613 } 613 614 if (mode.hasPropertyLink()) -
trunk/www/views/physicalbioassays/view_bioassay.jsp
r5657 r5662 36 36 import="net.sf.basedb.core.ArraySlide" 37 37 import="net.sf.basedb.core.BioMaterialEvent" 38 import="net.sf.basedb.core.BioMaterialEventSource" 38 39 import="net.sf.basedb.core.Protocol" 39 40 import="net.sf.basedb.core.DerivedBioAssaySet" … … 327 328 ItemQuery<Extract> extractsQuery = (ItemQuery<Extract>)creationEvent.getSources(); 328 329 extractsQuery.include(Include.ALL); 329 extractsQuery.order(Orders.asc(Hql.property("srcevt", " sourceGroup")));330 extractsQuery.order(Orders.asc(Hql.property("srcevt", "position"))); 330 331 extractsQuery.order(Orders.asc(Hql.property("name"))); 331 332 ItemResultList<Extract> extracts = extractsQuery.list(dc); … … 379 380 for (Extract item : extracts) 380 381 { 382 BioMaterialEventSource evtSrc = creationEvent.getEventSource(item); 381 383 %> 382 384 <tbl:row> 383 <tbl:cell column="position"><%= creationEvent.getSourceGroup(item)%></tbl:cell>385 <tbl:cell column="position"><%=evtSrc.getPosition()%></tbl:cell> 384 386 <tbl:cell column="name"><base:icon 385 387 image="deleted.gif" … … 388 390 /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell> 389 391 <tbl:cell column="tag"><base:propertyvalue item="<%=item%>" property="tag" /></tbl:cell> 390 <tbl:cell column="quantity"><%=Values.formatNumber( creationEvent.getUsedQuantity(item), 2)%></tbl:cell>392 <tbl:cell column="quantity"><%=Values.formatNumber(evtSrc.getUsedQuantity(), 2)%></tbl:cell> 391 393 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 392 394 </tbl:row>
Note: See TracChangeset
for help on using the changeset viewer.