Changeset 5698


Ignore:
Timestamp:
Aug 15, 2011, 1:57:00 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #597: Subtypes of items

Implemented linking of item subtypes and data file types so that we can show/hide the suitable file types when editing an item.

This should more or less complete the item subtype feature. I'll keep the ticket open a little longer in case something pops up.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r5689 r5698  
    10581058  /**
    10591059    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 item
     1060    platform/variant/subtype that can be used on a given item type. If an item
    10611061    is specified the query will also return data file types that
    10621062    already are present in the item's file set even if those
     
    10661066    @param platform The platform to get file types for, or null
    10671067    @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
    10681069    @return An <code>ItemQuery</code> object
    1069     @since 2.5
    1070   */
    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)
    10721073  {
    10731074    ItemQuery<DataFileType> q = DataFileType.getQuery();
     
    11031104    }
    11041105   
     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   
    11051114    // Also include file types already present for item
    11061115    Restriction onItem = null;
     
    11121121    }
    11131122   
    1114     // full = onItem || (onItemType && onPlatform)
     1123    // full = onItem || (onItemType && onPlatform && onSubtype)
    11151124    Restriction full = onItemType;
    11161125    if (onPlatform != null) full = Restrictions.and(full, onPlatform);
     1126    if (onSubtype != null) full = Restrictions.and(full, onSubtype);
    11171127    if (onItem != null) full = Restrictions.or(full, onItem);
    11181128   
  • trunk/src/core/net/sf/basedb/core/DataFileType.java

    r5697 r5698  
    560560
    561561  /**
     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  /**
    562581    Check if there is at least one extension that claims to support
    563582    validation of files of this type. The extensions are not actually
  • trunk/src/core/net/sf/basedb/core/Install.java

    r5697 r5698  
    489489     
    490490      // Derived bioassay set subtypes
    491       createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SCAN,
     491      ItemSubtypeData scan = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SCAN,
    492492        "Scan", "A hybridization that has been scanned to produce one or more images.",
    493493        hybridization, scanner, scanningProtocol, labeledExtract);
    494       createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SEQUENCED,
     494      ItemSubtypeData sequenced = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SEQUENCED,
    495495        "Sequenced", "A flow cell that has been sequenced.",
    496496        flowCell, sequencer, sequencingProtocol, library);
    497       createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.ASSEMBLY,
     497      ItemSubtypeData assembly = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.ASSEMBLY,
    498498        "Assembly", "A data set of sequences that has been aligned against a reference database",
    499499        alignmentSoftware, library);
     
    849849        DataFileType.SAM, "Sequence Alignment/Map",
    850850        "SAM format is a generic format for storing large nucleotide sequence alignments.",
    851         Item.DERIVEDBIOASSAY, "sam", alignedType
     851        Item.DERIVEDBIOASSAY, "sam", alignedType, assembly
    852852      );
    853853      DataFileTypeData bamFile = createDataFileType(
    854854        DataFileType.BAM, "Compressed Sequence Alignment/Map",
    855855        "BAM format is a BGZF-compressed SAM file.",
    856         Item.DERIVEDBIOASSAY, "bam", alignedType
     856        Item.DERIVEDBIOASSAY, "bam", alignedType, assembly
    857857      );
    858858      DataFileTypeData scanImageFile = createDataFileType(
    859859        DataFileType.MICROARRAY_IMAGE, "Microarray image",
    860860        "Scanned image from a microarray slide.",
    861         Item.DERIVEDBIOASSAY, "tif", imageType
     861        Item.DERIVEDBIOASSAY, "tif", imageType, scan
    862862      );
    863863     
     
    25932593  private static DataFileTypeData createDataFileType(
    25942594    String externalId, String name, String description,
    2595     Item itemType, String extension, ItemSubtypeData genericType)
     2595    Item itemType, String extension, ItemSubtypeData genericType,
     2596    ItemSubtypeData... itemSubtypes)
    25962597    throws BaseException
    25972598  {
     
    26132614      {
    26142615        log.info("createDataFileType: EXISTS [externalId="+externalId+"]");
     2616        if (itemSubtypes != null)
     2617        {
     2618          for (ItemSubtypeData itemSubtype : itemSubtypes)
     2619          {
     2620            fileType.getItemSubtypes().add(itemSubtype);
     2621          }
     2622        }
    26152623        HibernateUtil.commit(tx);
    26162624      }
     
    26252633        fileType.setGenericType(genericType);
    26262634 
     2635        if (itemSubtypes != null)
     2636        {
     2637          for (ItemSubtypeData itemSubtype : itemSubtypes)
     2638          {
     2639            fileType.getItemSubtypes().add(itemSubtype);
     2640          }
     2641        }
     2642       
    26272643        HibernateUtil.saveData(session, fileType);
    26282644        HibernateUtil.commit(tx);
  • trunk/src/core/net/sf/basedb/core/ItemSubtype.java

    r5686 r5698  
    525525 
    526526  /**
     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  /**
    527586    Helper method for implementing the {@link Subtypable#setItemSubtype(ItemSubtype)}
    528587    method.
  • trunk/src/core/net/sf/basedb/core/data/DataFileTypeData.java

    r5630 r5698  
    2222package net.sf.basedb.core.data;
    2323
     24import java.util.HashSet;
    2425import java.util.Set;
    2526
     
    138139  }
    139140 
     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 
    140159  private ItemSubtypeData genericType;
    141160  /**
  • trunk/src/core/net/sf/basedb/core/data/ItemSubtypeData.java

    r5645 r5698  
    2424import java.util.Date;
    2525import java.util.HashMap;
     26import java.util.HashSet;
    2627import java.util.Map;
    2728import java.util.Set;
     
    171172  }
    172173 
     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
    173192 
    174193}
  • trunk/www/admin/itemsubtypes/edit_subtype.jsp

    r5645 r5698  
    3232  import="net.sf.basedb.core.PermissionDeniedException"
    3333  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"
    3440  import="net.sf.basedb.clients.web.Base"
    3541  import="net.sf.basedb.clients.web.util.HTML"
     
    5763  String title = null;
    5864  ItemSubtype subtype = null;
    59 
     65  ItemQuery<DataFileType> fileTypesQuery = null;
     66 
    6067  if (itemId == 0)
    6168  {
     
    6976    title = "Edit item subtype -- " + HTML.encodeTags(subtype.getName());
    7077    subtype.checkPermission(Permission.WRITE);
     78    fileTypesQuery = subtype.getDataFileTypes();
    7179  }
    7280 
     
    7886  %>
    7987  <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">
    8189    <ext:scripts context="<%=jspContext%>" />
    8290    <ext:stylesheets context="<%=jspContext%>" />
     
    101109      if (TabControl.validateActiveTab('settings'))
    102110      {
     111        frm.addedFileTypes.value = Link.getActionIds(1, 'F').join(',');
     112        frm.removedFileTypes.value = Link.getActionIds(-1, 'F').join(',');
    103113        frm.submit();
    104114      }
     
    117127      }
    118128      %>
     129      initFileTypes();
    119130      mainItemOnChange();
    120131    }
    121132   
    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();
    124153    <%
    125154    for (Item item : subtypableItems)
     
    131160      }
    132161      %>
    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;
    135167      <%
    136168    }
    137169    %>
    138170   
    139     function mainItemOnChange()
     171    function getCurrentMainItemType()
    140172    {
    141173      var frm = document.forms['subtype'];
     
    153185        <%
    154186      }
     187      %>
     188      return mainType;
     189    }
     190   
     191    function mainItemOnChange()
     192    {
     193      var mainType = getCurrentMainItemType();
     194      <%
    155195      for (Item item : subtypableItems)
    156196      {
    157197        %>
    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)
    159199        <%
    160200      }
    161201      %>
    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      }
    163214    }
    164215   
     
    169220      lastList = frm['related.'+itemType];
    170221      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;
    172223      if (lastList.length > 1)
    173224      {
     
    189240      list.selectedIndex = 1;
    190241    }
     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
    191264    </script>
    192265  </base:head>
     
    273346      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
    274347    </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&hellip;"
     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>
    275388    </t:tabcontrol>
    276389
  • trunk/www/admin/itemsubtypes/index.jsp

    r5631 r5698  
    2929  import="net.sf.basedb.core.Include"
    3030  import="net.sf.basedb.core.ItemSubtype"
     31  import="net.sf.basedb.core.DataFileType"
    3132  import="net.sf.basedb.core.ItemQuery"
    3233  import="net.sf.basedb.core.Permission"
     
    171172        }
    172173      }
     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      }
    173181     
     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
    174189      cc.removeAllTemporaryFilters();
    175190     
  • trunk/www/admin/itemsubtypes/list_subtypes.jsp

    r5686 r5698  
    2828  import="net.sf.basedb.core.Item"
    2929  import="net.sf.basedb.core.ItemSubtype"
     30  import="net.sf.basedb.core.DataFileType"
    3031  import="net.sf.basedb.core.ItemQuery"
    3132  import="net.sf.basedb.core.Include"
     
    9899  relatedQuery.include(cc.getInclude());
    99100 
     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
    100107  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    101108  try
     
    272279        exportable="true"
    273280      />     
     281      <tbl:columndef
     282        id="dataFileTypes"
     283        title="File types"
     284        property="&dataFileTypes(name)"
     285        datatype="string"
     286        filterable="true"
     287        exportable="true"
     288      />
    274289      <tbl:columndef
    275290        id="description"
     
    457472                  %>
    458473                </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>
    459493                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
    460494              </tbl:row>
  • trunk/www/admin/itemsubtypes/view_subtype.jsp

    r5645 r5698  
    3434  import="net.sf.basedb.core.Permission"
    3535  import="net.sf.basedb.core.ItemSubtype"
     36  import="net.sf.basedb.core.DataFileType"
    3637  import="net.sf.basedb.core.PermissionDeniedException"
    3738  import="net.sf.basedb.core.PluginDefinition"
     
    313314      %>
    314315
     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
    315382      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
    316383        <jsp:param name="ID" value="<%=ID%>" />
  • trunk/www/common/datafiles/list_files.jsp

    r5623 r5698  
    2323  @version 2.0
    2424--%>
     25<%@page import="net.sf.basedb.core.Subtypable"%>
     26<%@page import="net.sf.basedb.core.ItemSubtype"%>
    2527<%@ page pageEncoding="UTF-8" session="false"
    2628  import="net.sf.basedb.core.SessionControl"
     
    101103  Platform platform = null;
    102104  PlatformVariant variant = null;
     105  ItemSubtype subtype = null;
    103106  try
    104107  {
     
    108111  catch (Throwable t)
    109112  {}
     113  if (item instanceof Subtypable)
     114  {
     115    try
     116    {
     117      subtype = ((Subtypable)item).getItemSubtype();
     118    }
     119    catch (Throwable t)
     120    {}
     121  }
    110122 
    111123  // Load member file types
     
    175187      catch (Throwable t)
    176188      {}
     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      }
    177202    }
    178203  }
     
    255280            PlatformFileType pft = platformFileTypes.get(dft);
    256281            boolean isRequired = pft == null ? false : pft.isRequired();
    257             boolean isPartOfPlatform = pft != null;
     282            boolean isPartOfPlatform = pft != null || (subtype != null && subtype.isAssociatedDataFileType(dft));
    258283            String icon = null;
    259284            if (member == null)
     
    273298                icon = "error.gif";
    274299              }
    275               else if (!isPartOfPlatform && platform != null)
     300              else if (!isPartOfPlatform)
    276301              {
    277302                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                }
    279311              }
    280312              else if (Boolean.TRUE.equals(validFile))
  • trunk/www/common/datafiles/select_files.jsp

    r5623 r5698  
    4040  import="net.sf.basedb.core.PlatformFileType"
    4141  import="net.sf.basedb.core.DataFileType"
     42  import="net.sf.basedb.core.Subtypable"
     43  import="net.sf.basedb.core.ItemSubtype"
    4244  import="net.sf.basedb.core.ItemQuery"
    4345  import="net.sf.basedb.core.Include"
     
    7072final int platformId = Values.getInt(request.getParameter("platform_id"), -1);
    7173final int variantId = Values.getInt(request.getParameter("variant_id"), -1);
     74final int itemSubtypeId = Values.getInt(request.getParameter("itemsubtype_id"), -1);
    7275final ItemContext cc = sc.getCurrentContext(itemType);
    7376
     
    8487  }
    8588
    86   // Get the current platform/variant 
     89  // Get the current platform/variant/itemsubtype
    8790  // -- if not submitted in URL use values from current item
    8891  PlatformVariant variant = null;
    8992  Platform platform = null;
     93  ItemSubtype itemSubtype = null;
    9094  boolean deniedPlatform = false;
    9195  try
    9296  {
     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    }
    93105    if (variantId > 0)
    94106    {
     
    113125  // Query to load data file types for specific itemType/platform/variant
    114126  final ItemQuery<DataFileType> fileTypeQuery =
    115     Base.getDataFileTypes(itemType, item, platform, variant);
     127    Base.getDataFileTypes(itemType, item, platform, variant, itemSubtype);
    116128  List<DataFileType> fileTypes = fileTypeQuery.list(dc);
    117129 
     
    203215    if (fileTypes.size() == 0)
    204216    {
     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      }
    205226      %>
    206227      <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.
    210230      </div>
    211231      <%
     
    233253        // If file type is not registered with a variant, also check if it is inherited from platform
    234254        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));
    236256        boolean isRequired = pft == null ? false : pft.isRequired();
    237257        FileSetMember member = fileSet == null || !fileSet.hasMember(dft) ?
     
    270290        %>
    271291        <tr>
    272           <td class="prompt"><%=HTML.encodeTags(dft.getName())%>
     292          <td class="prompt "><%=HTML.encodeTags(dft.getName())%>
    273293          <%
    274294          if (!isPartOfPlatform && !deniedPlatform)
     
    276296            hasNonPlatformFiles = true;
    277297            %>
    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" />
    279299            <%
    280300          }
     
    339359      </table>
    340360      <%
    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      }
    352382    }
    353383    %>
  • trunk/www/include/scripts/platforms.js

    r4889 r5698  
    3131function PlatformsClass()
    3232{
    33   this.loadDataFilesFrame = function(theFrame, ID, itemType, itemId, platformId, variantId)
     33  this.loadDataFilesFrame = function(theFrame, ID, itemType, itemId, platformId, variantId, itemSubtypeId)
    3434  {
    3535    var url = getRoot()+'common/datafiles/select_files.jsp?ID='+ID;
     
    3737    if (platformId != undefined && platformId != null) url += '&platform_id='+platformId;
    3838    if (variantId != undefined && variantId != null) url += '&variant_id='+variantId;
     39    if (itemSubtypeId != undefined && itemSubtypeId != null) url += '&itemsubtype_id='+itemSubtypeId;
    3940    theFrame.location.href = url;
    4041  }
  • trunk/www/views/derivedbioassays/edit_bioassay.jsp

    r5687 r5698  
    318318    var parentsChanged = false;
    319319    var protocolChanged = false;
     320    var subtypeChanged = false;
    320321    var dataFilesLoaded = false;
    321322    function switchTab(tabControlId, tabId)
     
    336337          parentsChanged = false;
    337338        }
    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);
    343343          dataFilesLoaded = true;
     344          subtypeChanged = false;
    344345        }
    345346      }
     
    380381      var frm = document.forms['bioAssay'];
    381382      var subtypeId = ItemSubtype.getSubtypeId('bioAssay');
     383      subtypeChanged = true;
    382384      var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'BIOASSAY', ['PROTOCOL', 'HARDWARE', 'SOFTWARE']);
    383385      protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']);
     
    845847
    846848    <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"
    848850        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
    849851        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
     
    852854    <t:tab id="annotations" title="Annotations"
    853855      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"
    855857        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
    856858        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
     
    858860   
    859861    <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"
    861863        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
    862864        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
Note: See TracChangeset for help on using the changeset viewer.