Changeset 5709
- Timestamp:
- Aug 26, 2011, 1:26:09 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/BioPlateType.java
r5641 r5709 237 237 238 238 /** 239 Get the subtype that biomaterial items should have when placed 240 on a plate with this bioplate type. 241 @return A subtype or null if not important 242 @since 3.0 243 */ 244 public ItemSubtype getItemSubtype() 245 { 246 return getDbControl().getItem(ItemSubtype.class, getData().getItemSubtype()); 247 } 248 249 /** 250 Set the subtype that biomaterial items should have when placed on a 251 plate with the bioplate type. A subtype can only be specified if 252 a biomaterial type has been set and the given subtype must be compatible 253 with the biomaterial type. 254 @param subtype A subtype or null if the subtype is not important 255 @since 3.0 256 */ 257 public void setItemSubtype(ItemSubtype subtype) 258 { 259 checkPermission(Permission.WRITE); 260 261 if (subtype == null) 262 { 263 getData().setItemSubtype(null); 264 } 265 else 266 { 267 Item bmType = getBioMaterialType(); 268 if (bmType == null) 269 { 270 throw new InvalidDataException("Can't set subtype when no biomaterial type has been set: " + this.getName()); 271 } 272 if (bmType != subtype.getMainItemType()) 273 { 274 throw new InvalidDataException("The subtype is not used for " + bmType.name() + ": " + subtype.getName()); 275 } 276 subtype.checkPermission(Permission.USE); 277 getData().setItemSubtype(subtype.getData()); 278 } 279 } 280 281 /** 239 282 Get the lock mode for wells located on plates of this plate type. 240 283 The lock mode determines if biomaterial may be changed in the -
trunk/src/core/net/sf/basedb/core/Install.java
r5699 r5709 646 646 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating bioplate types..."); 647 647 BioPlateTypeData storagePlate = createBioPlateType("Storage plate", "A generic storage plate for all types of biomaterial.", 648 null, BioWell.LockMode.UNLOCKED);648 null, null, BioWell.LockMode.UNLOCKED); 649 649 BioPlateTypeData sampleReactionPlate = createBioPlateType("Sample reaction plate", "A generic reaction plate for samples.", 650 Item.SAMPLE, BioWell.LockMode.LOCKED_AFTER_ADD);650 Item.SAMPLE, null, BioWell.LockMode.LOCKED_AFTER_ADD); 651 651 BioPlateTypeData extractReactionPlate = createBioPlateType("Extract reaction plate", "A generic reaction plate for extracts.", 652 Item.EXTRACT, BioWell.LockMode.LOCKED_AFTER_ADD); 653 652 Item.EXTRACT, null, BioWell.LockMode.LOCKED_AFTER_ADD); 653 BioPlateTypeData labeledExtractReactionPlate = createBioPlateType("Labeled extract reaction plate", 654 "A generic reaction plate for labeled extracts.", 655 Item.EXTRACT, labeledExtract, BioWell.LockMode.LOCKED_AFTER_ADD); 656 654 657 BioPlateEventTypeData genericEvent = createBioPlateEventType("Generic", BioPlateEventType.GENERIC, 655 658 "An event that does something unspecified to the participating bioplates. Use the " + … … 1669 1672 */ 1670 1673 private static BioPlateTypeData createBioPlateType(String name, String description, 1671 Item biomaterialType, BioWell.LockMode lockedMode)1674 Item biomaterialType, ItemSubtypeData subtype, BioWell.LockMode lockedMode) 1672 1675 throws BaseException 1673 1676 { … … 1687 1690 if (pt != null) 1688 1691 { 1692 if (pt.getItemSubtype() == null && subtype != null) 1693 { 1694 pt.setItemSubtype(subtype); 1695 } 1689 1696 log.info("createBioPlateType: EXISTS [name="+name+"]"); 1690 1697 HibernateUtil.commit(tx); … … 1696 1703 pt.setDescription(description); 1697 1704 pt.setBioMaterialType(biomaterialType == null ? null : biomaterialType.getValue()); 1705 pt.setItemSubtype(subtype); 1698 1706 pt.setLockMode(lockedMode.getValue()); 1699 1707 HibernateUtil.saveData(session, pt); -
trunk/src/core/net/sf/basedb/core/data/BioPlateTypeData.java
r5456 r5709 101 101 } 102 102 103 private ItemSubtypeData subtype; 104 /** 105 Get the subtype of biomaterials that can be placed on plates of this type. 106 @hibernate.many-to-one column="`subtype_id`" not-null="false" outer-join="false" 107 @since 3.0 108 */ 109 public ItemSubtypeData getItemSubtype() 110 { 111 return subtype; 112 } 113 public void setItemSubtype(ItemSubtypeData subtype) 114 { 115 this.subtype = subtype; 116 } 117 103 118 private int lockMode; 104 119 /** -
trunk/www/biomaterials/bioplates/list_bioplates.jsp
r5708 r5709 37 37 import="net.sf.basedb.core.Include" 38 38 import="net.sf.basedb.core.Type" 39 import="net.sf.basedb.core.ItemSubtype" 39 40 import="net.sf.basedb.core.ItemResultIterator" 40 41 import="net.sf.basedb.core.ItemResultList" … … 100 101 { 101 102 final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); 103 104 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(null); 105 subtypesQuery.restrict( 106 Restrictions.in( 107 Hql.property("itemType"), 108 Expressions.integer(Item.SAMPLE.getValue()), Expressions.integer(Item.EXTRACT.getValue()) 109 )); 102 110 103 111 final ItemQuery<PlateGeometry> geometryQuery = PlateGeometry.getQuery(); … … 322 330 exportable="true" 323 331 enumeration="<%=bioMaterialTypes%>" 332 /> 333 <tbl:columndef 334 id="bioMaterialSubtype" 335 property="bioPlateType.itemSubtype" 336 sortproperty="bioPlateType.itemSubtype.name" 337 exportproperty="bioPlateType.itemSubtype.name:string" 338 datatype="int" 339 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-any-")%>" 340 title="Biomaterial subtype" 341 sortable="true" 342 filterable="true" 343 exportable="true" 324 344 /> 325 345 <tbl:columndef … … 588 608 Integer i = bmType.getValue(dc, item); 589 609 %><%=i == null ? "<i>- any -</i>" : Item.fromValue(i).toString() %></tbl:cell> 610 <tbl:cell column="bioMaterialSubtype"><base:propertyvalue 611 item="<%=item%>" 612 property="bioPlateType.itemSubtype" 613 enableEditLink="<%=mode.hasEditLink()%>" 614 enablePropertyLink="<%=mode.hasPropertyLink()%>" 615 nulltext="<i>- any -</i>" 616 /></tbl:cell> 590 617 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 591 618 <% -
trunk/www/biomaterials/bioplates/wells/edit_biowell.jsp
r5708 r5709 31 31 import="net.sf.basedb.core.BioPlateType" 32 32 import="net.sf.basedb.core.BioWell" 33 import="net.sf.basedb.core.ItemSubtype" 33 34 import="net.sf.basedb.core.MeasuredBioMaterial" 34 35 import="net.sf.basedb.core.Sample" … … 64 65 BioPlateType bioPlateType = bioPlate.getBioPlateType(); 65 66 Item bioMaterialType = bioPlateType.getBioMaterialType(); 67 ItemSubtype bioMaterialSubType = bioPlateType.getItemSubtype(); 66 68 67 69 bioWell.checkPermission(Permission.WRITE); … … 132 134 } 133 135 url += '&resetTemporary=1&tmpfilter:STRING:bioWell='+escape('='); 136 <% 137 if (bioMaterialSubType != null) 138 { 139 %> 140 url += '&tmpfilter:INT:itemSubtype=<%=bioMaterialSubType.getId()%>'; 141 <% 142 } 143 %> 134 144 Main.openPopup(url, 'Select'+type, 1000, 700); 135 145 } … … 188 198 { 189 199 Item currentBmType = currentBioMaterial == null ? null : currentBioMaterial.getType(); 200 String subtype = bioMaterialSubType != null ? " ("+HTML.encodeTags(bioMaterialSubType.getName()) + ")" : ""; 190 201 %> 191 202 <option value="0">- none - 192 203 <option value="<%=Item.SAMPLE.name()%>" 193 <%=currentBmType == Item.SAMPLE || bioMaterialType == Item.SAMPLE ? "selected" : ""%>>Sample 204 <%=currentBmType == Item.SAMPLE || bioMaterialType == Item.SAMPLE ? "selected" : ""%>>Sample<%=subtype %> 194 205 <option value="<%=Item.EXTRACT.name()%>" 195 <%=currentBmType == Item.EXTRACT || bioMaterialType == Item.EXTRACT ? "selected" : ""%>>Extract 206 <%=currentBmType == Item.EXTRACT || bioMaterialType == Item.EXTRACT ? "selected" : ""%>>Extract<%=subtype %> 196 207 <% 197 208 } -
trunk/www/biomaterials/bioplates/wells/list_biowells.jsp
r5525 r5709 395 395 BioWell item = biowells.next(); 396 396 int itemId = item.getId(); 397 String coordinate = rowFormatter.format(item.getRow()) + columnFormatter.format(item.getColumn()); 397 398 index++; 398 399 numListed++; … … 429 430 name="<%=itemId%>" 430 431 value="<%=itemId%>" 431 title=" [<%=rowFormatter.format(item.getRow())%>,<%=columnFormatter.format(item.getColumn())%>]"432 title="<%=coordinate%>" 432 433 <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 433 434 ></tbl:header> … … 439 440 name="item_id" 440 441 value="<%=itemId%>" 441 title=" [<%=rowFormatter.format(item.getRow())%>,<%=columnFormatter.format(item.getColumn())%>]"442 title="<%=coordinate%>" 442 443 <%=selectedItemId == itemId ? "checked" : ""%> 443 444 ></tbl:header> -
trunk/www/biomaterials/bioplatetypes/edit_platetype.jsp
r5708 r5709 34 34 import="net.sf.basedb.core.BioPlateType" 35 35 import="net.sf.basedb.core.BioWell" 36 import="net.sf.basedb.core.ItemSubtype" 36 37 import="net.sf.basedb.core.ItemQuery" 37 38 import="net.sf.basedb.core.ItemResultList" 38 39 import="net.sf.basedb.core.PermissionDeniedException" 39 40 import="net.sf.basedb.core.BaseException" 41 import="net.sf.basedb.core.query.Expressions" 42 import="net.sf.basedb.core.query.Restrictions" 40 43 import="net.sf.basedb.core.query.Orders" 41 44 import="net.sf.basedb.core.query.Hql" … … 68 71 BioPlateType bioPlateType = null; 69 72 BioWell.LockMode lockMode = BioWell.LockMode.UNLOCKED; 73 boolean readCurrentSubtype = true; 74 ItemSubtype currentSubtype = null; 75 ItemQuery<ItemSubtype> subtypesQuery = null; 70 76 71 77 if (itemId == 0) … … 75 81 int lm = Values.getInt(cc.getPropertyValue("lockMode")); 76 82 lockMode = BioWell.LockMode.fromValue(lm); 83 subtypesQuery = Base.getSubtypesQuery(null); 84 subtypesQuery.restrict( 85 Restrictions.in( 86 Hql.property("itemType"), 87 Expressions.integer(Item.SAMPLE.getValue()), Expressions.integer(Item.EXTRACT.getValue()) 88 )); 77 89 } 78 90 else … … 83 95 cc.setObject("item", bioPlateType); 84 96 title = "Edit bioplate type -- " + HTML.encodeTags(bioPlateType.getName()); 97 try 98 { 99 currentSubtype = bioPlateType.getItemSubtype(); 100 } 101 catch (PermissionDeniedException ex) 102 { 103 readCurrentSubtype = false; 104 } 105 if (bioPlateType.getBioMaterialType() != null) 106 { 107 subtypesQuery = Base.getSubtypesQuery(bioPlateType.getBioMaterialType()); 108 } 85 109 } 86 110 final String clazz = "class=\"text\""; … … 88 112 JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioPlateType); 89 113 ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); 114 90 115 %> 91 116 <base:page type="popup" title="<%=title%>"> … … 126 151 frm.name.focus(); 127 152 frm.name.select(); 153 bioMaterialTypeOnChange(); 128 154 <% 129 155 } 130 156 %> 157 } 158 159 var subtypeOptions = null; 160 function bioMaterialTypeOnChange() 161 { 162 var frm = document.forms['bioPlateType']; 163 if (subtypeOptions == null) 164 { 165 // Cache all options in the list 166 subtypeOptions = new Array(); 167 for (var i = 1; i < frm.subtype_id.length; i++) 168 { 169 var opt = frm.subtype_id[i]; 170 subtypeOptions[subtypeOptions.length] = frm.subtype_id[i]; 171 } 172 } 173 174 var bmType = frm.bioMaterialType[frm.bioMaterialType.selectedIndex].value; 175 176 frm.subtype_id.selectedIndex = 0; 177 if (bmType == '') 178 { 179 frm.subtype_id.disabled = true; 180 } 181 else 182 { 183 frm.subtype_id.disabled = false; 184 // Clean the list... 185 frm.subtype_id.length = 1; 186 // ...and re-populate from the cache 187 for (var i = 0; i < subtypeOptions.length; i++) 188 { 189 if (subtypeOptions[i].attributes['bmtype'].value == bmType) 190 { 191 frm.subtype_id[frm.subtype_id.length] = subtypeOptions[i]; 192 } 193 } 194 } 131 195 } 132 196 </script> … … 149 213 size="40" maxlength="<%=BioPlateType.MAX_NAME_LENGTH%>"></td> 150 214 </tr> 215 <tr valign=top> 216 <td class="prompt">Biomaterial type</td> 217 <% 218 if (bioPlateType == null) 219 { 220 %> 221 <td> 222 <select name="bioMaterialType" class="required unchangeable" onchange="bioMaterialTypeOnChange()"> 223 <option value="">- any - 224 <option value="<%=Item.SAMPLE.name()%>">Sample 225 <option value="<%=Item.EXTRACT.name()%>">Extract 226 </select> 227 </td> 228 <% 229 } 230 else 231 { 232 %> 233 <td><%=bioPlateType.getBioMaterialType() == null ? "- any -" : bioPlateType.getBioMaterialType()%></td> 234 <% 235 } 236 %> 237 </tr> 151 238 <% 152 if ( bioPlateType == null)239 if (subtypesQuery != null) 153 240 { 154 241 %> 155 <tr valign=top> 156 <td class="prompt">Biomaterial type</td> 157 <td> 158 <select name="bioMaterialType" class="required unchangeable"> 159 <option value="">any 160 <option value="<%=Item.SAMPLE.name()%>">Sample 161 <option value="<%=Item.EXTRACT.name()%>">Extract 242 <tr valign="top"> 243 <td class="prompt">Biomaterial subtype</td> 244 <td colspan="2"> 245 <select name="subtype_id" 246 <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%> 247 onchange="subtypeOnChange()" 248 > 249 <% 250 if (!readCurrentSubtype) 251 { 252 %> 253 <option value="-1">- denied - 254 <% 255 } 256 else 257 { 258 %> 259 <option value="0">-any- 260 <% 261 int currentSubtypeId = currentSubtype == null ? 0 : currentSubtype.getId(); 262 for (ItemSubtype subtype : subtypesQuery.list(dc)) 263 { 264 int id = subtype.getId(); 265 if (id != currentSubtypeId && subtype.isRemoved()) continue; 266 %> 267 <option value="<%=id == currentSubtypeId && bioPlateType != null ? -id : id%>" 268 <%=id == currentSubtypeId ? "selected" : ""%> 269 title="<%=HTML.encodeTags(subtype.getDescription()) %>" 270 bmtype="<%=subtype.getMainItemType().name() %>" 271 ><%=HTML.encodeTags(subtype.getName())%> 272 <% 273 } 274 } 275 %> 162 276 </select> 163 277 </td> -
trunk/www/biomaterials/bioplatetypes/index.jsp
r5590 r5709 30 30 import="net.sf.basedb.core.BioPlateType" 31 31 import="net.sf.basedb.core.BioWell" 32 import="net.sf.basedb.core.ItemSubtype" 32 33 import="net.sf.basedb.core.ItemQuery" 33 34 import="net.sf.basedb.core.ItemResultIterator" … … 161 162 plateType.setLockMode(BioWell.LockMode.valueOf(request.getParameter("lockMode"))); 162 163 164 int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); 165 ItemSubtype subtype = null; 166 if (subtypeId >= 0) // < 0 = denied or unchanged 167 { 168 if (subtypeId > 0) subtype = ItemSubtype.getById(dc, subtypeId); 169 plateType.setItemSubtype(subtype); 170 } 171 163 172 // OnSave extensions 164 173 invoker.render(OnSaveRenderer.ON_SAVE); -
trunk/www/biomaterials/bioplatetypes/list_platetypes.jsp
r5708 r5709 32 32 import="net.sf.basedb.core.Type" 33 33 import="net.sf.basedb.core.BioWell" 34 import="net.sf.basedb.core.ItemSubtype" 34 35 import="net.sf.basedb.core.ItemResultIterator" 36 import="net.sf.basedb.core.ItemQuery" 35 37 import="net.sf.basedb.core.ItemResultList" 36 38 import="net.sf.basedb.core.ItemContext" … … 99 101 { 100 102 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 103 final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(null); 104 subtypesQuery.restrict( 105 Restrictions.in( 106 Hql.property("itemType"), 107 Expressions.integer(Item.SAMPLE.getValue()), Expressions.integer(Item.EXTRACT.getValue()) 108 )); 101 109 try 102 110 { … … 242 250 exportable="true" 243 251 enumeration="<%=bioMaterialTypes%>" 252 /> 253 <tbl:columndef 254 id="itemSubtype" 255 property="itemSubtype" 256 sortproperty="itemSubtype.name" 257 exportproperty="itemSubtype.name:string" 258 datatype="int" 259 enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>" 260 title="Biomaterial subtype" 261 sortable="true" 262 filterable="true" 263 exportable="true" 244 264 /> 245 265 <tbl:columndef … … 409 429 <tbl:cell column="id"><%=item.getId()%></tbl:cell> 410 430 <tbl:cell column="bioMaterialType"><%=item.getBioMaterialType() == null ? "<i>- any -</i>" : item.getBioMaterialType().toString() %></tbl:cell> 431 <tbl:cell column="itemSubtype"><base:propertyvalue 432 item="<%=item%>" 433 property="itemSubtype" 434 enableEditLink="<%=mode.hasEditLink()%>" 435 enablePropertyLink="<%=mode.hasPropertyLink()%>" 436 /></tbl:cell> 411 437 <tbl:cell column="lockMode"><%=item.getLockMode()%></tbl:cell> 412 438 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> -
trunk/www/biomaterials/bioplatetypes/view_platetype.jsp
r5708 r5709 219 219 </tr> 220 220 <tr> 221 <td class="prompt">Biomaterial subtype</td> 222 <td><base:propertyvalue item="<%=plateType%>" property="itemSubtype" nulltext="<i>- any -</i>"/></td> 223 </tr> 224 <tr> 221 225 <td class="prompt">Well lock mode</td> 222 226 <td><%=plateType.getLockMode()%></td> -
trunk/www/biomaterials/extracts/edit_extract.jsp
r5708 r5709 457 457 } 458 458 url += '&resetTemporary=1&tmpfilter:INT:bioPlateType.lockMode=<><%=BioWell.LockMode.LOCKED_AFTER_CREATE.getValue()%>'; 459 // Restrict to plates that can holds extracts 460 url += '&tmpfilter:INT:bioPlateType.bioMaterialType=|<%=itemType.getValue()%>'; 461 var subtypeId = ItemSubtype.getSubtypeId('extract'); 462 // Restrict to plates with the given subtype 463 url += '&tmpfilter:INT:bioPlateType.itemSubtype='+(subtypeId ? '|' + subtypeId : '='); 459 464 url += '&tmpfilter:BOOLEAN:destroyed=false'; 460 465 Main.openPopup(url, 'SelectBioplate', 1000, 700); … … 493 498 Forms.addListOption(list, 1, new Option()); 494 499 list[1].value = '<%=currentBioWell.getId()*(extract == null ? 1 : -1)%>'; 495 list[1].text = ' [<%=rowFormatter.format(currentBioWell.getRow())%>,<%=columnFormatter.format(currentBioWell.getColumn())%>]';500 list[1].text = '<%=rowFormatter.format(currentBioWell.getRow())%><%=columnFormatter.format(currentBioWell.getColumn())%>'; 496 501 list.selectedIndex = 1; 497 502 <% -
trunk/www/biomaterials/samples/edit_sample.jsp
r5708 r5709 411 411 } 412 412 url += '&resetTemporary=1&tmpfilter:INT:bioPlateType.lockMode=<><%=BioWell.LockMode.LOCKED_AFTER_CREATE.getValue()%>'; 413 // Restrict to plates that can holds samples 414 url += '&tmpfilter:INT:bioPlateType.bioMaterialType=|<%=itemType.getValue()%>'; 415 var subtypeId = ItemSubtype.getSubtypeId('sample'); 416 // Restrict to plates with the given subtype 417 url += '&tmpfilter:INT:bioPlateType.itemSubtype='+(subtypeId ? '|' + subtypeId : '='); 413 418 url += '&tmpfilter:BOOLEAN:destroyed=false'; 414 419 Main.openPopup(url, 'SelectBioplate', 1000, 700); … … 447 452 Forms.addListOption(list, 1, new Option()); 448 453 list[1].value = '<%=currentBioWell.getId()*(sample == null ? 1 : -1)%>'; 449 list[1].text = ' [<%=rowFormatter.format(currentBioWell.getRow())%>,<%=columnFormatter.format(currentBioWell.getColumn())%>]';454 list[1].text = '<%=rowFormatter.format(currentBioWell.getRow())%><%=columnFormatter.format(currentBioWell.getColumn())%>'; 450 455 list.selectedIndex = 1; 451 456 <%
Note: See TracChangeset
for help on using the changeset viewer.