Changeset 5631
- Timestamp:
- May 16, 2011, 2:56:23 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r5612 r5631 552 552 verbose="${xdoclet.verbose}"> 553 553 <fileset dir="${core.src}"> 554 <include name=" **/*.java"/>554 <include name="net/sf/basedb/core/data/**/*.java"/> 555 555 </fileset> 556 556 <hibernate version="2.0"/> -
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/edit/EditUtil.java
r5630 r5631 72 72 Item.QUOTATYPE, Item.MIMETYPE, 73 73 Item.ANNOTATIONTYPECATEGORY, Item.ANNOTATIONTYPE, 74 Item.QUANTITY, Item.UNIT, Item.EXTRAVALUETYPE, Item.REPORTERTYPE 74 Item.QUANTITY, Item.UNIT, Item.EXTRAVALUETYPE, Item.REPORTERTYPE, Item.ITEMSUBTYPE 75 75 }; 76 76 -
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/ToolbarUtil.java
r5630 r5631 78 78 Item.ANNOTATIONTYPE, Item.ANNOTATIONTYPECATEGORY, Item.QUANTITY, Item.UNIT, 79 79 Item.SESSION, Item.JOB, Item.MESSAGE, Item.PROJECT, Item.FILE, Item.FILESERVER, 80 Item.CHANGEHISTORY, Item.PERMISSIONTEMPLATE 80 Item.CHANGEHISTORY, Item.PERMISSIONTEMPLATE, Item.ITEMSUBTYPE 81 81 }; 82 82 -
trunk/src/clients/web/net/sf/basedb/clients/web/resources/menu.properties
r5630 r5631 228 228 extravaluetypes.tooltip.1 Administrate extra value types 229 229 extravaluetypes.tooltip.0 You do not have permission to administrate extra value types 230 itemsubtypes.tooltip.1 Administrate item subtypes231 itemsubtypes.tooltip.0 You do not have permission to administrate itemsubtypes230 itemsubtypes.tooltip.1 Administrate subtypes for protocols, hardware/software, etc. 231 itemsubtypes.tooltip.0 You do not have permission to administrate subtypes 232 232 233 233 ## Extensions menu ## -
trunk/src/core/net/sf/basedb/core/Extract.java
r5523 r5631 161 161 } 162 162 // ------------------------------------------- 163 164 163 /* 165 164 From the BasicItem class -
trunk/src/core/net/sf/basedb/core/Install.java
r5630 r5631 161 161 throws BaseException 162 162 { 163 final int totalProgressSteps = 2 7;163 final int totalProgressSteps = 24; 164 164 final float progress_factor = 100 / totalProgressSteps; 165 165 int progressStep = 0; … … 421 421 installUnits("/units.xml", update); 422 422 423 // Item subtypes 424 progressStep++; 425 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating item subtypes..."); 426 427 // File subtypes 428 ItemSubtypeData protocolFileType = createItemSubtype(Item.FILE, File.PROTOCOL, "Protocol", "Protocol files"); 429 ItemSubtypeData rawDataType = createItemSubtype(Item.FILE, File.RAW_DATA, "Raw data", "Raw data files"); 430 createItemSubtype(Item.FILE, File.PLATE, "Plate", "Plate files"); 431 createItemSubtype(Item.FILE, File.PLATE_MAPPING, "Plate mapping", "Plate mapping files"); 432 ItemSubtypeData printMapType = createItemSubtype(Item.FILE, File.PRINT_MAP, "Print map", "Print map files"); 433 ItemSubtypeData reporterMapType = createItemSubtype(Item.FILE, File.REPORTER_MAP, "Reporter map", "Reporter map files"); 434 createItemSubtype(Item.FILE, File.REPORTER, "Reporter", "Reporter files"); 435 ItemSubtypeData imageType = createItemSubtype(Item.FILE, File.IMAGE, "Image", "Image files"); 436 createItemSubtype(Item.FILE, File.SPOT_IMAGES, "Spot images", "A zip file containing generated spot images in png format."); 437 ItemSubtypeData spotDataType = createItemSubtype(Item.FILE, File.SPOT_DATA, "Spot data", "Analysed bioassay set data"); 438 ItemSubtypeData extraValueType = createItemSubtype(Item.FILE, File.EXTRAVALUE_DATA, "Extra value data", "Analysed extra values"); 439 423 440 // Protocol subtypes 424 progressStep++; 425 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating protocol subtypes..."); 426 createItemSubtype(Item.PROTOCOL, Protocol.SAMPLING, "Sampling", "Protocols used for creating samples."); 427 createItemSubtype(Item.PROTOCOL, Protocol.EXTRACTION, "Extraction", "Protocols used for creating extracts."); 428 createItemSubtype(Item.PROTOCOL, Protocol.LABELING, "Labeling", "Protocols used for creating labeled extracts."); 429 createItemSubtype(Item.PROTOCOL, Protocol.POOLING, "Pooling", "Protocols used for creating pooled biomaterails."); 430 createItemSubtype(Item.PROTOCOL, Protocol.HYBRIDIZATION, "Hybridization", "Protocols used for creating hybridizations."); 431 createItemSubtype(Item.PROTOCOL, Protocol.PRINTING, "Printing", "Protocols used for printing a bathc of array slides."); 432 createItemSubtype(Item.PROTOCOL, Protocol.SCANNING, "Scanning", "Protocols used for scanning microarray images."); 433 createItemSubtype(Item.PROTOCOL, Protocol.FEATURE_EXTRACTION, "Feature extraction", "Protocols used for extracting features from microarray images."); 441 createItemSubtype(Item.PROTOCOL, Protocol.SAMPLING, "Sampling", "Protocols used for creating samples.", protocolFileType); 442 createItemSubtype(Item.PROTOCOL, Protocol.EXTRACTION, "Extraction", "Protocols used for creating extracts.", protocolFileType); 443 createItemSubtype(Item.PROTOCOL, Protocol.LABELING, "Labeling", "Protocols used for creating labeled extracts.", protocolFileType); 444 createItemSubtype(Item.PROTOCOL, Protocol.POOLING, "Pooling", "Protocols used for creating pooled biomaterails.", protocolFileType); 445 createItemSubtype(Item.PROTOCOL, Protocol.HYBRIDIZATION, "Hybridization", "Protocols used for creating hybridizations.", protocolFileType); 446 createItemSubtype(Item.PROTOCOL, Protocol.PRINTING, "Printing", "Protocols used for printing a batch of array slides.", protocolFileType); 447 createItemSubtype(Item.PROTOCOL, Protocol.SCANNING, "Scanning", "Protocols used for scanning microarray images.", protocolFileType); 448 createItemSubtype(Item.PROTOCOL, Protocol.FEATURE_EXTRACTION, "Feature extraction", "Protocols used for extracting features from microarray images.", protocolFileType); 434 449 435 450 // Hardware subtypes 436 progressStep++;437 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating hardware subtypes...");438 451 ItemSubtypeData scanner = createItemSubtype(Item.HARDWARE, Hardware.SCANNER, "Scanner", "Scans the microarray images."); 439 452 ItemSubtypeData robot = createItemSubtype(Item.HARDWARE, Hardware.PRINT_ROBOT, "Print robot", "Spot the probe on the array."); … … 442 455 ItemSubtypeData otherHardware = createItemSubtype(Item.HARDWARE, Hardware.OTHER, "Other", "Other kinds of hardware that is used for some process."); 443 456 457 // Software subtypes 458 ItemSubtypeData feature = createItemSubtype(Item.SOFTWARE, Software.FEATURE_EXTRACTION, "Feature extraction", "Extracts features from microarray images."); 459 444 460 // Hardware 445 461 progressStep++; … … 455 471 createHardware("OmniGrid", "100", "", robot, rootUser, keyEveryoneUse); 456 472 createHardware("Qarray", "Max", "", robot, rootUser, keyEveryoneUse); 457 458 // SoftwareTypes459 progressStep++;460 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating software subtypes...");461 ItemSubtypeData feature = createItemSubtype(Item.SOFTWARE, Software.FEATURE_EXTRACTION, "Feature extraction", "Extracts features from microarray images.");462 473 463 474 // Software … … 490 501 createDirectory(rootUser, templateDirectory, null, "raw data", "Place your raw data files here", null, true); 491 502 createDirectory(rootUser, templateDirectory, null, "projects", "Create a subdirectory for project-related files in this directory.", null, false); 492 493 // FileTypes494 progressStep++;495 if (progress != null) progress.display((int)(progressStep*progress_factor), "--Creating file types...");496 createItemSubtype(Item.FILE, File.PROTOCOL, "Protocol", "Protocol files");497 ItemSubtypeData rawDataType = createItemSubtype(Item.FILE, File.RAW_DATA, "Raw data", "Raw data files");498 createItemSubtype(Item.FILE, File.PLATE, "Plate", "Plate files");499 createItemSubtype(Item.FILE, File.PLATE_MAPPING, "Plate mapping", "Plate mapping files");500 ItemSubtypeData printMapType = createItemSubtype(Item.FILE, File.PRINT_MAP, "Print map", "Print map files");501 ItemSubtypeData reporterMapType = createItemSubtype(Item.FILE, File.REPORTER_MAP, "Reporter map", "Reporter map files");502 createItemSubtype(Item.FILE, File.REPORTER, "Reporter", "Reporter files");503 ItemSubtypeData imageType = createItemSubtype(Item.FILE, File.IMAGE, "Image", "Image files");504 createItemSubtype(Item.FILE, File.SPOT_IMAGES, "Spot images", "A zip file containing generated spot images in png format.");505 ItemSubtypeData spotDataType = createItemSubtype(Item.FILE, File.SPOT_DATA, "Spot data", "Analysed bioassay set data");506 ItemSubtypeData extraValueType = createItemSubtype(Item.FILE, File.EXTRAVALUE_DATA, "Extra value data", "Analysed extra values");507 503 508 504 // MimeTypes … … 1542 1538 Create an {@link ItemSubtype}. 1543 1539 */ 1544 private static ItemSubtypeData createItemSubtype(Item itemType, String systemId, String name, String description) 1540 private static ItemSubtypeData createItemSubtype(Item itemType, String systemId, String name, 1541 String description, ItemSubtypeData... related) 1545 1542 { 1546 1543 int id = SystemItems.getId(systemId); … … 1574 1571 subtype.setName(name); 1575 1572 subtype.setDescription(description); 1573 1574 if (related != null) 1575 { 1576 Map<Integer, ItemSubtypeData> allRelated = subtype.getReleatedSubtypes(); 1577 for (ItemSubtypeData rel : related) 1578 { 1579 allRelated.put(rel.getItemType(), rel); 1580 } 1581 } 1582 1576 1583 HibernateUtil.saveData(session, subtype); 1577 1584 HibernateUtil.commit(tx); -
trunk/src/core/net/sf/basedb/core/ItemSubtype.java
r5630 r5631 22 22 package net.sf.basedb.core; 23 23 24 import java.lang.reflect.Method; 25 import java.util.Arrays; 26 import java.util.Collections; 24 27 import java.util.Date; 28 import java.util.HashMap; 29 import java.util.List; 30 import java.util.Map; 25 31 import java.util.Set; 26 32 … … 30 36 import net.sf.basedb.core.query.Hql; 31 37 import net.sf.basedb.core.query.Restrictions; 38 import net.sf.basedb.util.ClassUtil; 32 39 33 40 /** … … 53 60 public static final Item TYPE = Item.ITEMSUBTYPE; 54 61 62 63 private static Map<Item, List<Item>> relatedItems = new HashMap<Item, List<Item>>(); 64 /** 65 Get a list with (subtypable) items that are related to the given 66 item (which should also be subtypable). Typically, if the main item 67 has a many-to-one relatation to another subtypable item, this item type 68 will appear in the list. For example a {@link Protocol} has a link to 69 {@link File} via {@link Protocol#getFile()}. Given the subtype of the protocol 70 we can find the desired subtype of the file and check agains the actual subtype: 71 72 <pre class="code"> 73 Protocol p = ... 74 ItemSubtype protocolSubtype = p.getItemSubtype(); 75 ItemSubtype desiredFileSubtype = protocolSubtype.getRelatedSubtype(Item.FILE); 76 File f = p.getFile(); 77 ItemSubtype actualFileSubtype = f.getItemSubtype(); 78 </pre> 79 80 @param mainItem 81 @return A list with the related items 82 @see #getRelatedSubtype(Item) 83 */ 84 public static List<Item> getRelatedItems(Item mainItem) 85 { 86 if (!Subtypable.class.isAssignableFrom(mainItem.getItemClass())) return Collections.emptyList(); 87 88 List<Item> related = relatedItems.get(mainItem); 89 if (related == null) 90 { 91 synchronized (relatedItems) 92 { 93 94 Method getItemSubtype = ClassUtil.findMethod(mainItem.getItemClass(), "getItemSubtype"); 95 SubtypableRelatedItems items = getItemSubtype == null ? null : getItemSubtype.getAnnotation(SubtypableRelatedItems.class); 96 if (items == null) 97 { 98 related = Collections.emptyList(); 99 } 100 else 101 { 102 related = Collections.unmodifiableList(Arrays.asList(items.value())); 103 } 104 relatedItems.put(mainItem, related); 105 } 106 } 107 108 return related; 109 110 } 55 111 56 112 /** … … 314 370 315 371 /** 372 Get a related subtype of another item type. For a given main type of 373 items use {@link #getRelatedItems(Item)} to find out which other 374 subtypable items that can be related to this subtype. 375 376 @param itemType The other item type (which should also be subtypable) 377 @return A subtype or null if no subtype has been configured. 378 */ 379 public ItemSubtype getRelatedSubtype(Item itemType) 380 { 381 return getDbControl().getItem(ItemSubtype.class, getData().getReleatedSubtypes().get(itemType.getValue())); 382 } 383 384 /** 385 Set a subtype that is related to this subtype. Only one related subtype 386 per item type is allowed. 387 @param subtype The subtype (null is not allowed) 388 @see #getRelatedSubtype(Item) 389 */ 390 public void setRelatedSubtype(ItemSubtype subtype) 391 { 392 checkPermission(Permission.WRITE); 393 if (subtype == null) throw new InvalidUseOfNullException("subtype"); 394 getData().getReleatedSubtypes().put(subtype.getMainItemType().getValue(), subtype.getData()); 395 } 396 397 /** 398 Remove the related subtype for the given item type. 399 @param itemType The item type of the related subtype to 400 be removed 401 */ 402 public void removeRelatedSubtype(Item itemType) 403 { 404 checkPermission(Permission.WRITE); 405 getData().getReleatedSubtypes().remove(itemType.getValue()); 406 } 407 408 /** 316 409 Helper method for implementing the {@link Subtypable#setItemSubtype(ItemSubtype)} 317 410 method. -
trunk/src/core/net/sf/basedb/core/MeasuredBioMaterial.java
r5630 r5631 174 174 /* 175 175 From the Subtypable interface 176 ----------------------------- 176 177 */ 177 178 @Override 179 @SubtypableRelatedItems({Item.PROTOCOL, Item.HARDWARE}) 178 180 public ItemSubtype getItemSubtype() 179 181 { -
trunk/src/core/net/sf/basedb/core/Protocol.java
r5630 r5631 234 234 */ 235 235 @Override 236 @SubtypableRelatedItems({Item.FILE}) 236 237 public ItemSubtype getItemSubtype() 237 238 { -
trunk/src/core/net/sf/basedb/core/Subtypable.java
r5630 r5631 37 37 Get the subtype of the item. 38 38 @return A subtype of null if not set 39 @see SubtypableRelatedItems 39 40 */ 40 41 public ItemSubtype getItemSubtype(); -
trunk/src/core/net/sf/basedb/core/data/ItemSubtypeData.java
r5630 r5631 23 23 24 24 import java.util.Date; 25 import java.util.HashMap; 26 import java.util.Map; 25 27 26 28 /** … … 132 134 } 133 135 136 private Map<Integer, ItemSubtypeData> relatedSubtypes; 137 /** 138 @hibernate.map table="`RelatedSubtypes`" lazy="true" 139 @hibernate.collection-key column="`itemsubtype_id`" 140 @hibernate.collection-index column="`item_type`" type="int" not-null="true" 141 @hibernate.collection-many-to-many column="`related_subtype_id`" class="net.sf.basedb.core.data.ItemSubtypeData" 142 */ 143 public Map<Integer, ItemSubtypeData> getReleatedSubtypes() 144 { 145 if (relatedSubtypes == null) 146 { 147 relatedSubtypes = new HashMap<Integer, ItemSubtypeData>(); 148 } 149 return relatedSubtypes; 150 } 151 void setReleatedSubtypes(Map<Integer, ItemSubtypeData> relatedSubtypes) 152 { 153 this.relatedSubtypes = relatedSubtypes; 154 } 155 156 134 157 } -
trunk/www/admin/itemsubtypes/edit_subtype.jsp
r5630 r5631 71 71 } 72 72 73 Set<Item> subtypableItems = Metadata.getSubtypableItems(); 73 74 final String clazz = "class=\"text\""; 74 75 final String requiredClazz = "class=\"text required\""; … … 116 117 } 117 118 %> 119 mainItemOnChange(); 120 } 121 122 var related = new Array(); 123 var nameToValue = new Array(); 124 <% 125 for (Item item : subtypableItems) 126 { 127 String tmp = ""; 128 for (Item related : ItemSubtype.getRelatedItems(item)) 129 { 130 tmp += related.name() + ":"; 131 } 132 %> 133 related['<%=item.name()%>'] = '<%=tmp%>'; 134 nameToValue['<%=item.name()%>'] = <%=item.getValue()%>; 135 <% 136 } 137 %> 138 139 function mainItemOnChange() 140 { 141 var frm = document.forms['subtype']; 142 <% 143 if (subtype != null) 144 { 145 %> 146 var mainType = '<%=subtype.getMainItemType().name()%>'; 147 <% 148 } 149 else 150 { 151 %> 152 var mainType = frm.itemType[frm.itemType.selectedIndex].value; 153 <% 154 } 155 for (Item item : subtypableItems) 156 { 157 %> 158 Main.showHide('section.<%=item.name()%>', related[mainType].indexOf('<%=item.name()%>') >= 0) 159 <% 160 } 161 %> 162 } 163 164 var lastList; 165 function relatedItemOnSelect(itemType) 166 { 167 var frm = document.forms['subtype']; 168 lastList = frm['related.'+itemType]; 169 var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&title=Select+related+subtype&callback=setRelatedCallback'; 170 url += '&resetTemporary=1&tmpfilter:INT:itemType=' + nameToValue[itemType]; 171 if (lastList.length > 1) 172 { 173 var id = Math.abs(parseInt(lastList[1].value)); 174 url += '&item_id='+id; 175 } 176 Main.openPopup(url, 'SelectReleatedSubtype', 1000, 700); 177 } 178 function setRelatedCallback(id, name) 179 { 180 var frm = document.forms['subtype']; 181 var list = lastList; 182 if (list.length < 2 || list[1].value == '0') // > 183 { 184 Forms.addListOption(list, 1, new Option()); 185 } 186 list[1].value = id; 187 list[1].text = name; 188 list.selectedIndex = 1; 118 189 } 119 190 </script> … … 143 214 { 144 215 %> 145 <select name="itemType" class="required unchangeable" >216 <select name="itemType" class="required unchangeable" onchange="mainItemOnChange()"> 146 217 <% 147 Set<Item> items = Metadata.getSubtypableItems();148 218 int itemCode = Values.getInt(cc.getPropertyValue("itemType"), -1); 149 for (Item item : items)219 for (Item item : subtypableItems) 150 220 { 151 221 String selected = itemCode == item.getValue() ? "selected" : ""; … … 176 246 </td> 177 247 </tr> 248 <tr> 249 <td class="prompt">Related subtypes</td> 250 <td></td> 251 </tr> 252 <% 253 for (Item item : subtypableItems) 254 { 255 %> 256 <tr id="section.<%=item.name()%>" style="display: none;"> 257 <td class="subprompt"><%=item%></td> 258 <td> 259 <base:select 260 id="<%="related."+item.name()%>" 261 current="<%=subtype == null ? null : subtype.getRelatedSubtype(item) %>" 262 onselect="<%="relatedItemOnSelect('" + item.name() + "')"%>" 263 newitem="<%=subtype == null%>" 264 /> 265 </td> 266 </tr> 267 <% 268 } 269 %> 178 270 </table> 179 271 <div align=right> <i><base:icon image="required.gif" /> = required information</i></div> -
trunk/www/admin/itemsubtypes/index.jsp
r5630 r5631 155 155 subtype.setName(Values.getStringOrNull(request.getParameter("name"))); 156 156 subtype.setDescription(Values.getStringOrNull(request.getParameter("description"))); 157 157 158 for (Item related : ItemSubtype.getRelatedItems(subtype.getMainItemType())) 159 { 160 int relatedId = Values.getInt(request.getParameter("related." + related.name()), -1); 161 if (relatedId >= 0) // < 0 = denied or unchanged 162 { 163 if (relatedId == 0) 164 { 165 subtype.removeRelatedSubtype(related); 166 } 167 else 168 { 169 subtype.setRelatedSubtype(ItemSubtype.getById(dc, relatedId)); 170 } 171 } 172 } 173 174 cc.removeAllTemporaryFilters(); 175 158 176 // OnSave extensions 159 177 invoker.render(OnSaveRenderer.ON_SAVE); -
trunk/www/admin/itemsubtypes/view_subtype.jsp
r5630 r5631 221 221 <td><%=HTML.niceFormat(subtype.getDescription())%></td> 222 222 </tr> 223 <tr> 224 <td class="prompt">Related subtypes</td> 225 <td></td> 226 </tr> 227 <% 228 for (Item relatedItem : ItemSubtype.getRelatedItems(subtype.getMainItemType())) 229 { 230 ItemSubtype related = null; 231 boolean deniedRelated = false; 232 try 233 { 234 related = subtype.getRelatedSubtype(relatedItem); 235 } 236 catch (PermissionDeniedException ex) 237 { 238 deniedRelated = true; 239 } 240 %> 241 <tr> 242 <td class="subprompt"><%=relatedItem%></td> 243 <td><%=Base.getLinkedName(ID, related, deniedRelated, true)%></td> 244 </tr> 245 <% 246 } 247 %> 223 248 </table> 224 249 -
trunk/www/admin/protocols/edit_protocol.jsp
r5630 r5631 128 128 129 129 <base:page type="popup" title="<%=title%>"> 130 <base:head scripts="tabcontrol.js,annotations.js,linkitems.js " styles="tabcontrol.css">130 <base:head scripts="tabcontrol.js,annotations.js,linkitems.js,ajax.js,json2.js,subtypes.js" styles="tabcontrol.css"> 131 131 <ext:scripts context="<%=jspContext%>" /> 132 132 <ext:stylesheets context="<%=jspContext%>" /> … … 182 182 { 183 183 var frm = document.forms['protocol']; 184 var protocolType = Math.abs(frm.protocoltype_id[frm.protocoltype_id.selectedIndex].value); 185 var relatedFileSubtype = ItemSubtype.getRelatedSubtype(protocolType, 'FILE', <%=SystemItems.getId(File.PROTOCOL)%>); 184 186 var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&title=Select+protocol&callback=setFileCallback'; 185 url += '&resetTemporary=1&tmpfilter:INT:itemSubtype= <%=SystemItems.getId(File.PROTOCOL)%>';187 url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=' + relatedFileSubtype.id; 186 188 if (frm.file_id.length > 1) 187 189 { -
trunk/www/include/menu.jsp
r5630 r5631 824 824 enabled="<%=hasItemSubtypes%>" 825 825 /> 826 <m:menuseparator /> 826 827 <m:menuitem 827 828 title="<%=common.getString("item.annotationtype+")%>"
Note: See TracChangeset
for help on using the changeset viewer.