Changeset 5664
- Timestamp:
- Jun 23, 2011, 11:53:05 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/ItemQueryLoader.java
r4900 r5664 36 36 @base.modified $Date$ 37 37 */ 38 public class ItemQueryLoader 39 implements DataLoader< BasicItem<?>>38 public class ItemQueryLoader<T extends BasicItem> 39 implements DataLoader<T> 40 40 { 41 41 private final ItemQuery<?> query; … … 55 55 56 56 @Override 57 public Object getData(ExportedProperty exportedProperty, BasicItem<?>item)57 public Object getData(ExportedProperty exportedProperty, T item) 58 58 throws Exception 59 59 { -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/ParentBioMaterialLoader.java
r5663 r5664 24 24 import net.sf.basedb.core.BioMaterial; 25 25 import net.sf.basedb.core.DbControl; 26 import net.sf.basedb.core.Include;27 26 import net.sf.basedb.core.ItemQuery; 28 27 import net.sf.basedb.core.MeasuredBioMaterial; … … 36 35 37 36 public class ParentBioMaterialLoader 38 implements DataLoader<MeasuredBioMaterial<?>>37 extends ItemQueryLoader<MeasuredBioMaterial> 39 38 { 40 39 41 public ParentBioMaterialLoader() 42 {} 40 public ParentBioMaterialLoader(ItemQuery<? extends BioMaterial> query, String parameterName) 41 { 42 super(query, parameterName); 43 } 43 44 44 @SuppressWarnings("unchecked")45 45 @Override 46 public Object getData(ExportedProperty exportedProperty, MeasuredBioMaterial <?>item)46 public Object getData(ExportedProperty exportedProperty, MeasuredBioMaterial item) 47 47 throws Exception 48 48 { … … 57 57 try 58 58 { 59 parents = exportedProperty.propertyPath.getValue(dc, item);59 parents = item.getParent(); 60 60 } 61 61 catch(Throwable e) … … 64 64 else 65 65 { 66 ItemQuery<? extends BioMaterial> pooledQuery = item.getCreationEvent().getSources(); 67 pooledQuery.include(Include.ALL); 68 parents = pooledQuery.list(dc); 66 parents = super.getData(exportedProperty, item); 69 67 } 70 68 return parents; -
trunk/www/biomaterials/extracts/edit_extract.jsp
r5650 r5664 29 29 import="net.sf.basedb.core.DbControl" 30 30 import="net.sf.basedb.core.Item" 31 import="net.sf.basedb.core.Type" 31 32 import="net.sf.basedb.core.ItemContext" 32 33 import="net.sf.basedb.core.SystemItems" … … 48 49 import="net.sf.basedb.core.query.Orders" 49 50 import="net.sf.basedb.core.query.Hql" 51 import="net.sf.basedb.core.query.Expressions" 52 import="net.sf.basedb.core.query.Restrictions" 50 53 import="net.sf.basedb.clients.web.Base" 51 54 import="net.sf.basedb.clients.web.util.HTML" … … 81 84 BioMaterialEvent creationEvent = null; 82 85 Date eventDate = null; 83 boolean isPooled = false;86 Item parentType = null; 84 87 boolean lockEventProperties = false; 85 88 … … 144 147 } 145 148 int sampleId = Values.getInt(request.getParameter("sample_id")); 149 int extractId = Values.getInt(request.getParameter("extract_id")); 146 150 if (sampleId != 0) 147 151 { 148 152 currentSample = Sample.getById(dc, sampleId); 149 isPooled = false;153 parentType = Item.SAMPLE; 150 154 name = currentSample.getName() + ".e" + (currentSample.countExtracts() + 1); 151 155 } 152 else if(Values.getBoolean(request.getParameter("pooled"))) 153 { 154 isPooled = true; 156 else if (extractId != 0) 157 { 158 parentType = Item.EXTRACT; 159 Extract e = Extract.getById(dc, extractId); 160 name = e.getName() + ".e" + (e.countExtracts()+1); 161 extractsQuery = Extract.getQuery(); 162 extractsQuery.restrict(Restrictions.eq(Hql.property("id"), Expressions.integer(extractId))); 163 } 164 else if (Values.getBoolean(request.getParameter("pooled"))) 165 { 166 parentType = Item.EXTRACT; 155 167 name = Values.getString(cc.getPropertyValue("name"), "New pooled extract"); 168 extractsQuery = Extract.getQuery(); 169 extractsQuery.restrict(Restrictions.in(Hql.property("id"), Expressions.parameter("selected"))); 170 extractsQuery.setParameter("selected", cc.getSelected(), Type.INT); 156 171 } 157 172 else 158 173 { 159 isPooled = Values.getBoolean(cc.getPropertyValue("pooled"));160 174 name = Values.getString(cc.getPropertyValue("name"), "New extract"); 161 175 } … … 171 185 creationEvent = extract.getCreationEvent(); 172 186 eventDate = creationEvent.getEventDate(); 173 isPooled = extract.isPooled();174 187 name = extract.getName(); 175 188 lockEventProperties = !creationEvent.hasPermission(Permission.WRITE); … … 205 218 try 206 219 { 207 currentSample = extract.getSample(); 208 if (currentSample != null) usedFromSample = creationEvent.getUsedQuantity(currentSample); 220 if (parentType == Item.SAMPLE) 221 { 222 currentSample = (Sample)extract.getParent(); 223 if (currentSample != null) 224 { 225 usedFromSample = creationEvent.getUsedQuantity(currentSample); 226 } 227 } 209 228 } 210 229 catch (PermissionDeniedException ex) … … 228 247 229 248 // Query to retrieve pooled extracts 230 extractsQuery = (ItemQuery<Extract>)creationEvent.getSources();231 extractsQuery.include(Include.ALL);232 extractsQuery.order(Orders.asc(Hql.property("name")));233 249 if (parentType == Item.EXTRACT) 250 { 251 extractsQuery = (ItemQuery<Extract>)creationEvent.getSources(); 252 } 234 253 } 235 254 … … 329 348 var frm = document.forms['extract']; 330 349 var parents = new Array(); 331 if (frm.p ooled[0].checked)350 if (frm.parentType[0].checked) 332 351 { 333 352 var sampleId = Math.abs(parseInt(frm.sample_id[frm.sample_id.selectedIndex].value)); … … 488 507 } 489 508 490 function p ooledOnClick()491 { 492 var frm = document.forms['extract']; 493 var isPooled = frm.pooled[1].checked;494 frm.sample_id.disabled = isPooled;495 frm.used_from_sample.disabled = isPooled;496 frm.extracts.disabled = ! isPooled;497 frm.used_quantity.disabled = ! isPooled;509 function parentTypeOnClick() 510 { 511 var frm = document.forms['extract']; 512 var useExtracts = frm.parentType[1].checked; 513 frm.sample_id.disabled = useExtracts; 514 frm.used_from_sample.disabled = useExtracts; 515 frm.extracts.disabled = !useExtracts; 516 frm.used_quantity.disabled = !useExtracts; 498 517 parentsChanged = true; 499 518 } … … 506 525 { 507 526 var frm = document.forms['extract']; 508 if (frm.pooled[1].checked)509 {510 alert('This is a pooled extract, which cannot have a sample as it\'s parent');511 return;512 }513 527 var url = '../samples/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone'; 514 528 url += '&callback=setSampleCallback&resetTemporary=1'; … … 532 546 list[1].text = name; 533 547 list.selectedIndex = 1; 548 frm.parentType[0].checked = true; 549 frm.parentType[1].checked = false; 550 parentTypeOnClick(); 534 551 parentsChanged = true; 535 552 } … … 538 555 { 539 556 var frm = document.forms['extract']; 540 if (!frm.pooled[1].checked)541 {542 alert('This is not a pooled extract');543 return;544 }545 557 var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple'; 546 558 url += '&callback=addExtractCallback&resetTemporary=1'; … … 554 566 if (!item) item = new Item('E', extractId, name+' [-]', '', ''); 555 567 Link.addItem(document.forms['extract'].extracts, item); 568 frm.parentType[0].checked = false; 569 frm.parentType[1].checked = true; 570 parentTypeOnClick(); 556 571 parentsChanged = true; 557 572 } … … 618 633 initBioWell(); 619 634 initExtracts(); 620 p ooledOnClick();635 parentTypeOnClick(); 621 636 } 622 637 function initExtracts() … … 624 639 var extracts = document.forms['extract'].extracts; 625 640 <% 626 if (extract != null && extract.isPooled()) 627 { 641 if (extractsQuery != null) 642 { 643 extractsQuery.include(Include.ALL); 644 extractsQuery.order(Orders.asc(Hql.property("name"))); 628 645 ItemResultList<Extract> extracts = extractsQuery.list(dc); 629 646 for (Extract e : extracts) 630 647 { 631 String usedQuantity = Values.formatNumber(creationEvent.getUsedQuantity(e), -1);632 %>633 Link.addNewItem(extracts, new Item('E', <%=e.getId()%>, '<%=HTML.javaScriptEncode(e.getName())%> [<%=usedQuantity%> µg]', '<%=usedQuantity%>'));634 <%635 }636 }637 else if (extract == null && Values.getBoolean(request.getParameter("pooled")))638 {639 for (int eId : cc.getSelected())640 {641 Extract extractToPool = Extract.getById(dc, eId);642 %>643 Link.addItem(extracts, new Item('E', <%=extractToPool.getId()%>, '<%=HTML.javaScriptEncode(extractToPool.getName())%> [-]', '', ''));644 <%648 if (extract != null) 649 { 650 String usedQuantity = Values.formatNumber(creationEvent.getUsedQuantity(e), -1); 651 %> 652 Link.addNewItem(extracts, new Item('E', <%=e.getId()%>, '<%=HTML.javaScriptEncode(e.getName())%> [<%=usedQuantity%> µg]', '<%=usedQuantity%>')); 653 <% 654 } 655 else 656 { 657 %> 658 Link.addItem(extracts, new Item('E', <%=e.getId()%>, '<%=HTML.javaScriptEncode(e.getName())%> [-]', '', '')); 659 <% 660 661 } 645 662 } 646 663 } … … 821 838 <table class="form" cellspacing=0> 822 839 <tr> 823 <td class="prompt">P ooled</td>840 <td class="prompt">Parent type</td> 824 841 <td> 825 <input type="radio" name="pooled" value="0" onclick="pooledOnClick()" 826 <%=!isPooled ? "checked" : ""%> 827 >no 828 <input type="radio" name="pooled" value="1" onclick="pooledOnClick()" 829 <%=isPooled ? "checked" : ""%> 830 >yes 842 <input type="radio" name="parentType" id="parentType.sample" 843 value="SAMPLE" onclick="parentTypeOnClick()" 844 <%=parentType != Item.EXTRACT ? "checked" : ""%> 845 ><label for="parentType.sample">Sample</label> 846 <input type="radio" name="parentType" id="parentType.extract" 847 value="EXTRACT" onclick="parentTypeOnClick()" 848 <%=parentType == Item.EXTRACT ? "checked" : ""%> 849 ><label for="parentType.extract">Extract</label> 831 850 </td> 832 851 </tr> … … 837 856 id="sample_id" 838 857 clazz="selectionlist" 858 buttonstyle="width: 150px;" 859 buttonicon="add.png" 860 buttontitle="Select biosource…" 839 861 required="false" 840 862 current="<%=currentSample%>" … … 846 868 onchange="sampleOnChange()" 847 869 /> 848 Used 870 </td> 871 </tr> 872 <tr> 873 <td class="subprompt">-</td> 874 <td> 875 used quantity 849 876 <input <%=clazz%> type="text" name="used_from_sample" value="<%=Values.formatNumber(usedFromSample, -1)%>" 850 877 size="12" maxlength="10" onkeypress="return Numbers.numberOnly(event)" … … 858 885 <tr valign="top"> 859 886 <td> 860 <select name="extracts" size="5" multiple style="width: 20em;"887 <select name="extracts" size="5" multiple class="selectionlist" 861 888 onchange="extractsOnChange()"> 862 </select> <br> 863 Used 864 <input <%=clazz%> type="text" name="used_quantity" value="" 865 size="12" maxlength="10" onkeypress="return Numbers.numberOnly(event)" 866 onkeyup="usedQuantityOnBlur()" 867 > (µg) 889 </select> 868 890 <input type="hidden" name="modifiedExtracts" value=""> 869 891 <input type="hidden" name="removedExtracts" value=""> 870 892 </td> 871 893 <td> 872 <table border="0"> 873 <tr><td width="150"><base:button 894 <table border="0" cellspacing="0" cellpadding="0"> 895 <tr><td style="padding: 1px 0px 4px 0px;"><base:button 896 style="width: 150px;" 874 897 onclick="addExtractsOnClick()" 875 898 title="Add extracts…" … … 877 900 /></td></tr> 878 901 <tr><td width="150"><base:button 902 style="width: 150px;" 879 903 onclick="removeOnClick()" 880 904 title="Remove" … … 887 911 </td> 888 912 </tr> 913 <tr> 914 <td class="subprompt">-</td> 915 <td>used quantity 916 <input <%=clazz%> type="text" name="used_quantity" value="" 917 size="12" maxlength="10" onkeypress="return Numbers.numberOnly(event)" 918 onkeyup="usedQuantityOnBlur();" 919 > (µg) 920 </td> 921 </tr> 889 922 </table> 890 923 </t:tab> -
trunk/www/biomaterials/extracts/index.jsp
r5662 r5664 24 24 @version 2.0 25 25 --%> 26 <%@page import="net.sf.basedb.core.BioMaterialEventSource"%>27 26 <%@ page pageEncoding="UTF-8" session="false" 28 27 import="net.sf.basedb.core.SessionControl" … … 33 32 import="net.sf.basedb.core.Extract" 34 33 import="net.sf.basedb.core.BioMaterialEvent" 34 import="net.sf.basedb.core.BioMaterialEventSource" 35 35 import="net.sf.basedb.core.BioPlateEventType" 36 36 import="net.sf.basedb.core.BioWell" … … 61 61 import="net.sf.basedb.util.formatter.NameableFormatter" 62 62 import="net.sf.basedb.util.formatter.WellCoordinateFormatter" 63 import="net.sf.basedb.util.formatter.ItemTypeFormatter" 63 64 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 64 65 import="net.sf.basedb.clients.web.plugins.ItemQueryLoader" … … 88 89 cc.setObject("export.formatter.bioWell.column", new WellCoordinateFormatter(false)); 89 90 cc.setObject("export.formatter.&children(name)", new NameableFormatter()); 90 cc.setObject("export.formatter.&creationEvent.source BioMaterials(name)", new NameableFormatter());91 cc.setObject("export.formatter.& sourceEvents(event.physicalBioAssay.name)", new NameableFormatter());92 cc.setObject("export.formatter.& sourceEvents(event.bioMaterial.name)", new NameableFormatter());93 91 cc.setObject("export.formatter.&creationEvent.sources(bioMaterial.name)", new NameableFormatter()); 92 cc.setObject("export.formatter.&childCreationEvents(event.physicalBioAssay.name)", new NameableFormatter()); 93 cc.setObject("export.formatter.&childCreationEvents(event.bioMaterial.name)", new NameableFormatter()); 94 cc.setObject("export.formatter.parentType", new ItemTypeFormatter()); 94 95 95 96 String restrictionParameter = "extract"; … … 99 100 bioAssayQuery.join(Hql.innerJoin("creationEvent", "ce")); 100 101 bioAssayQuery.join(Hql.innerJoin("ce", "sources", "src")); 101 bioAssayQuery.restrict(Restrictions.eq(Hql. index("src", null), Expressions.parameter(restrictionParameter)));102 bioAssayQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Expressions.parameter(restrictionParameter))); 102 103 bioAssayQuery.order(Orders.asc(Hql.property("name"))); 103 104 bioAssayQuery.include(cc.getInclude()); 104 cc.setObject("export.dataloader.& sourceEvents(event.physicalBioAssay.name)", new ItemQueryLoader(bioAssayQuery, restrictionParameter));105 cc.setObject("export.dataloader.&childCreationEvents(event.physicalBioAssay.name)", new ItemQueryLoader(bioAssayQuery, restrictionParameter)); 105 106 106 107 // Child extracts … … 108 109 childExtractsQuery.join(Hql.innerJoin("creationEvent", "ce")); 109 110 childExtractsQuery.join(Hql.innerJoin("ce", "sources", "src")); 110 childExtractsQuery.restrict(Restrictions.eq(Hql. index("src", null), Expressions.parameter(restrictionParameter)));111 childExtractsQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Expressions.parameter(restrictionParameter))); 111 112 childExtractsQuery.order(Orders.asc(Hql.property("name"))); 112 113 childExtractsQuery.include(cc.getInclude()); 113 cc.setObject("export.dataloader.& sourceEvents(event.bioMaterial.name)", new ItemQueryLoader(childExtractsQuery, restrictionParameter));114 cc.setObject("export.dataloader.&childCreationEvents(event.bioMaterial.name)", new ItemQueryLoader(childExtractsQuery, restrictionParameter)); 114 115 115 // Parent extracts116 // Parent items 116 117 final ItemQuery<Extract> parentExtractsQuery = Extract.getQuery(); 117 parentExtractsQuery.join(Hql.innerJoin(" sourceEvents", "srcevt"));118 parentExtractsQuery.join(Hql.innerJoin(" srcevt", "event", "evt"));118 parentExtractsQuery.join(Hql.innerJoin("childCreationEvents", "cce")); 119 parentExtractsQuery.join(Hql.innerJoin("cce", "event", "evt")); 119 120 parentExtractsQuery.restrict(Restrictions.eq(Hql.property("evt", "bioMaterial"), Expressions.parameter(restrictionParameter))); 120 121 parentExtractsQuery.order(Orders.asc(Hql.property("name"))); 121 122 parentExtractsQuery.include(cc.getInclude()); 122 cc.setObject("export.dataloader.&creationEvent.source BioMaterials(name)", new ItemQueryLoader(parentExtractsQuery, restrictionParameter));123 cc.setObject("export.dataloader.&creationEvent.sources(bioMaterial.name)", new ParentBioMaterialLoader(parentExtractsQuery, restrictionParameter)); 123 124 } 124 125 %> … … 277 278 278 279 // Parents tab 279 extract.setPooled(Values.getBoolean(request.getParameter("pooled")));280 if ( !extract.isPooled())280 Item parentType = Item.valueOf(request.getParameter("parentType")); 281 if (parentType == Item.SAMPLE) 281 282 { 282 283 int sampleId = Values.getInt(request.getParameter("sample_id"), -1); … … 284 285 { 285 286 Sample s = sampleId == 0 ? null : Sample.getById(dc, sampleId); 286 BioMaterialEventSource evtSrc = extract.setSample(s);287 BioMaterialEventSource evtSrc = creationEvent.setSource(s); 287 288 if (evtSrc != null) 288 289 { … … 294 295 else 295 296 { 297 if (extract.getParentType() != Item.EXTRACT) 298 { 299 creationEvent.clearSources(); 300 } 296 301 String[] modifiedExtracts = Values.getString(request.getParameter("modifiedExtracts")).split(","); 297 302 for (int i = 0; i < modifiedExtracts.length; ++i) -
trunk/www/biomaterials/extracts/list_extracts.jsp
r5662 r5664 103 103 final boolean createBioAssayPermission = sc.hasPermission(Permission.CREATE, Item.PHYSICALBIOASSAY); 104 104 105 // Child bioassays 105 106 final ItemQuery<PhysicalBioAssay> bioAssayQuery = PhysicalBioAssay.getQuery(); 106 107 bioAssayQuery.join(Hql.innerJoin("creationEvent", "ce")); 107 108 bioAssayQuery.join(Hql.innerJoin("ce", "sources", "src")); 108 bioAssayQuery.restrict(Restrictions.eq(Hql. index("src", null), Hql.entityParameter("extract", Item.EXTRACT)));109 bioAssayQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Hql.entityParameter("extract", Item.EXTRACT))); 109 110 bioAssayQuery.order(Orders.asc(Hql.property("name"))); 110 111 bioAssayQuery.include(cc.getInclude()); 111 112 113 // Child extracts 112 114 final ItemQuery<Extract> childExtractsQuery = Extract.getQuery(); 113 115 childExtractsQuery.join(Hql.innerJoin("creationEvent", "ce")); 114 116 childExtractsQuery.join(Hql.innerJoin("ce", "sources", "src")); 115 childExtractsQuery.restrict(Restrictions.eq(Hql. index("src", null), Hql.entityParameter("extract", Item.EXTRACT)));117 childExtractsQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Hql.entityParameter("extract", Item.EXTRACT))); 116 118 childExtractsQuery.order(Orders.asc(Hql.property("name"))); 117 119 childExtractsQuery.include(cc.getInclude()); 118 120 121 // Parent extracts 119 122 final ItemQuery<Extract> parentExtractsQuery = Extract.getQuery(); 120 123 parentExtractsQuery.join(Hql.innerJoin("childCreationEvents", "cce")); … … 173 176 Table.poolItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'NewPhysicalBioAssay'); 174 177 } 178 function newExtract(extractId) 179 { 180 Main.viewOrEditItem('<%=ID%>', 'EXTRACT', 0, true, '&extract_id='+extractId); 181 } 175 182 function editItem(itemId) 176 183 { … … 377 384 formatter="<%=dateFormatter%>" 378 385 /> 379 <tbl:columndef 380 id="pooled" 381 property="pooled" 382 datatype="boolean" 383 title="Pooled" 384 sortable="true" 385 filterable="true" 386 exportable="true" 387 /> 386 <% 387 Enumeration<String, String> parentTypes = new Enumeration<String, String>(); 388 parentTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString()); 389 parentTypes.add(Integer.toString(Item.EXTRACT.getValue()), Item.EXTRACT.toString()); 390 %> 388 391 <tbl:columndef 389 id="sample" 390 title="Sample" 391 property="parent.name" 392 datatype="string" 393 sortable="true" 394 filterable="true" 395 exportable="true" 392 id="parentType" 393 title="Parent type" 394 property="parentType" 395 enumeration="<%=parentTypes%>" 396 datatype="int" 397 filterable="true" 398 exportable="true" 399 sortable="true" 396 400 /> 397 401 <tbl:columndef 398 402 id="parents" 399 title="Parent extracts"403 title="Parent items" 400 404 property="&creationEvent.sources(bioMaterial.name)" 405 sortproperty="parent.name" 401 406 datatype="string" 402 407 filterable="true" 403 408 exportable="true" 409 sortable="true" 404 410 /> 405 411 <tbl:columndef … … 662 668 { 663 669 Extract item = extracts.next(); 670 Item parentType = item.getParentType(); 664 671 BioMaterialEvent creationEvent = item.getCreationEvent(); 665 672 int itemId = item.getId(); … … 727 734 <tbl:cell column="originalQuantity"><%=Values.formatNumber(item.getOriginalQuantity(), 2)%></tbl:cell> 728 735 <tbl:cell column="remainingQuantity"><%=Values.formatNumber(item.getRemainingQuantity(), 2)%></tbl:cell> 729 <tbl:cell column="pooled"><%=item.isPooled()%></tbl:cell>730 736 <tbl:cell column="protocol" 731 737 ><base:propertyvalue … … 737 743 <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" /> 738 744 <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" /> 739 <tbl:cell column=" sample"><base:propertyvalue item="<%=item%>" property="parent"/></tbl:cell>745 <tbl:cell column="parentType"><%=parentType == null ? "" : parentType.toString() %></tbl:cell> 740 746 <tbl:cell column="parents"> 741 747 <% 742 if (item.isPooled()) 748 if (item.hasSingleParent() || item.getParentType() == null) 749 { 750 %> 751 <base:propertyvalue item="<%=item%>" property="parent"/> 752 <% 753 } 754 else 743 755 { 744 756 String separator = ""; … … 759 771 } 760 772 %> 773 <%=parentType != null ? "<span class=\"itemtype\">(" + parentType + ")</span>" : "" %> 761 774 </tbl:cell> 762 775 <tbl:cell column="children"> … … 778 791 } 779 792 %> 793 <base:icon 794 image="add.png" 795 onclick="<%="newExtract("+itemId+")"%>" 796 tooltip="Create new child extract" 797 visible="<%=mode.hasEditLink() && createPermission && usePermission %>" 798 /> 780 799 </tbl:cell> 781 800 <tbl:cell column="physicalBioAssays"> -
trunk/www/biomaterials/extracts/view_extract.jsp
r5648 r5664 30 30 import="net.sf.basedb.core.Group" 31 31 import="net.sf.basedb.core.Item" 32 import="net.sf.basedb.core.CommonItem" 32 33 import="net.sf.basedb.core.ItemContext" 33 34 import="net.sf.basedb.core.ItemProxy" … … 36 37 import="net.sf.basedb.core.PhysicalBioAssay" 37 38 import="net.sf.basedb.core.Sample" 39 import="net.sf.basedb.core.BioMaterial" 38 40 import="net.sf.basedb.core.BioMaterialEvent" 41 import="net.sf.basedb.core.BioMaterialEventSource" 39 42 import="net.sf.basedb.core.BioWell" 40 43 import="net.sf.basedb.core.MultiPermissions" … … 44 47 import="net.sf.basedb.core.ItemQuery" 45 48 import="net.sf.basedb.core.ItemResultList" 49 import="net.sf.basedb.core.SpecialQuery" 46 50 import="net.sf.basedb.core.Include" 51 import="net.sf.basedb.core.query.ResultList" 47 52 import="net.sf.basedb.core.query.Orders" 48 53 import="net.sf.basedb.core.query.Hql" … … 124 129 Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); 125 130 } 131 function newExtract() 132 { 133 Main.viewOrEditItem('<%=ID%>', 'EXTRACT', 0, true, '&extract_id=<%=itemId%>'); 134 } 126 135 function shareItem() 127 136 { … … 230 239 title="Set owner…" 231 240 tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" 241 /> 242 <tbl:button 243 image="add.png" 244 onclick="newExtract()" 245 title="New child extract…" 246 tooltip="Create a new child extract from this extract" 247 visible="<%=sc.hasPermission(Permission.CREATE, Item.EXTRACT) && usePermission%>" 232 248 /> 233 249 <tbl:button … … 311 327 <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td> 312 328 </tr> 313 <%314 if (!extract.isPooled())315 {316 %>317 <tr>318 <td class="prompt">Sample</td>319 <td><base:propertyvalue item="<%=extract%>" property="parent"/>320 <%321 try322 {323 %>324 <%=extract.getSample() != null ? "(" + Values.formatNumber(creationEvent.getUsedQuantity(extract.getSample()), 2, " µg") + ")" : ""%>325 <%326 }327 catch (PermissionDeniedException ex)328 {}329 %>330 331 </td>332 </tr>333 <%334 }335 %>336 329 <tr> 337 330 <td class="prompt">Protocol</td> … … 378 371 379 372 <% 380 if (extract.isPooled()) 381 { 382 ItemQuery<Extract> extractsQuery = (ItemQuery<Extract>)creationEvent.getSources(); 383 extractsQuery.include(Include.ALL); 384 extractsQuery.order(Orders.asc(Hql.property("name"))); 385 ItemResultList<Extract> extracts = extractsQuery.list(dc); 386 %> 387 <h4 class="docked">Pooled from extracts</h4> 388 <tbl:table 389 id="pooled" 390 clazz="itemlist" 391 columns="all" 373 SpecialQuery<BioMaterialEventSource> sourceQuery = creationEvent.getEventSources(); 374 sourceQuery.order(Orders.asc(Hql.property("bioMaterial.name"))); 375 ResultList<BioMaterialEventSource> sources = sourceQuery.list(dc); 376 if (sources.size() == 0) 377 { 378 %> 379 <h4>Parent items</h4> 380 This extract doesn't have any parent items 381 (or, you don't have permission to view them). 382 <% 383 } 384 else 385 { 386 %> 387 <base:section 388 id="parentsSection" 389 title="<%="Parent items (" + sources.size() + ")"%>" 390 context="<%=cc%>" 392 391 > 393 <tbl:columndef 394 id="name" 395 title="Name" 396 /> 397 <tbl:columndef 398 id="quantity" 399 title="Used quantity (µg)" 400 /> 401 <tbl:columndef 402 id="description" 403 title="Description" 404 /> 405 <tbl:data> 406 <tbl:columns> 407 </tbl:columns> 408 <tbl:rows> 409 <% 410 for (Extract item : extracts) 411 { 412 %> 413 <tbl:row> 414 <tbl:cell column="name"><base:icon 392 <tbl:table 393 id="parents" 394 clazz="itemlist" 395 columns="all" 396 > 397 <tbl:columndef 398 id="name" 399 title="Name" 400 /> 401 <tbl:columndef 402 id="type" 403 title="Type" 404 /> 405 <tbl:columndef 406 id="quantity" 407 title="Used quantity (µg)" 408 /> 409 <tbl:columndef 410 id="description" 411 title="Description" 412 /> 413 <tbl:data> 414 <tbl:columns> 415 </tbl:columns> 416 <tbl:rows> 417 <% 418 for (BioMaterialEventSource item : sources) 419 { 420 BioMaterial bm = null; 421 try 422 { 423 bm = item.getBioMaterial(); 424 } 425 catch (PermissionDeniedException ex) 426 {} 427 %> 428 <tbl:row> 429 <tbl:cell column="name"><base:icon 415 430 image="deleted.gif" 416 431 tooltip="This item has been scheduled for deletion" 417 visible="<%=item.isRemoved()%>" 418 /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell> 419 <tbl:cell column="quantity"><%=Values.formatNumber(creationEvent.getUsedQuantity(item), 2)%></tbl:cell> 420 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 421 </tbl:row> 422 <% 423 } 424 %> 432 visible="<%=bm != null && bm.isRemoved()%>" 433 /><%=Base.getLinkedName(ID, bm, bm == null, true)%></tbl:cell> 434 <tbl:cell column="type"><%=bm != null ? bm.getType() : "" %></tbl:cell> 435 <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(), 2)%></tbl:cell> 436 <tbl:cell column="description"><%=HTML.encodeTags(bm == null ? "" : bm.getDescription())%></tbl:cell> 437 </tbl:row> 438 <% 439 } 440 %> 425 441 </tbl:rows> 426 </tbl:data> 427 </tbl:table> 428 <% 429 } 430 431 // Extracts this item is pooled in. 432 ItemQuery<BioMaterialEvent> poolingQuery = extract.getPoolingEvents(); 433 ItemResultList<BioMaterialEvent> poolingEvents = poolingQuery.list(dc); 434 if (poolingEvents.size() == 0) 435 { 436 %> 437 <h4>Pooled in extracts</h4> 438 No extracts have been pooled from this extract 442 </tbl:data> 443 </tbl:table> 444 </base:section> 445 <% 446 } 447 448 SpecialQuery<BioMaterialEventSource> childQuery = extract.getChildCreationEvents(); 449 childQuery.join(Hql.innerJoin("es", "event", "evt", true)); 450 childQuery.join(Hql.leftJoin("evt", "bioMaterial", "bm", null, true)); 451 childQuery.join(Hql.leftJoin("evt", "physicalBioAssay", "pba", null, true)); 452 childQuery.order(Orders.asc(Hql.property("pba", "name"))); 453 childQuery.order(Orders.asc(Hql.property("bm", "name"))); 454 ResultList<BioMaterialEventSource> children = childQuery.list(dc); 455 if (children.size() == 0) 456 { 457 %> 458 <h4>Child items</h4> 459 No child items have been created from this extract 439 460 (or, you don't have permission to view them). 440 461 <% … … 444 465 %> 445 466 <base:section 446 id=" pooledSection"447 title="<%=" Pooled in extracts (" + poolingEvents.size() + ")"%>"467 id="childSection" 468 title="<%="Child items (" + children.size() + ")"%>" 448 469 context="<%=cc%>" 449 470 > 450 471 <tbl:table 451 id=" poolChilds"472 id="children" 452 473 clazz="itemlist" 453 474 columns="all" … … 458 479 /> 459 480 <tbl:columndef 460 id=" quantity"461 title=" Original quantity (µg)"481 id="type" 482 title="Type" 462 483 /> 463 484 <tbl:columndef 464 id=" parents"465 title="Used extracts[quantity]"485 id="quantity" 486 title="Used quantity (µg)" 466 487 /> 467 488 <tbl:columndef … … 473 494 <tbl:rows> 474 495 <% 475 for (BioMaterialEvent poolEvt : poolingEvents)496 for (BioMaterialEventSource item : children) 476 497 { 477 ItemQuery<Extract> extractsQuery = (ItemQuery<Extract>)poolEvt.getSources(); 478 Extract child = (Extract)poolEvt.getBioMaterial(); 479 extractsQuery.include(Include.ALL); 480 extractsQuery.order(Orders.asc(Hql.property("name"))); 481 ItemResultList<Extract> parentExtracts = extractsQuery.list(dc); 498 CommonItem child = null; 499 try 500 { 501 BioMaterialEvent evt = item.getEvent(); 502 if (evt.getEventType() == BioMaterialEvent.Type.BIOASSAY) 503 { 504 child = evt.getPhysicalBioAssay(); 505 } 506 else 507 { 508 child = evt.getBioMaterial(); 509 } 510 } 511 catch (PermissionDeniedException ex) 512 {} 482 513 %> 483 514 <tbl:row> 484 <tbl:cell column="name"> 485 <base:icon 515 <tbl:cell column="name"><base:icon 486 516 image="deleted.gif" 487 517 tooltip="This item has been scheduled for deletion" 488 visible="<%=child.isRemoved()%>" 489 /> 490 <%=Base.getLinkedName(ID, child, false, true)%> 491 </tbl:cell> 492 <tbl:cell column="quantity"><%=Values.formatNumber(child.getOriginalQuantity(), 2)%></tbl:cell> 493 <tbl:cell column="parents"> 494 <% 495 String separator = ""; 496 for (Extract parent : parentExtracts) 497 { 498 out.write(separator); 499 if (parent.equals(extract)) 500 out.write(HTML.encodeTags(parent.getName())); 501 else 502 out.write(Base.getLinkedName(ID, parent, false, true)); 503 out.write("[" + Values.formatNumber(poolEvt.getUsedQuantity(parent), 2) + "µg]"); 504 separator = ", "; 505 } 506 %> 507 </tbl:cell> 508 <tbl:cell column="description"><%=HTML.encodeTags(child.getDescription())%></tbl:cell> 518 visible="<%=child != null && child.isRemoved()%>" 519 /><%=Base.getLinkedName(ID, child, child == null, true)%></tbl:cell> 520 <tbl:cell column="type"><%=child != null ? child.getType() : "" %></tbl:cell> 521 <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(), 2)%></tbl:cell> 522 <tbl:cell column="description"><%=HTML.encodeTags(child == null ? "" : child.getDescription())%></tbl:cell> 509 523 </tbl:row> 510 524 <% … … 517 531 <% 518 532 } 519 520 ItemQuery<PhysicalBioAssay> bioAssayQuery = extract.getPhysicalBioAssays();521 bioAssayQuery.include(Include.ALL);522 bioAssayQuery.order(Orders.asc(Hql.property("name")));523 ItemResultList<PhysicalBioAssay> bioAssays = bioAssayQuery.list(dc);524 if (bioAssays.size() == 0)525 {526 %>527 <h4>Physical bioassays</h4>528 No bioassays have been created from this extract529 (or you don't have the permission to view them)530 <%531 }532 else533 {534 %>535 <base:section536 id="bioAssaysSection"537 title="<%="Physical bioassays (" + bioAssays.size() + ")"%>"538 context="<%=cc%>"539 >540 <tbl:table541 id="bioAssays"542 clazz="itemlist"543 columns="all"544 >545 <tbl:columndef546 id="name"547 title="Name"548 />549 <tbl:columndef550 id="quantity"551 title="Used quantity (µg)"552 />553 <tbl:columndef554 id="description"555 title="Description"556 />557 <tbl:data>558 <tbl:columns></tbl:columns>559 <tbl:rows>560 <%561 for (PhysicalBioAssay pba : bioAssays)562 {563 %>564 <tbl:row>565 <tbl:cell column="name"><base:icon566 image="deleted.gif"567 tooltip="This item has been scheduled for deletion"568 visible="<%=pba.isRemoved()%>"569 /><%=Base.getLinkedName(ID, pba, false, true)%></tbl:cell>570 <tbl:cell column="quantity"><%=Values.formatNumber(pba.getCreationEvent().getUsedQuantity(extract), 2)%></tbl:cell>571 <tbl:cell column="description"><%=HTML.encodeTags(pba.getDescription())%></tbl:cell>572 </tbl:row>573 <%574 }575 %>576 </tbl:rows>577 </tbl:data>578 </tbl:table>579 </base:section>580 <%581 }582 533 %> 583 534 <jsp:include page="../../common/anytoany/list_anytoany.jsp"> -
trunk/www/biomaterials/samples/edit_sample.jsp
r5663 r5664 469 469 { 470 470 var frm = document.forms['sample']; 471 var useSamples = frm.parentType[1].checked 471 var useSamples = frm.parentType[1].checked; 472 472 frm.biosource_id.disabled = useSamples; 473 473 frm.samples.disabled = !useSamples; … … 815 815 <td> 816 816 <table border="0" cellspacing="0" cellpadding="0"> 817 <tr><td style="padding: 1px 0px 4px 0px; width: 150px;"><base:button 817 <tr><td style="padding: 1px 0px 4px 0px;"><base:button 818 style="width: 150px;" 818 819 onclick="addSamplesOnClick()" 819 820 title="Add samples…" -
trunk/www/biomaterials/samples/index.jsp
r5663 r5664 61 61 import="net.sf.basedb.util.formatter.WellCoordinateFormatter" 62 62 import="net.sf.basedb.util.formatter.NameableFormatter" 63 import="net.sf.basedb.util.formatter.ItemTypeFormatter" 63 64 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 64 65 … … 91 92 cc.setObject("export.formatter.&childCreationEvents(event.bioMaterial.name)", new NameableFormatter()); 92 93 cc.setObject("export.formatter.&children(name)", new NameableFormatter()); 94 cc.setObject("export.formatter.parentType", new ItemTypeFormatter()); 93 95 94 96 // Register dataloaders … … 118 120 parentSamplesQuery.order(Orders.asc(Hql.property("name"))); 119 121 parentSamplesQuery.include(cc.getInclude()); 120 cc.setObject("export.dataloader.&creationEvent.sources(bioMaterial.name)", new ItemQueryLoader(parentSamplesQuery, sampleParameter));122 cc.setObject("export.dataloader.&creationEvent.sources(bioMaterial.name)", new ParentBioMaterialLoader(parentSamplesQuery, sampleParameter)); 121 123 } 122 124 %> … … 264 266 265 267 // Parents tab 266 //sample.setPooled(Values.getBoolean(request.getParameter("pooled")));267 268 Item parentType = Item.valueOf(request.getParameter("parentType")); 268 269 if (parentType == Item.BIOSOURCE) -
trunk/www/biomaterials/samples/list_samples.jsp
r5663 r5664 101 101 final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); 102 102 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); 103 104 // Child extracts 103 105 final ItemQuery<Extract> extractQuery = Extract.getQuery(); 104 106 extractQuery.include(cc.getInclude()); … … 107 109 final boolean createExtractPermission = sc.hasPermission(Permission.CREATE, Item.EXTRACT); 108 110 111 // Child samples 109 112 final ItemQuery<Sample> childSamplesQuery = Sample.getQuery(); 110 113 childSamplesQuery.join(Hql.innerJoin("creationEvent", "ce")); … … 114 117 childSamplesQuery.include(cc.getInclude()); 115 118 119 // Parent samples 116 120 final ItemQuery<Sample> parentSamplesQuery = Sample.getQuery(); 117 121 parentSamplesQuery.join(Hql.innerJoin("childCreationEvents", "cce")); … … 377 381 exportable="true" 378 382 formatter="<%=dateFormatter%>" 383 /> 384 <% 385 Enumeration<String, String> parentTypes = new Enumeration<String, String>(); 386 parentTypes.add(Integer.toString(Item.BIOSOURCE.getValue()), Item.BIOSOURCE.toString()); 387 parentTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString()); 388 %> 389 <tbl:columndef 390 id="parentType" 391 title="Parent type" 392 property="parentType" 393 enumeration="<%=parentTypes%>" 394 datatype="int" 395 filterable="true" 396 exportable="true" 397 sortable="true" 379 398 /> 380 399 <tbl:columndef … … 756 775 <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" /> 757 776 <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" /> 777 <tbl:cell column="parentType"><%=parentType == null ? "" : parentType.toString() %></tbl:cell> 758 778 <tbl:cell column="parents"> 759 779 <% 760 if (item.hasSingleParent() || item.getParentType()== null)780 if (item.hasSingleParent() || parentType == null) 761 781 { 762 782 %> … … 783 803 } 784 804 %> 805 <%=parentType != null ? "<span class=\"itemtype\">(" + parentType + ")</span>" : "" %> 785 806 </tbl:cell> 786 807 <tbl:cell column="children"> -
trunk/www/biomaterials/samples/view_sample.jsp
r5663 r5664 373 373 { 374 374 %> 375 <h4>Parent items</h4> 376 This sample doesn't have any parent items 377 (or, you don't have permission to view them). 375 378 <% 376 379 } … … 439 442 } 440 443 441 // Samples this item is pooled in.442 444 SpecialQuery<BioMaterialEventSource> childQuery = sample.getChildCreationEvents(); 443 445 childQuery.join(Hql.innerJoin("es", "event", "evt", true)); -
trunk/www/include/styles/table.css
r5426 r5664 199 199 } 200 200 201 201 .itemlist .itemtype { 202 font-size: 10px; 203 color: #777777; 204 } 205 -
trunk/www/views/physicalbioassays/view_bioassay.jsp
r5662 r5664 35 35 import="net.sf.basedb.core.PhysicalBioAssay" 36 36 import="net.sf.basedb.core.ArraySlide" 37 import="net.sf.basedb.core.BioMaterial" 37 38 import="net.sf.basedb.core.BioMaterialEvent" 38 39 import="net.sf.basedb.core.BioMaterialEventSource" … … 46 47 import="net.sf.basedb.core.MultiPermissions" 47 48 import="net.sf.basedb.core.ItemQuery" 49 import="net.sf.basedb.core.SpecialQuery" 48 50 import="net.sf.basedb.core.Include" 49 import="net.sf.basedb.core.ItemResultList"50 51 import="net.sf.basedb.core.ItemResultList" 51 52 import="net.sf.basedb.core.PermissionDeniedException" … … 56 57 import="net.sf.basedb.core.query.Orders" 57 58 import="net.sf.basedb.core.query.Hql" 59 import="net.sf.basedb.core.query.ResultList" 58 60 import="net.sf.basedb.clients.web.Base" 59 61 import="net.sf.basedb.clients.web.ChangeHistoryUtil" … … 326 328 327 329 <% 328 ItemQuery<Extract> extractsQuery = (ItemQuery<Extract>)creationEvent.getSources(); 329 extractsQuery.include(Include.ALL); 330 extractsQuery.order(Orders.asc(Hql.property("srcevt", "position"))); 331 extractsQuery.order(Orders.asc(Hql.property("name"))); 332 ItemResultList<Extract> extracts = extractsQuery.list(dc); 333 if (extracts.size() == 0) 330 SpecialQuery<BioMaterialEventSource> sourceQuery = creationEvent.getEventSources(); 331 sourceQuery.order(Orders.asc(Hql.property("position"))); 332 sourceQuery.order(Orders.asc(Hql.property("bioMaterial.name"))); 333 ResultList<BioMaterialEventSource> sources = sourceQuery.list(dc); 334 if (sources.size() == 0) 334 335 { 335 336 %> … … 344 345 <base:section 345 346 id="extractSection" 346 title="<%="Extracts (" + extracts.size() + ")"%>"347 title="<%="Extracts (" + sources.size() + ")"%>" 347 348 context="<%=cc%>" 348 349 > … … 378 379 <tbl:rows> 379 380 <% 380 for ( Extract item : extracts)381 for (BioMaterialEventSource item : sources) 381 382 { 382 BioMaterialEventSource evtSrc = creationEvent.getEventSource(item); 383 BioMaterial bm = null; 384 try 385 { 386 bm = item.getBioMaterial(); 387 } 388 catch (PermissionDeniedException ex) 389 {} 383 390 %> 384 391 <tbl:row> 385 <tbl:cell column="position"><%= evtSrc.getPosition()%></tbl:cell>392 <tbl:cell column="position"><%=item.getPosition()%></tbl:cell> 386 393 <tbl:cell column="name"><base:icon 387 394 image="deleted.gif" 388 395 tooltip="This item has been scheduled for deletion" 389 visible="<%= item.isRemoved()%>"390 /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>391 <tbl:cell column="tag" ><base:propertyvalue item="<%=item%>" property="tag" /></tbl:cell>392 <tbl:cell column="quantity"><%=Values.formatNumber( evtSrc.getUsedQuantity(), 2)%></tbl:cell>393 <tbl:cell column="description"><%=HTML.encodeTags( item.getDescription())%></tbl:cell>396 visible="<%=bm != null && bm.isRemoved()%>" 397 /><%=Base.getLinkedName(ID, bm, bm == null, true)%></tbl:cell> 398 <tbl:cell column="tag" visible="<%=bm != null && bm.getType() == Item.EXTRACT%>"><base:propertyvalue item="<%=bm%>" property="tag" /></tbl:cell> 399 <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(), 2)%></tbl:cell> 400 <tbl:cell column="description"><%=HTML.encodeTags(bm == null ? "" : bm.getDescription())%></tbl:cell> 394 401 </tbl:row> 395 402 <%
Note: See TracChangeset
for help on using the changeset viewer.