Changeset 5723
- Timestamp:
- Sep 7, 2011, 3:08:08 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/ItemSubtype.java
r5713 r5723 52 52 public class ItemSubtype 53 53 extends BasicItem<ItemSubtypeData> 54 implements Nameable, Removable, Registered, SystemItem 54 implements Nameable, Removable, Registered, SystemItem, Subtypable 55 55 { 56 56 … … 349 349 } 350 350 // ------------------------------------------- 351 /* 352 From the Subtypable interface 353 ------------------------------------------- 354 */ 355 /** 356 @return A reference to self 357 */ 358 @Override 359 public ItemSubtype getItemSubtype() 360 { 361 return this; 362 } 363 /** 364 Do nothing. 365 */ 366 @Override 367 public void setItemSubtype(ItemSubtype subtype) 368 {} 369 // ------------------------------------------- 351 370 352 371 /* -
trunk/www/biomaterials/wizards/create_child_bioplate_step1.jsp
r5642 r5723 27 27 import="net.sf.basedb.core.BioPlateEventType" 28 28 import="net.sf.basedb.core.BioPlateType" 29 import="net.sf.basedb.core.BioWell" 29 30 import="net.sf.basedb.core.PlateGeometry" 30 31 import="net.sf.basedb.core.MeasuredBioMaterial" … … 32 33 import="net.sf.basedb.core.Protocol" 33 34 import="net.sf.basedb.core.Tag" 35 import="net.sf.basedb.core.ItemSubtype" 34 36 import="net.sf.basedb.core.DbControl" 35 37 import="net.sf.basedb.core.Item" … … 39 41 import="net.sf.basedb.core.SessionControl" 40 42 import="net.sf.basedb.core.SystemItems" 43 import="net.sf.basedb.core.PermissionDeniedException" 41 44 import="net.sf.basedb.core.query.Restrictions" 42 45 import="net.sf.basedb.core.query.Orders" … … 75 78 List<BioPlateType> recentPlateTypes = (List<BioPlateType>)cc.getRecent(dc, Item.BIOPLATETYPE, sourceBioMaterialType.name()); 76 79 List<Hardware> recentFreezers = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE, "freezer"); 80 81 // Load subtypes 82 final List<ItemSubtype> sampleSubtypes = sourceBioMaterialType == Item.SAMPLE ? 83 Base.getSubtypesQuery(Item.SAMPLE).list(dc) : null; 84 final List<ItemSubtype> extractSubtypes = Base.getSubtypesQuery(Item.EXTRACT).list(dc); 85 final List<ItemSubtype> bioAssaySubtypes = sourceBioMaterialType == Item.EXTRACT ? 86 Base.getSubtypesQuery(Item.PHYSICALBIOASSAY).list(dc) : null; 87 // Find a common itemsubtype (if any) 88 ItemSubtype commonSubtype = null; 89 boolean first = true; 90 for (BioWell well : sourcePlate.getBioWells().list(dc)) 91 { 92 try 93 { 94 if (!well.isEmpty()) 95 { 96 ItemSubtype subtype = well.getBioMaterial().getItemSubtype(); 97 if (first) 98 { 99 commonSubtype = subtype; 100 first = false; 101 } 102 else 103 { 104 if (subtype == null || !subtype.equals(commonSubtype)) 105 { 106 commonSubtype = null; 107 break; 108 } 109 } 110 } 111 } 112 catch (PermissionDeniedException ex) 113 {} 114 } 77 115 78 116 final String clazz = "class=\"text\""; … … 84 122 %> 85 123 <base:page type="popup" title="Create child bioplate - step 1/2"> 86 <base:head >124 <base:head scripts="subtypes.js,ajax.js"> 87 125 <script language="javascript"> 88 126 … … 135 173 } 136 174 url += '&resetTemporary=1'; 175 var childType = frm.child_biomaterial_type[frm.child_biomaterial_type.selectedIndex].value; 176 url += ItemSubtype.createRelatedFilter('main', 'HARDWARE', '', childType+'_subtype_id'); 137 177 Main.openPopup(url, 'SelectHardware', 1000, 700); 138 178 } … … 154 194 var frm = document.forms['main']; 155 195 var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setProtocolCallback'; 196 url += '&resetTemporary=1'; 156 197 if (frm.protocol_id.length > 1) 157 198 { … … 159 200 url += '&item_id='+id; 160 201 } 161 url += '&resetTemporary=1'; 202 var childType = frm.child_biomaterial_type[frm.child_biomaterial_type.selectedIndex].value; 203 url += ItemSubtype.createRelatedFilter('main', 'PROTOCOL', '', childType+'_subtype_id'); 162 204 Main.openPopup(url, 'SelectProtocol', 1000, 700); 163 205 } 206 164 207 function setProtocolCallback(id, name) 165 208 { … … 174 217 list.selectedIndex = 1; 175 218 } 219 220 function selectTagOnClick() 221 { 222 var frm = document.forms['main']; 223 var url = '../tags/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setTagCallback'; 224 url += '&resetTemporary=1'; 225 if (frm.protocol_id.length > 1) 226 { 227 var id = Math.abs(parseInt(frm.protocol_id[1].value)); 228 url += '&item_id='+id; 229 } 230 var childType = frm.child_biomaterial_type[frm.child_biomaterial_type.selectedIndex].value; 231 url += ItemSubtype.createRelatedFilter('main', 'TAG', '', childType+'_subtype_id'); 232 Main.openPopup(url, 'SelectTag', 1000, 700); 233 } 234 235 function setTagCallback(id, name) 236 { 237 var frm = document.forms['main']; 238 var list = frm.tag_id; 239 if (list.length < 2 || list[1].value == '0') // > 240 { 241 Forms.addListOption(list, 1, new Option()); 242 } 243 list[1].value = id; 244 list[1].text = name; 245 list.selectedIndex = 1; 246 } 247 176 248 177 249 function selectPlateGeometryOnClick() … … 196 268 } 197 269 270 var bioMaterialTypes = { 'EXTRACT': <%=Item.EXTRACT.getValue()%>, 'SAMPLE': <%=Item.SAMPLE.getValue()%> }; 198 271 function selectBioPlateTypeOnClick() 199 272 { … … 201 274 var url = '../bioplatetypes/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setBioPlateTypeCallback'; 202 275 if (frm.bioplatetype_id.length > 0) url += '&item_id='+frm.bioplatetype_id[0].value; 276 277 url += '&resetTemporary=1'; 278 var childType = frm.child_biomaterial_type[frm.child_biomaterial_type.selectedIndex].value; 279 // Restrict to plates that can holds to target biomaterial 280 url += '&tmpfilter:INT:bioMaterialType=|'+bioMaterialTypes[childType]; 281 var subtypeId = ItemSubtype.getSubtypeId('main', childType+'_subtype_id'); 282 // Restrict to plates with the given subtype 283 url += '&tmpfilter:INT:itemSubtype='+(subtypeId ? '|' + subtypeId : '='); 284 203 285 Main.openPopup(url, 'SelectBioPlateType', 1000, 700); 204 286 } … … 242 324 var frm = document.forms['main']; 243 325 var childType = frm.child_biomaterial_type[frm.child_biomaterial_type.selectedIndex].value; 244 Main.showHide('tagDiv', childType == 'EXTRACT'); 326 var isSample = childType == 'SAMPLE'; 327 var isExtract = childType == 'EXTRACT'; 245 328 var isBioAssay = childType == 'PHYSICALBIOASSAY'; 329 Main.showHide('sampleSubtypesDiv', isSample); 330 Main.showHide('extractSubtypesDiv', isExtract); 331 Main.showHide('bioAssaySubtypesDiv', isBioAssay); 332 Main.showHide('tagDiv', isExtract); 246 333 Main.showHide('originalQuantityDiv', !isBioAssay); 247 334 Main.showHide('freezerDiv', !isBioAssay); … … 260 347 <base:body onload="init()"> 261 348 262 <h3>Create child bioplate - step 1/2 </h3>349 <h3>Create child bioplate - step 1/2 <base:help helpid="bioplateevent.create-child-1" /></h3> 263 350 <div class="boxedbottom" style="height: <%=(int)(scale*500)%>px; background: #e0e0e0;"> 264 351 <form name="main" action="create_child_bioplate_step2.jsp" method="post"> … … 347 434 <td class="prompt">Type</td> 348 435 <td> 349 <select name="child_biomaterial_type" class="required " onchange="childTypeOnChange()">436 <select name="child_biomaterial_type" class="required selectionlist" onchange="childTypeOnChange()"> 350 437 <% 351 438 if (sourceBioMaterialType == Item.SAMPLE) … … 368 455 </tr> 369 456 <% 370 if (s ourceBioMaterialType == Item.EXTRACT)457 if (sampleSubtypes != null && sampleSubtypes.size() > 0) 371 458 { 372 final ItemQuery<Tag> tagsQuery = Tag.getQuery();373 tagsQuery.order(Orders.asc(Hql.property("name")));374 tagsQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);375 tagsQuery.setCacheResult(true);376 final List<Tag> tags = tagsQuery.list(dc);377 459 %> 378 <tr id=" tagDiv">379 <td class="prompt"> Tag</td>460 <tr id="sampleSubtypesDiv" style="display: none;"> 461 <td class="prompt">Subtype</td> 380 462 <td> 381 <select name="tag_id" size="1" 382 style="width: 20em;"> 383 <option value="">- none - 463 <select name="SAMPLE_subtype_id" class="selectionlist"> 464 <option value="0">- none - 384 465 <% 385 for (Tag tag : tags) 466 int currentSubtypeId = 0; 467 if (commonSubtype != null) 386 468 { 469 List<ItemSubtype> relatedToParent = ItemSubtype.getParentSubtypes(dc, commonSubtype, Item.SAMPLE); 470 if (relatedToParent.size() > 0) currentSubtypeId = relatedToParent.get(0).getId(); 471 } 472 for (ItemSubtype subtype : sampleSubtypes) 473 { 474 int id = subtype.getId(); 387 475 %> 388 <option value="<%=tag.getId()%>"><%=HTML.encodeTags(tag.getName())%> 476 <option value="<%=id%>" 477 <%=id == currentSubtypeId ? "selected" : ""%> 478 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 479 ><%=HTML.encodeTags(subtype.getName())%> 480 <% 481 } 482 %> 483 </select> 484 </td> 485 </tr> 486 <% 487 } 488 if (extractSubtypes != null && extractSubtypes.size() > 0) 489 { 490 %> 491 <tr id="extractSubtypesDiv" style="display: none;"> 492 <td class="prompt">Subtype</td> 493 <td> 494 <select name="EXTRACT_subtype_id" class="selectionlist"> 495 <option value="0">- none - 496 <% 497 int currentSubtypeId = 0; 498 if (commonSubtype != null) 499 { 500 List<ItemSubtype> relatedToParent = ItemSubtype.getParentSubtypes(dc, commonSubtype, Item.EXTRACT); 501 if (relatedToParent.size() > 0) currentSubtypeId = relatedToParent.get(0).getId(); 502 } 503 for (ItemSubtype subtype : extractSubtypes) 504 { 505 int id = subtype.getId(); 506 %> 507 <option value="<%=id%>" 508 <%=id == currentSubtypeId ? "selected" : ""%> 509 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 510 ><%=HTML.encodeTags(subtype.getName())%> 389 511 <% 390 512 } … … 396 518 } 397 519 %> 398 520 <% 521 if (bioAssaySubtypes != null && bioAssaySubtypes.size() > 0) 522 { 523 %> 524 <tr id="bioAssaySubtypesDiv" style="display: none;"> 525 <td class="prompt">Subtype</td> 526 <td> 527 <select name="PHYSICALBIOASSAY_subtype_id" class="selectionlist"> 528 <option value="0">- none - 529 <% 530 int currentSubtypeId = 0; 531 if (commonSubtype != null) 532 { 533 List<ItemSubtype> relatedToParent = ItemSubtype.getParentSubtypes(dc, commonSubtype, Item.PHYSICALBIOASSAY); 534 if (relatedToParent.size() > 0) currentSubtypeId = relatedToParent.get(0).getId(); 535 } 536 for (ItemSubtype subtype : bioAssaySubtypes) 537 { 538 int id = subtype.getId(); 539 %> 540 <option value="<%=id%>" 541 <%=id == currentSubtypeId ? "selected" : ""%> 542 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 543 ><%=HTML.encodeTags(subtype.getName())%> 544 <% 545 } 546 %> 547 </select> 548 </td> 549 </tr> 550 <% 551 } 552 %> 553 <tr id="tagDiv" style="display: none;"> 554 <td class="prompt">Tag</td> 555 <td> 556 <base:select 557 id="tag_id" 558 clazz="selectionlist" 559 required="false" 560 unselectedtext="<%=sourceBioMaterialType == Item.SAMPLE ? "- none -" : "- same as parent -" %>" 561 current="<%=null%>" 562 onselect="selectTagOnClick()" 563 /> 564 </td> 565 </tr> 399 566 <tr id="originalQuantityDiv"> 400 567 <td class="prompt">Original quantity</td> -
trunk/www/biomaterials/wizards/create_child_bioplate_step2.jsp
r5642 r5723 717 717 <!-- child biomaterial properties --> 718 718 <input type="hidden" name="child_biomaterial_type" value="<%=childBioMaterialType.name()%>"> 719 <input type="hidden" name="subtype_id" value="<%=request.getParameter(childBioMaterialType.name() + "_subtype_id")%>"> 719 720 <input type="hidden" name="original_quantity" value="<%=HTML.encodeTags(request.getParameter("original_quantity"))%>"> 720 721 <input type="hidden" name="used_quantity" value="<%=HTML.encodeTags(request.getParameter("used_quantity"))%>"> 721 722 <input type="hidden" name="child_description" value="<%=HTML.encodeTags(request.getParameter("child_description"))%>"> 722 <input type="hidden" name=" label_id" value="<%=HTML.encodeTags(request.getParameter("label_id"))%>">723 <input type="hidden" name="tag_id" value="<%=HTML.encodeTags(request.getParameter("tag_id"))%>"> 723 724 724 725 <tbl:toolbar id="toolbar.mappings" style="border-left: 0px; border-right: 0px; border-top: 0px;"> -
trunk/www/biomaterials/wizards/index.jsp
r5722 r5723 43 43 import="net.sf.basedb.core.Extract" 44 44 import="net.sf.basedb.core.Tag" 45 import="net.sf.basedb.core.ItemSubtype" 45 46 import="net.sf.basedb.core.PlateGeometry" 46 47 import="net.sf.basedb.core.InvalidDataException" … … 239 240 } 240 241 } 242 ItemSubtype subtype = null; 243 int subtypeId = Values.getInt(request.getParameter("subtype_id")); 244 if (subtypeId > 0) 245 { 246 subtype = ItemSubtype.getById(dc, subtypeId); 247 cc.setRecent(subtype, sourceBioMaterialType.name(), maxRecent); 248 } 249 Tag tag = null; 250 int tagId = Values.getInt(request.getParameter("tag_id")); 251 if (tagId > 0) 252 { 253 tag = Tag.getById(dc, tagId); 254 } 241 255 int numChildPlates = Values.getInt(request.getParameter("number_of_plates")); 242 256 int size = Values.getInt(request.getParameter("size")); … … 270 284 pba.setDescription(Values.getStringOrNull(request.getParameter("plate_description"))); 271 285 pba.setSize(size); 286 pba.setItemSubtype(subtype); 272 287 dc.saveItem(pba); 273 288 pbaCreationEvent = pba.getCreationEvent(); … … 302 317 BioWell well = childPlate.getBioWell(row, column); 303 318 MeasuredBioMaterial child = null; 304 boolean pooled = childBioMaterialType == sourceBioMaterialType;305 319 if (childBioMaterialType == Item.SAMPLE) 306 320 { … … 309 323 else if (childBioMaterialType == Item.EXTRACT) 310 324 { 311 child = Extract.getNew(dc, destParticipant); 312 //if (!pooled) ((Extract)child).setSample((Sample)parent).setUsedQuantity(usedQuantity); 325 Extract extract = Extract.getNew(dc, destParticipant); 326 if (tag != null) 327 { 328 extract.setTag(tag); 329 } 330 else if (parent instanceof Extract) 331 { 332 extract.setTag(((Extract)parent).getTag()); 333 } 334 child = extract; 313 335 } 314 /*315 else if (childBioMaterialType == Item.LABELEDEXTRACT)316 {317 Label label = Label.getById(dc, Values.getInt(request.getParameter("label_id")));318 child = LabeledExtract.getNew(dc, label, destParticipant);319 if (!pooled) ((LabeledExtract)child).setExtract((Extract)parent, usedQuantity);320 }321 */322 336 else 323 337 { 324 338 throw new InvalidDataException("Can't create child biomaterial of type: " + childBioMaterialType); 325 339 } 340 child.setItemSubtype(subtype); 326 341 child.setName(Values.getStringOrNull(request.getParameter(prefix + ".name"))); 327 342 child.setDescription(Values.getStringOrNull(request.getParameter("child_description"))); 328 343 child.setBioWell(well); 329 344 child.setOriginalQuantity(originalQuantity); 330 331 if (pooled) 332 { 333 child.getCreationEvent().addSource(parent).setUsedQuantity(usedQuantity); 334 } 345 child.getCreationEvent().setSource(parent).setUsedQuantity(usedQuantity); 335 346 dc.saveItem(child); 336 347 } … … 339 350 } 340 351 } 341 342 352 } 343 353 -
trunk/www/biomaterials/wizards/move_biomaterial.jsp
r5722 r5723 73 73 catch (PermissionDeniedException ex) 74 74 {} 75 // Find a common itemsubtype (if any) 75 76 ItemSubtype commonSubtype = null; 76 77 boolean first = true; -
trunk/www/include/scripts/subtypes.js
r5701 r5723 92 92 } 93 93 94 this.createRelatedFilter = function(formId, relatedItemType, defaultSubtypeId )95 { 96 var subtypeId = this.getSubtypeId(formId );94 this.createRelatedFilter = function(formId, relatedItemType, defaultSubtypeId, listName) 95 { 96 var subtypeId = this.getSubtypeId(formId, listName); 97 97 var relatedSubtype = this.getRelatedSubtype(subtypeId, relatedItemType, defaultSubtypeId); 98 98 return relatedSubtype ? '&tmpfilter:INT:itemSubtype=' + relatedSubtype.id : ''; 99 99 } 100 100 101 this.getSubtypeId = function(formId )101 this.getSubtypeId = function(formId, listName) 102 102 { 103 103 var frm = document.forms[formId]; 104 104 if (!frm) return null; 105 var list = frm['subtype_id']; 105 if (!listName) listName = 'subtype_id'; 106 var list = frm[listName]; 106 107 if (!list || list.disabled || list.length == 0) return null; 107 108 return Math.abs(parseInt(list[list.selectedIndex].value));
Note: See TracChangeset
for help on using the changeset viewer.