Changeset 5698
- Timestamp:
- Aug 15, 2011, 1:57:00 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r5689 r5698 1058 1058 /** 1059 1059 Get a query that returns all data file types for a specific 1060 platform/variant that can be used on a given item type. If an item1060 platform/variant/subtype that can be used on a given item type. If an item 1061 1061 is specified the query will also return data file types that 1062 1062 already are present in the item's file set even if those … … 1066 1066 @param platform The platform to get file types for, or null 1067 1067 @param variant The platform variant to get file types for, or null 1068 @param subtype The item subtype to get the file types for, or null 1068 1069 @return An <code>ItemQuery</code> object 1069 @since 2.51070 */ 1071 public static ItemQuery<DataFileType> getDataFileTypes(Item itemType, FileStoreEnabled item, Platform platform, PlatformVariant variant )1070 @since 3.0 1071 */ 1072 public static ItemQuery<DataFileType> getDataFileTypes(Item itemType, FileStoreEnabled item, Platform platform, PlatformVariant variant, ItemSubtype subtype) 1072 1073 { 1073 1074 ItemQuery<DataFileType> q = DataFileType.getQuery(); … … 1103 1104 } 1104 1105 1106 // Restrict on item subtype 1107 Restriction onSubtype = null; 1108 if (subtype != null) 1109 { 1110 onSubtype = Restrictions.eq(Hql.alias("its"), Hql.entity(subtype)); 1111 q.join(Hql.leftJoin("itemSubtypes", "its")); 1112 } 1113 1105 1114 // Also include file types already present for item 1106 1115 Restriction onItem = null; … … 1112 1121 } 1113 1122 1114 // full = onItem || (onItemType && onPlatform )1123 // full = onItem || (onItemType && onPlatform && onSubtype) 1115 1124 Restriction full = onItemType; 1116 1125 if (onPlatform != null) full = Restrictions.and(full, onPlatform); 1126 if (onSubtype != null) full = Restrictions.and(full, onSubtype); 1117 1127 if (onItem != null) full = Restrictions.or(full, onItem); 1118 1128 -
trunk/src/core/net/sf/basedb/core/DataFileType.java
r5697 r5698 560 560 561 561 /** 562 Get a query returning the item subtypes that files of this type 563 can be used on. The query should only be used if the main item 564 type {@link #getItemType()} is a {@link Subtypable} item. 565 @return A query 566 @since 3.0 567 */ 568 public ItemQuery<ItemSubtype> getItemSubtypes() 569 { 570 ItemQuery<ItemSubtype> query = ItemSubtype.getQuery(null); 571 query.joinPermanent(Hql.innerJoin("dataFileTypes", Item.DATAFILETYPE.getAlias())); 572 query.restrictPermanent( 573 Restrictions.eq( 574 Hql.alias(Item.DATAFILETYPE.getAlias()), 575 Hql.entity(this) 576 )); 577 return query; 578 } 579 580 /** 562 581 Check if there is at least one extension that claims to support 563 582 validation of files of this type. The extensions are not actually -
trunk/src/core/net/sf/basedb/core/Install.java
r5697 r5698 489 489 490 490 // Derived bioassay set subtypes 491 createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SCAN,491 ItemSubtypeData scan = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SCAN, 492 492 "Scan", "A hybridization that has been scanned to produce one or more images.", 493 493 hybridization, scanner, scanningProtocol, labeledExtract); 494 createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SEQUENCED,494 ItemSubtypeData sequenced = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SEQUENCED, 495 495 "Sequenced", "A flow cell that has been sequenced.", 496 496 flowCell, sequencer, sequencingProtocol, library); 497 createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.ASSEMBLY,497 ItemSubtypeData assembly = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.ASSEMBLY, 498 498 "Assembly", "A data set of sequences that has been aligned against a reference database", 499 499 alignmentSoftware, library); … … 849 849 DataFileType.SAM, "Sequence Alignment/Map", 850 850 "SAM format is a generic format for storing large nucleotide sequence alignments.", 851 Item.DERIVEDBIOASSAY, "sam", alignedType 851 Item.DERIVEDBIOASSAY, "sam", alignedType, assembly 852 852 ); 853 853 DataFileTypeData bamFile = createDataFileType( 854 854 DataFileType.BAM, "Compressed Sequence Alignment/Map", 855 855 "BAM format is a BGZF-compressed SAM file.", 856 Item.DERIVEDBIOASSAY, "bam", alignedType 856 Item.DERIVEDBIOASSAY, "bam", alignedType, assembly 857 857 ); 858 858 DataFileTypeData scanImageFile = createDataFileType( 859 859 DataFileType.MICROARRAY_IMAGE, "Microarray image", 860 860 "Scanned image from a microarray slide.", 861 Item.DERIVEDBIOASSAY, "tif", imageType 861 Item.DERIVEDBIOASSAY, "tif", imageType, scan 862 862 ); 863 863 … … 2593 2593 private static DataFileTypeData createDataFileType( 2594 2594 String externalId, String name, String description, 2595 Item itemType, String extension, ItemSubtypeData genericType) 2595 Item itemType, String extension, ItemSubtypeData genericType, 2596 ItemSubtypeData... itemSubtypes) 2596 2597 throws BaseException 2597 2598 { … … 2613 2614 { 2614 2615 log.info("createDataFileType: EXISTS [externalId="+externalId+"]"); 2616 if (itemSubtypes != null) 2617 { 2618 for (ItemSubtypeData itemSubtype : itemSubtypes) 2619 { 2620 fileType.getItemSubtypes().add(itemSubtype); 2621 } 2622 } 2615 2623 HibernateUtil.commit(tx); 2616 2624 } … … 2625 2633 fileType.setGenericType(genericType); 2626 2634 2635 if (itemSubtypes != null) 2636 { 2637 for (ItemSubtypeData itemSubtype : itemSubtypes) 2638 { 2639 fileType.getItemSubtypes().add(itemSubtype); 2640 } 2641 } 2642 2627 2643 HibernateUtil.saveData(session, fileType); 2628 2644 HibernateUtil.commit(tx); -
trunk/src/core/net/sf/basedb/core/ItemSubtype.java
r5686 r5698 525 525 526 526 /** 527 Get a query returning the data file types that have been 528 associated with this subtype. The association is only used 529 for main item types that implemented the 530 {@link FileStoreEnabled} interface. 531 @return A query 532 */ 533 public ItemQuery<DataFileType> getDataFileTypes() 534 { 535 ItemQuery<DataFileType> query = DataFileType.getQuery(); 536 query.joinPermanent(Hql.innerJoin("itemSubtypes", Item.ITEMSUBTYPE.getAlias())); 537 query.restrictPermanent( 538 Restrictions.eq( 539 Hql.alias(Item.ITEMSUBTYPE.getAlias()), 540 Hql.entity(this) 541 )); 542 return query; 543 } 544 545 /** 546 Checks if the given data file type is associated with this subtype or not. 547 @param fileType The file type to check 548 @return TRUE if the file type is associated, FALSE if not 549 */ 550 public boolean isAssociatedDataFileType(DataFileType fileType) 551 { 552 return getData().getDataFileTypes().contains(fileType.getData()); 553 } 554 555 /** 556 Add a data file type as an associated file type. The data file type 557 must use the same main item type as this subtype. 558 @param fileType The file type to associate (required) 559 */ 560 public void addAssociatedDataFileType(DataFileType fileType) 561 { 562 checkPermission(Permission.WRITE); 563 if (fileType == null) throw new InvalidUseOfNullException("fileType"); 564 if (fileType.getItemType() != getMainItemType()) 565 { 566 throw new InvalidDataException("The file type is not used for " + getMainItemType() + ": " + fileType.getName()); 567 } 568 getData().getDataFileTypes().add(fileType.getData()); 569 } 570 571 /** 572 Remove the association between this subtype and the given data file type. 573 If the file type is not associated nothing happens. 574 @param fileType The file type to remove 575 */ 576 public void removeAssociatedDataFileType(DataFileType fileType) 577 { 578 checkPermission(Permission.WRITE); 579 if (fileType != null) 580 { 581 getData().getDataFileTypes().remove(fileType.getData()); 582 } 583 } 584 585 /** 527 586 Helper method for implementing the {@link Subtypable#setItemSubtype(ItemSubtype)} 528 587 method. -
trunk/src/core/net/sf/basedb/core/data/DataFileTypeData.java
r5630 r5698 22 22 package net.sf.basedb.core.data; 23 23 24 import java.util.HashSet; 24 25 import java.util.Set; 25 26 … … 138 139 } 139 140 141 private Set<ItemSubtypeData> itemSubtypes; 142 /** 143 The subtypes that this file type can be used with. 144 145 @hibernate.set table="`DataFileItemSubTypes`" lazy="true" 146 @hibernate.collection-key column="`datafiletype_id`" 147 @hibernate.collection-many-to-many column="`itemsubtype_id`" class="net.sf.basedb.core.data.ItemSubtypeData" 148 */ 149 public Set<ItemSubtypeData> getItemSubtypes() 150 { 151 if (itemSubtypes == null) itemSubtypes = new HashSet<ItemSubtypeData>(); 152 return itemSubtypes; 153 } 154 void setItemSubtypes(Set<ItemSubtypeData> itemSubtypes) 155 { 156 this.itemSubtypes = itemSubtypes; 157 } 158 140 159 private ItemSubtypeData genericType; 141 160 /** -
trunk/src/core/net/sf/basedb/core/data/ItemSubtypeData.java
r5645 r5698 24 24 import java.util.Date; 25 25 import java.util.HashMap; 26 import java.util.HashSet; 26 27 import java.util.Map; 27 28 import java.util.Set; … … 171 172 } 172 173 174 private Set<DataFileTypeData> dataFileTypes; 175 /** 176 This is the inverse end. See {@link DataFileTypeData#getItemSubtypes()}. 177 178 @hibernate.set table="`DataFileItemSubTypes`" lazy="true" 179 @hibernate.collection-key column="`itemsubtype_id`" 180 @hibernate.collection-many-to-many column="`datafiletype_id`" class="net.sf.basedb.core.data.DataFileTypeData" 181 */ 182 public Set<DataFileTypeData> getDataFileTypes() 183 { 184 if (dataFileTypes == null) dataFileTypes = new HashSet<DataFileTypeData>(); 185 return dataFileTypes; 186 } 187 void setDataFileTypes(Set<DataFileTypeData> dataFileTypes) 188 { 189 this.dataFileTypes = dataFileTypes; 190 } 191 173 192 174 193 } -
trunk/www/admin/itemsubtypes/edit_subtype.jsp
r5645 r5698 32 32 import="net.sf.basedb.core.PermissionDeniedException" 33 33 import="net.sf.basedb.core.Metadata" 34 import="net.sf.basedb.core.FileStoreEnabled" 35 import="net.sf.basedb.core.DataFileType" 36 import="net.sf.basedb.core.ItemQuery" 37 import="net.sf.basedb.core.Include" 38 import="net.sf.basedb.core.query.Hql" 39 import="net.sf.basedb.core.query.Orders" 34 40 import="net.sf.basedb.clients.web.Base" 35 41 import="net.sf.basedb.clients.web.util.HTML" … … 57 63 String title = null; 58 64 ItemSubtype subtype = null; 59 65 ItemQuery<DataFileType> fileTypesQuery = null; 66 60 67 if (itemId == 0) 61 68 { … … 69 76 title = "Edit item subtype -- " + HTML.encodeTags(subtype.getName()); 70 77 subtype.checkPermission(Permission.WRITE); 78 fileTypesQuery = subtype.getDataFileTypes(); 71 79 } 72 80 … … 78 86 %> 79 87 <base:page type="popup" title="<%=title%>"> 80 <base:head scripts="tabcontrol.js " styles="tabcontrol.css">88 <base:head scripts="tabcontrol.js,linkitems.js" styles="tabcontrol.css"> 81 89 <ext:scripts context="<%=jspContext%>" /> 82 90 <ext:stylesheets context="<%=jspContext%>" /> … … 101 109 if (TabControl.validateActiveTab('settings')) 102 110 { 111 frm.addedFileTypes.value = Link.getActionIds(1, 'F').join(','); 112 frm.removedFileTypes.value = Link.getActionIds(-1, 'F').join(','); 103 113 frm.submit(); 104 114 } … … 117 127 } 118 128 %> 129 initFileTypes(); 119 130 mainItemOnChange(); 120 131 } 121 132 122 var related = new Array(); 123 var nameToValue = new Array(); 133 function initFileTypes() 134 { 135 var frm = document.forms['subtype']; 136 var fileTypes = frm.fileTypes; 137 <% 138 if (fileTypesQuery != null) 139 { 140 fileTypesQuery.include(Include.ALL); 141 fileTypesQuery.order(Orders.asc(Hql.property("name"))); 142 for (DataFileType fileType : fileTypesQuery.list(dc)) 143 { 144 %> 145 Link.addNewItem(fileTypes, new Item('F', <%=fileType.getId()%>, '<%=HTML.javaScriptEncode(fileType.getName())%>')); 146 <% 147 } 148 } 149 %> 150 } 151 152 var itemInfo = new Array(); 124 153 <% 125 154 for (Item item : subtypableItems) … … 131 160 } 132 161 %> 133 related['<%=item.name()%>'] = '<%=tmp%>'; 134 nameToValue['<%=item.name()%>'] = <%=item.getValue()%>; 162 var info = new Object(); 163 info.value = <%=item.getValue()%>; 164 info.related = '<%=tmp%>'; 165 info.fileStoreEnabled = <%=FileStoreEnabled.class.isAssignableFrom(item.getItemClass()) ? "true" : "false"%>; 166 itemInfo['<%=item.name()%>'] = info; 135 167 <% 136 168 } 137 169 %> 138 170 139 function mainItemOnChange()171 function getCurrentMainItemType() 140 172 { 141 173 var frm = document.forms['subtype']; … … 153 185 <% 154 186 } 187 %> 188 return mainType; 189 } 190 191 function mainItemOnChange() 192 { 193 var mainType = getCurrentMainItemType(); 194 <% 155 195 for (Item item : subtypableItems) 156 196 { 157 197 %> 158 Main.showHide('section.<%=item.name()%>', related[mainType].indexOf('<%=item.name()%>') >= 0)198 Main.showHide('section.<%=item.name()%>', itemInfo[mainType].related.indexOf('<%=item.name()%>') >= 0) 159 199 <% 160 200 } 161 201 %> 162 Main.showHide('section.none', related[mainType] == '') 202 Main.showHide('section.none', itemInfo[mainType].related == '') 203 if (itemInfo[mainType].fileStoreEnabled) 204 { 205 Main.show('filetypes.enabled'); 206 Main.hide('filetypes.disabled'); 207 } 208 else 209 { 210 Main.show('filetypes.disabled'); 211 Main.hide('filetypes.enabled'); 212 document.getElementById('filetypes.disabled').innerHTML = 'The selected main item type (' + mainType + ') has not support for attaching data files.'; 213 } 163 214 } 164 215 … … 169 220 lastList = frm['related.'+itemType]; 170 221 var url = 'index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&title=Select+related+subtype&callback=setRelatedCallback'; 171 url += '&resetTemporary=1&tmpfilter:INT:itemType=' + nameToValue[itemType];222 url += '&resetTemporary=1&tmpfilter:INT:itemType=' + itemInfo[itemType].value; 172 223 if (lastList.length > 1) 173 224 { … … 189 240 list.selectedIndex = 1; 190 241 } 242 function addFileTypesOnClick() 243 { 244 var frm = document.forms['subtype']; 245 var itemType = getCurrentMainItemType(); 246 var ids = Link.getListIds(frm.fileTypes, 'F'); 247 var excludes = ids.join(','); 248 var url = '../../admin/datafiletypes/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addFileTypeCallback'; 249 url += '&resetTemporary=1&tmpfilter:INT:itemType=' + itemInfo[itemType].value; 250 url += "&exclude="+excludes; 251 Main.openPopup(url, 'AddFileTypes', 1000, 700); 252 } 253 function addFileTypeCallback(fileTypeId, name) 254 { 255 var item = Link.getItem('F', fileTypeId); 256 if (!item) item = new Item('F', fileTypeId, name); 257 Link.addItem(document.forms['subtype'].fileTypes, item); 258 } 259 function removeFileTypesOnClick() 260 { 261 Link.removeSelected(document.forms['subtype'].fileTypes); 262 } 263 191 264 </script> 192 265 </base:head> … … 273 346 <div align=right> <i><base:icon image="required.gif" /> = required information</i></div> 274 347 </t:tab> 348 <t:tab 349 id="filetypes" 350 title="File types"> 351 <div id="filetypes.enabled"> 352 <table class="form" cellspacing=0> 353 <tr valign="top"> 354 <td class="prompt">File types</td> 355 <td> 356 <table border="0" cellspacing="0" cellpadding="0"> 357 <tr valign="top"> 358 <td> 359 <select name="fileTypes" size="10" multiple style="width: 20em;"> 360 </select> 361 <input type="hidden" name="addedFileTypes" value=""> 362 <input type="hidden" name="removedFileTypes" value=""> 363 </td> 364 <td> 365 <table border="0"> 366 <tr><td width="150"><base:button 367 onclick="addFileTypesOnClick()" 368 title="Add file types…" 369 tooltip="Add file types" 370 /></td></tr> 371 <tr><td width="150"><base:button 372 onclick="removeFileTypesOnClick()" 373 title="Remove" 374 tooltip="Remove the selected file types" 375 /></td></tr> 376 </table> 377 </td> 378 </tr> 379 </table> 380 </td> 381 </tr> 382 </table> 383 </div> 384 <div id="filetypes.disabled" style="display: none;"> 385 386 </div> 387 </t:tab> 275 388 </t:tabcontrol> 276 389 -
trunk/www/admin/itemsubtypes/index.jsp
r5631 r5698 29 29 import="net.sf.basedb.core.Include" 30 30 import="net.sf.basedb.core.ItemSubtype" 31 import="net.sf.basedb.core.DataFileType" 31 32 import="net.sf.basedb.core.ItemQuery" 32 33 import="net.sf.basedb.core.Permission" … … 171 172 } 172 173 } 174 175 String[] removeFileTypes = Values.getString(request.getParameter("removedFileTypes")).split(","); 176 for (int i = 0; i < removeFileTypes.length; ++i) 177 { 178 int fileTypeId = Values.getInt(removeFileTypes[i], -1); 179 if (fileTypeId != -1) subtype.removeAssociatedDataFileType(DataFileType.getById(dc, fileTypeId)); 180 } 173 181 182 String[] addFileTypes = Values.getString(request.getParameter("addedFileTypes")).split(","); 183 for (int i = 0; i < addFileTypes.length; ++i) 184 { 185 int fileTypeId = Values.getInt(addFileTypes[i], -1); 186 if (fileTypeId != -1) subtype.addAssociatedDataFileType(DataFileType.getById(dc, fileTypeId)); 187 } 188 174 189 cc.removeAllTemporaryFilters(); 175 190 -
trunk/www/admin/itemsubtypes/list_subtypes.jsp
r5686 r5698 28 28 import="net.sf.basedb.core.Item" 29 29 import="net.sf.basedb.core.ItemSubtype" 30 import="net.sf.basedb.core.DataFileType" 30 31 import="net.sf.basedb.core.ItemQuery" 31 32 import="net.sf.basedb.core.Include" … … 98 99 relatedQuery.include(cc.getInclude()); 99 100 101 final ItemQuery<DataFileType> fileTypesQuery = DataFileType.getQuery(); 102 fileTypesQuery.include(cc.getInclude()); 103 fileTypesQuery.join(Hql.innerJoin("itemSubtypes", "ist")); 104 fileTypesQuery.restrict(Restrictions.eq(Hql.alias("ist"), Expressions.parameter("subtype"))); 105 fileTypesQuery.order(Orders.asc(Hql.property("name"))); 106 100 107 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); 101 108 try … … 272 279 exportable="true" 273 280 /> 281 <tbl:columndef 282 id="dataFileTypes" 283 title="File types" 284 property="&dataFileTypes(name)" 285 datatype="string" 286 filterable="true" 287 exportable="true" 288 /> 274 289 <tbl:columndef 275 290 id="description" … … 457 472 %> 458 473 </tbl:cell> 474 <tbl:cell column="dataFileTypes"> 475 <% 476 fileTypesQuery.setParameter("subtype", itemId, Type.INT); 477 String separator = ""; 478 for (DataFileType dft : fileTypesQuery.list(dc)) 479 { 480 out.write(separator); 481 if (mode.hasPropertyLink()) 482 { 483 out.write(Base.getLinkedName(ID, dft, false, mode.hasEditLink())); 484 } 485 else 486 { 487 out.write(HTML.encodeTags(dft.getName())); 488 } 489 separator = ", "; 490 } 491 %> 492 </tbl:cell> 459 493 <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> 460 494 </tbl:row> -
trunk/www/admin/itemsubtypes/view_subtype.jsp
r5645 r5698 34 34 import="net.sf.basedb.core.Permission" 35 35 import="net.sf.basedb.core.ItemSubtype" 36 import="net.sf.basedb.core.DataFileType" 36 37 import="net.sf.basedb.core.PermissionDeniedException" 37 38 import="net.sf.basedb.core.PluginDefinition" … … 313 314 %> 314 315 316 <% 317 ItemQuery<DataFileType> fileTypeQuery = subtype.getDataFileTypes(); 318 fileTypeQuery.include(Include.ALL); 319 fileTypeQuery.order(Orders.asc(Hql.property("name"))); 320 ItemResultList<DataFileType> fileTypes = fileTypeQuery.list(dc); 321 if (fileTypes.size() == 0) 322 { 323 %> 324 <h4>File types associated with this subtype</h4> 325 There are no file types (or, you don't have permission to view them). 326 <% 327 } 328 else 329 { 330 %> 331 <base:section 332 id="fileTypes" 333 title="<%="File types associated with this subtype (" + fileTypes.size() + ")"%>" 334 context="<%=cc%>" 335 > 336 <tbl:table 337 id="fileTypes" 338 clazz="itemlist" 339 columns="all" 340 > 341 <tbl:columndef 342 id="name" 343 title="Name" 344 /> 345 <tbl:columndef 346 id="extension" 347 title="File extension" 348 /> 349 <tbl:columndef 350 id="description" 351 title="Description" 352 /> 353 <tbl:data> 354 <tbl:columns> 355 </tbl:columns> 356 <tbl:rows> 357 <% 358 for (DataFileType fileType : fileTypes) 359 { 360 %> 361 <tbl:row> 362 <tbl:cell column="name"><base:icon 363 image="deleted.gif" 364 tooltip="This item has been scheduled for deletion" 365 visible="<%=fileType.isRemoved()%>" 366 /><%=Base.getLinkedName(ID, fileType, false, true)%></tbl:cell> 367 <tbl:cell column="extension"><%=HTML.encodeTags(fileType.getExtension()) %></tbl:cell> 368 <tbl:cell column="description"><%=HTML.encodeTags(fileType.getDescription())%></tbl:cell> 369 </tbl:row> 370 <% 371 } 372 %> 373 </tbl:rows> 374 </tbl:data> 375 </tbl:table> 376 </base:section> 377 <% 378 } 379 %> 380 381 315 382 <jsp:include page="../../common/anytoany/list_anytoany.jsp"> 316 383 <jsp:param name="ID" value="<%=ID%>" /> -
trunk/www/common/datafiles/list_files.jsp
r5623 r5698 23 23 @version 2.0 24 24 --%> 25 <%@page import="net.sf.basedb.core.Subtypable"%> 26 <%@page import="net.sf.basedb.core.ItemSubtype"%> 25 27 <%@ page pageEncoding="UTF-8" session="false" 26 28 import="net.sf.basedb.core.SessionControl" … … 101 103 Platform platform = null; 102 104 PlatformVariant variant = null; 105 ItemSubtype subtype = null; 103 106 try 104 107 { … … 108 111 catch (Throwable t) 109 112 {} 113 if (item instanceof Subtypable) 114 { 115 try 116 { 117 subtype = ((Subtypable)item).getItemSubtype(); 118 } 119 catch (Throwable t) 120 {} 121 } 110 122 111 123 // Load member file types … … 175 187 catch (Throwable t) 176 188 {} 189 } 190 } 191 192 // Load subtype-related file types 193 if (subtype != null) 194 { 195 ItemQuery<DataFileType> query = subtype.getDataFileTypes(); 196 for (DataFileType dft : query.list(dc)) 197 { 198 if (!existing.contains(dft)) 199 { 200 members.add(new DataFile(dft, null, null)); 201 } 177 202 } 178 203 } … … 255 280 PlatformFileType pft = platformFileTypes.get(dft); 256 281 boolean isRequired = pft == null ? false : pft.isRequired(); 257 boolean isPartOfPlatform = pft != null ;282 boolean isPartOfPlatform = pft != null || (subtype != null && subtype.isAssociatedDataFileType(dft)); 258 283 String icon = null; 259 284 if (member == null) … … 273 298 icon = "error.gif"; 274 299 } 275 else if (!isPartOfPlatform && platform != null)300 else if (!isPartOfPlatform) 276 301 { 277 302 icon = "warning.gif"; 278 validationMessage = "This file is not part of the <i>" + HTML.encodeTags(platform.getName()) + "</i> platform"; 303 if (platform != null) 304 { 305 validationMessage = "This file is not part of the <i>" + HTML.encodeTags(platform.getName()) + "</i> platform"; 306 } 307 else if (subtype != null) 308 { 309 validationMessage = "This file is not part of the <i>" + HTML.encodeTags(subtype.getName()) + "</i> subtype"; 310 } 279 311 } 280 312 else if (Boolean.TRUE.equals(validFile)) -
trunk/www/common/datafiles/select_files.jsp
r5623 r5698 40 40 import="net.sf.basedb.core.PlatformFileType" 41 41 import="net.sf.basedb.core.DataFileType" 42 import="net.sf.basedb.core.Subtypable" 43 import="net.sf.basedb.core.ItemSubtype" 42 44 import="net.sf.basedb.core.ItemQuery" 43 45 import="net.sf.basedb.core.Include" … … 70 72 final int platformId = Values.getInt(request.getParameter("platform_id"), -1); 71 73 final int variantId = Values.getInt(request.getParameter("variant_id"), -1); 74 final int itemSubtypeId = Values.getInt(request.getParameter("itemsubtype_id"), -1); 72 75 final ItemContext cc = sc.getCurrentContext(itemType); 73 76 … … 84 87 } 85 88 86 // Get the current platform/variant 89 // Get the current platform/variant/itemsubtype 87 90 // -- if not submitted in URL use values from current item 88 91 PlatformVariant variant = null; 89 92 Platform platform = null; 93 ItemSubtype itemSubtype = null; 90 94 boolean deniedPlatform = false; 91 95 try 92 96 { 97 if (itemSubtypeId > 0) 98 { 99 itemSubtype = ItemSubtype.getById(dc, itemSubtypeId); 100 } 101 else if (item instanceof Subtypable) 102 { 103 itemSubtype = ((Subtypable)item).getItemSubtype(); 104 } 93 105 if (variantId > 0) 94 106 { … … 113 125 // Query to load data file types for specific itemType/platform/variant 114 126 final ItemQuery<DataFileType> fileTypeQuery = 115 Base.getDataFileTypes(itemType, item, platform, variant );127 Base.getDataFileTypes(itemType, item, platform, variant, itemSubtype); 116 128 List<DataFileType> fileTypes = fileTypeQuery.list(dc); 117 129 … … 203 215 if (fileTypes.size() == 0) 204 216 { 217 String what = ""; 218 if (platform != null) 219 { 220 what = "'" + HTML.encodeTags(platform.getName()) + "' platform"; 221 } 222 else if (itemSubtype != null) 223 { 224 what = "'" + HTML.encodeTags(itemSubtype.getName()) + "' subtype"; 225 } 205 226 %> 206 227 <div class="error"> 207 The <%=platform == null ? "" : "'" + HTML.encodeTags(platform.getName()) + "'" %> 208 platform doesn't define any file types for <%=itemType.toString() %> 209 items. 228 The <%=what%> doesn't define any file types for 229 <%=itemType.toString() %> items. 210 230 </div> 211 231 <% … … 233 253 // If file type is not registered with a variant, also check if it is inherited from platform 234 254 if (pft == null && variant != null) pft = platform.getFileType(dft, null); 235 boolean isPartOfPlatform = pft != null ;255 boolean isPartOfPlatform = pft != null || (itemSubtype != null && itemSubtype.isAssociatedDataFileType(dft)); 236 256 boolean isRequired = pft == null ? false : pft.isRequired(); 237 257 FileSetMember member = fileSet == null || !fileSet.hasMember(dft) ? … … 270 290 %> 271 291 <tr> 272 <td class="prompt "><%=HTML.encodeTags(dft.getName())%>292 <td class="prompt "><%=HTML.encodeTags(dft.getName())%> 273 293 <% 274 294 if (!isPartOfPlatform && !deniedPlatform) … … 276 296 hasNonPlatformFiles = true; 277 297 %> 278 <base:icon image="warning.gif" tooltip="This file is not part of the platform " />298 <base:icon image="warning.gif" tooltip="This file is not part of the platform/subtype" /> 279 299 <% 280 300 } … … 339 359 </table> 340 360 <% 341 if (platform != null && hasNonPlatformFiles) 342 { 343 %> 344 <div align="right"> 345 <base:icon image="warning.gif" /> 346 = The file type is not part of the <i><%=HTML.encodeTags(platform.getName())%></i> platform 347 </div> 348 <% 349 } 350 %> 351 <% 361 if (hasNonPlatformFiles) 362 { 363 if (platform != null) 364 { 365 %> 366 <div align="right"> 367 <base:icon image="warning.gif" /> 368 = The file type is not part of the <i><%=HTML.encodeTags(platform.getName())%></i> platform 369 </div> 370 <% 371 } 372 else if (itemSubtype != null) 373 { 374 %> 375 <div align="right"> 376 <base:icon image="warning.gif" /> 377 = The file type is not part of the <i><%=HTML.encodeTags(itemSubtype.getName())%></i> subtype 378 </div> 379 <% 380 } 381 } 352 382 } 353 383 %> -
trunk/www/include/scripts/platforms.js
r4889 r5698 31 31 function PlatformsClass() 32 32 { 33 this.loadDataFilesFrame = function(theFrame, ID, itemType, itemId, platformId, variantId )33 this.loadDataFilesFrame = function(theFrame, ID, itemType, itemId, platformId, variantId, itemSubtypeId) 34 34 { 35 35 var url = getRoot()+'common/datafiles/select_files.jsp?ID='+ID; … … 37 37 if (platformId != undefined && platformId != null) url += '&platform_id='+platformId; 38 38 if (variantId != undefined && variantId != null) url += '&variant_id='+variantId; 39 if (itemSubtypeId != undefined && itemSubtypeId != null) url += '&itemsubtype_id='+itemSubtypeId; 39 40 theFrame.location.href = url; 40 41 } -
trunk/www/views/derivedbioassays/edit_bioassay.jsp
r5687 r5698 318 318 var parentsChanged = false; 319 319 var protocolChanged = false; 320 var subtypeChanged = false; 320 321 var dataFilesLoaded = false; 321 322 function switchTab(tabControlId, tabId) … … 336 337 parentsChanged = false; 337 338 } 338 else if (tabId == 'datafiles' && (!dataFilesLoaded)) 339 { 340 //var platform = Platforms.getSelectedPlatform(frm.platform); 341 //var variant = Platforms.getSelectedVariant(frm.platform); 342 Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, 0, 0); 339 else if (tabId == 'datafiles' && (subtypeChanged || !dataFilesLoaded)) 340 { 341 var subtypeId = ItemSubtype.getSubtypeId('bioAssay'); 342 Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, 0, 0, subtypeId); 343 343 dataFilesLoaded = true; 344 subtypeChanged = false; 344 345 } 345 346 } … … 380 381 var frm = document.forms['bioAssay']; 381 382 var subtypeId = ItemSubtype.getSubtypeId('bioAssay'); 383 subtypeChanged = true; 382 384 var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'BIOASSAY', ['PROTOCOL', 'HARDWARE', 'SOFTWARE']); 383 385 protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']); … … 845 847 846 848 <t:tab id="datafiles" title="Data files" helpid="datafiles.edit"> 847 <iframe name="datafiles" id="idDatafiles" src="../../ ../common/datafiles/wait.jsp"849 <iframe name="datafiles" id="idDatafiles" src="../../common/datafiles/wait.jsp" 848 850 width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 849 851 marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe> … … 852 854 <t:tab id="annotations" title="Annotations" 853 855 helpid="annotations.edit" tooltip="Enter values for annotations"> 854 <iframe name="annotations" id="idAnnotations" src="../../ ../common/annotations/wait.jsp"856 <iframe name="annotations" id="idAnnotations" src="../../common/annotations/wait.jsp" 855 857 width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 856 858 marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe> … … 858 860 859 861 <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited"> 860 <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../ ../common/annotations/wait.jsp"862 <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../common/annotations/wait.jsp" 861 863 width="100%" height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0 862 864 marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
Note: See TracChangeset
for help on using the changeset viewer.