Changeset 5649


Ignore:
Timestamp:
May 30, 2011, 2:23:32 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1597: Subtypes of items

Added subtype functionality for physical bioassays. Including the web gui and batch importer.

Replaced the HybridizationImporter with PhysicalBioAssayImporter. The hybridization importer is kept for supporting older servers only and so is the LabeledExtractImporter. They are not installed on new installations.

Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/core/core-plugins.xml

    r5637 r5649  
    535535  </plugin-definition>
    536536
     537  <!--
     538  Used for backwards compatibility with older server installations
    537539  <plugin-definition id="LabeledExtractImporter">
    538540    <about>
     
    547549    </settings>
    548550  </plugin-definition>
    549 
     551  -->
     552  <!--
     553  Used for backwards compatibility with older server installations
    550554  <plugin-definition id="HybridizationImporter">
    551555    <about>
     
    560564    </settings>
    561565  </plugin-definition>
    562 
     566  -->
     567  <plugin-definition id="PhysicalBioAssayImporter">
     568    <about>
     569      <name>Physical bioassay importer</name>
     570      <description>
     571        Imports and updates physical bioassays in a batch.
     572      </description>
     573    </about>
     574    <plugin-class>net.sf.basedb.plugins.batchimport.PhysicalBioAssayImporter</plugin-class>
     575    <settings>
     576      <property name="everyone-use">1</property>
     577    </settings>
     578  </plugin-definition>
     579 
    563580  <plugin-definition id="ScanImporter">
    564581    <about>
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/HybridizationImporter.java

    r5642 r5649  
    4444import net.sf.basedb.core.SystemItems;
    4545import net.sf.basedb.core.plugin.GuiContext;
     46import net.sf.basedb.core.query.Expressions;
     47import net.sf.basedb.core.query.Hql;
     48import net.sf.basedb.core.query.Restrictions;
    4649import net.sf.basedb.util.parser.FlatFileParser;
    4750import net.sf.basedb.util.parser.Mapper;
     
    197200  protected ItemQuery<PhysicalBioAssay> createItemQuery()
    198201  {
    199     return PhysicalBioAssay.getQuery();
     202    ItemQuery<PhysicalBioAssay> query = PhysicalBioAssay.getQuery();
     203    query.restrictPermanent(
     204        Restrictions.eq(
     205          Hql.property("itemSubtype"),
     206          Expressions.integer(SystemItems.getId(PhysicalBioAssay.HYBRIDIZATION))
     207        )
     208      );
     209    return query;
    200210  }
    201211 
     
    222232  {
    223233    PhysicalBioAssay hyb = PhysicalBioAssay.getNew(dc);
     234    hyb.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(PhysicalBioAssay.HYBRIDIZATION)));
    224235    updateItem(dc, hyb, data);
    225236    return hyb;
     
    289300    {
    290301      String nameOrId = parentMapper.getValue(data);
    291       Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId);
     302      ItemSubtype type = ItemSubtype.getById(dc, SystemItems.getId(Extract.LABELED));
     303      Extract parent = findExtract(dc, FallbackIdMethod.NAME_OR_EXTERNALID_OR_ID, nameOrId, type);
    292304      if (parent != null)
    293305      {
  • trunk/src/test/TestItemImporter.java

    r5648 r5649  
    136136    // Import hybridizations
    137137    int hybFileId = TestFile.test_create("data/test.batchimport.hybridizations.txt", false, false);
    138     int hybImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.HybridizationImporter");
     138    int hybImporterId  = TestPluginDefinition.test_get("net.sf.basedb.plugins.batchimport.PhysicalBioAssayImporter");
    139139    int hybJobId = test_create_item_import_job(Item.PHYSICALBIOASSAY, hybImporterId, hybFileId);
    140140    ok &= TestJob.test_execute(hybJobId, false);
     
    359359    if (itemType == Item.PHYSICALBIOASSAY)
    360360    {
    361       request.setParameterValue("numArraysColumnMapping", "\\Num arrays\\");
     361      request.setParameterValue("subtypeColumnMapping", "Hybridization");
     362      request.setParameterValue("sizeColumnMapping", "\\Size\\");
    362363      request.setParameterValue("protocolColumnMapping", "\\Protocol\\");
    363       request.setParameterValue("hardwareColumnMapping", "\\Hyb station\\");
     364      request.setParameterValue("hardwareColumnMapping", "\\Hardware\\");
    364365      request.setParameterValue("createdColumnMapping", "\\Created\\");
    365366      request.setParameterValue("parentColumnMapping", "\\Parent\\");
    366367      request.setParameterValue("usedQuantityColumnMapping", "\\Used quantity\\");
    367       request.setParameterValue("arrayIndexColumnMapping", "\\Array index\\");
     368      request.setParameterValue("extractPositionColumnMapping", "\\Position\\");
    368369      request.setParameterValue("arraySlideColumnMapping", "\\Array slide\\");
    369370    }
  • trunk/src/test/data/test.batchimport.hybridizations.txt

    r4434 r5649  
    1 Name  Description Num arrays  Protocol  Hyb station Array slide Created Parent  Used quantity Array index
     1Name  Description Size  Protocol  Hardware  Array slide Created Parent  Used quantity Position
    22Hyb 1 The first 1 Hybridization Hybstation  Slide 1.2 2008-01-01  Labeled 1.1 50
    33Hyb 1             Labeled 1.2 50
  • trunk/src/test/net/sf/basedb/test/roles/AdminTest.java

    r5630 r5649  
    5050import net.sf.basedb.plugins.batchimport.BioSourceImporter;
    5151import net.sf.basedb.plugins.batchimport.ExtractImporter;
    52 import net.sf.basedb.plugins.batchimport.HybridizationImporter;
    53 import net.sf.basedb.plugins.batchimport.LabeledExtractImporter;
     52import net.sf.basedb.plugins.batchimport.PhysicalBioAssayImporter;
    5453import net.sf.basedb.plugins.batchimport.RawBioAssayImporter;
    5554import net.sf.basedb.plugins.batchimport.SampleImporter;
     
    116115      plugins.add(PluginDefinition.getByClassName(dc, SampleImporter.class.getName()));
    117116      plugins.add(PluginDefinition.getByClassName(dc, ExtractImporter.class.getName()));
    118       plugins.add(PluginDefinition.getByClassName(dc, LabeledExtractImporter.class.getName()));
    119       plugins.add(PluginDefinition.getByClassName(dc, HybridizationImporter.class.getName()));
     117      plugins.add(PluginDefinition.getByClassName(dc, PhysicalBioAssayImporter.class.getName()));
    120118      plugins.add(PluginDefinition.getByClassName(dc, ScanImporter.class.getName()));
    121119      plugins.add(PluginDefinition.getByClassName(dc, RawBioAssayImporter.class.getName()));
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r5648 r5649  
    442442    TestUtil.write("--Creating hybridization: " + name + "\n");
    443443    PhysicalBioAssay hyb = PhysicalBioAssay.getNew(dc);
     444    hyb.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(PhysicalBioAssay.HYBRIDIZATION)));
    444445    hyb.setName(name);
    445446    hyb.setArraySlide(Util.findArraySlide(dc, arraySlideName));
  • trunk/www/views/physicalbioassays/edit_bioassay.jsp

    r5642 r5649  
    3535  import="net.sf.basedb.core.PhysicalBioAssay"
    3636  import="net.sf.basedb.core.BioMaterialEvent"
     37  import="net.sf.basedb.core.ItemSubtype"
    3738  import="net.sf.basedb.core.ArraySlide"
    3839  import="net.sf.basedb.core.Protocol"
     
    8384  ItemQuery<Extract> extractsQuery = null;
    8485 
     86  boolean readCurrentSubtype = true;
     87  int currentSubtypeId = 0;
    8588  boolean readCurrentArraySlide = true;
    8689  ArraySlide currentArraySlide = null;
     
    123126    title = "Create physical bioassay";
    124127    cc.removeObject("item");
     128    currentSubtypeId = Values.getInt(request.getParameter("subtype_id"));
     129    if (currentSubtypeId == 0)
     130    {
     131      int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0));
     132      currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId);
     133    }
    125134    if (cc.getPropertyFilter("creationEvent.protocol.name") != null)
    126135    {
     
    162171  {
    163172    pba = PhysicalBioAssay.getById(dc, itemId);
     173    pba.checkPermission(Permission.WRITE);
    164174    creationEvent = pba.getCreationEvent();
    165175    eventDate = creationEvent.getEventDate();
     
    167177    title = "Edit physical bioassay -- " + HTML.encodeTags(pba.getName());
    168178    name = pba.getName();
     179   
     180    try
     181    {
     182      ItemSubtype subtype = pba.getItemSubtype();
     183      if (subtype != null) currentSubtypeId = subtype.getId();
     184    }
     185    catch (PermissionDeniedException ex)
     186    {
     187      readCurrentSubtype = false;
     188    }
     189
    169190    try
    170191    {
     
    198219   
    199220  }
    200   if (pba != null) pba.checkPermission(Permission.WRITE);
     221  // Query to retrieve item types
     222  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
     223  subtypesQuery.include(Include.ALL);
    201224
    202225  final String clazz = "class=\"text\"";
     
    210233  %>
    211234  <base:page type="popup" title="<%=title%>">
    212   <base:head scripts="tabcontrol.js,annotations.js,linkitems.js,ajax.js,json2.js" styles="tabcontrol.css">
     235  <base:head scripts="tabcontrol.js,annotations.js,linkitems.js,subtypes.js,ajax.js,json2.js" styles="tabcontrol.css">
    213236    <ext:scripts context="<%=jspContext%>" />
    214237    <ext:stylesheets context="<%=jspContext%>" />
     
    313336    {
    314337      var frm = document.forms['bioassay'];
    315       var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setProtocolCallback';
     338      var url = '../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
     339      url += '&callback=setProtocolCallback&resetTemporary=1';
     340      url += ItemSubtype.createRelatedFilter('bioassay', 'PROTOCOL');
    316341      if (frm.protocol_id.length > 1)
    317342      {
     
    319344        url += '&item_id='+id;
    320345      }
    321       url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Protocol.HYBRIDIZATION)%>';
    322346      Main.openPopup(url, 'SelectProtocol', 1000, 700);
    323347    }
     
    343367    {
    344368      var frm = document.forms['bioassay'];
    345       var url = '../../admin/hardware/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setHardwareCallback';
     369      var url = '../../admin/hardware/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
     370      url += '&callback=setHardwareCallback&resetTemporary=1';
     371      url += ItemSubtype.createRelatedFilter('bioassay', 'HARDWARE');
    346372      if (frm.hardware_id.length > 1)
    347373      {
     
    349375        url += '&item_id='+id;
    350376      }
    351       url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(Hardware.HYBRIDIZATION_STATION)%>';
    352377      Main.openPopup(url, 'SelectHardware', 1000, 700);
    353378    }
     
    399424      parentsChanged = true;
    400425    }
    401     function updateNumArrays(arraySlideId)
     426    function updateSize(arraySlideId)
    402427    {
    403428      var request = Ajax.getXmlHttpRequest();
     
    406431        var url = '../../lims/arrayslides/ajax.jsp?ID=<%=ID%>&cmd=GetArrayDesign&item_id=' + arraySlideId;
    407432        request.open("GET", url, true);
    408         Ajax.setReadyStateHandler(request, updateNumArraysCallback);
     433        Ajax.setReadyStateHandler(request, updateSizeCallback);
    409434        request.send(null);
    410435      }
    411436      return request != null;
    412437    }
    413     function updateNumArraysCallback(request)
     438    function updateSizeCallback(request)
    414439    {
    415440      var frm = document.forms['bioassay'];
     
    433458      var excludes = ids.join(',');
    434459     
    435       var url = '../../biomaterials/extracts/index.jsp?ID=<%=ID%>&mode=selectmultiple&callback=addExtractCallback';
     460      var url = '../../biomaterials/extracts/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple';
     461      url += '&callback=addExtractCallback&resetTemporary=1';
     462      url += ItemSubtype.createRelatedFilter('bioassay', 'EXTRACT');
    436463      url += '&exclude='+excludes;
    437464      Main.openPopup(url, 'AddExtracts', 1000, 700);
     
    554581          value="<%=name%>"
    555582          size="40" maxlength="<%=PhysicalBioAssay.MAX_NAME_LENGTH%>"></td>
     583      </tr>
     584      <tr valign="top">
     585        <td class="prompt">Type</td>
     586        <td colspan="2">
     587          <select name="subtype_id"
     588            <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>>
     589          <%
     590          if (!readCurrentSubtype)
     591          {
     592            %>
     593            <option value="-1">- denied -
     594            <%
     595          }
     596          else
     597          {
     598            %>
     599            <option value="0">-none-
     600            <%
     601            for (ItemSubtype subtype : subtypesQuery.list(dc))
     602            {
     603              int id = subtype.getId();
     604              if (id != currentSubtypeId && subtype.isRemoved()) continue;
     605              %>
     606              <option value="<%=id == currentSubtypeId && pba != null ? -id : id%>"
     607                <%=id == currentSubtypeId ? "selected" : ""%>
     608                title="<%=HTML.encodeTags(subtype.getDescription()) %>"
     609                ><%=HTML.encodeTags(subtype.getName())%>
     610              <%
     611            }
     612          }
     613          %>
     614          </select>
     615        </td>
    556616      </tr>
    557617      <tr>
  • trunk/www/views/physicalbioassays/index.jsp

    r5642 r5649  
    3535  import="net.sf.basedb.core.Protocol"
    3636  import="net.sf.basedb.core.Hardware"
     37  import="net.sf.basedb.core.ItemSubtype"
    3738  import="net.sf.basedb.core.ItemQuery"
    3839  import="net.sf.basedb.core.ItemResultIterator"
     
    7576<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    7677<%!
    77   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,extracts,arraySlide,scans,description");
     78  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,extracts,arraySlide,scans,description");
    7879  private static final Item itemType = Item.PHYSICALBIOASSAY;
    7980 
     
    212213      }
    213214     
     215      int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1);
     216      if (subtypeId >= 0) // < 0 = denied or unchanged
     217      {
     218        ItemSubtype subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId);
     219        pba.setItemSubtype(subtype);
     220        if (subtype != null) cc.setRecent(subtype, maxRecent);
     221      }
     222
    214223      //Hardware
    215224      int hardwareId = Values.getInt(request.getParameter("hardware_id"), -1);
  • trunk/www/views/physicalbioassays/list_bioassays.jsp

    r5642 r5649  
    3636  import="net.sf.basedb.core.AnnotationSet"
    3737  import="net.sf.basedb.core.Annotation"
     38  import="net.sf.basedb.core.ItemSubtype"
    3839  import="net.sf.basedb.core.ItemQuery"
    3940  import="net.sf.basedb.core.Include"
     
    9495{
    9596  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     97  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
    9698
    9799  // Query for extracts relatated to the current bioassay
     
    254256        exportable="true"
    255257        show="always"
     258      />
     259      <tbl:columndef
     260        id="itemSubtype"
     261        property="itemSubtype"
     262        sortproperty="itemSubtype.name"
     263        exportproperty="itemSubtype.name"
     264        datatype="int"
     265        enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>"
     266        title="Type"
     267        sortable="true"
     268        filterable="true"
     269        exportable="true"
    256270      />
    257271      <tbl:columndef
     
    568582                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
    569583                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
     584                <tbl:cell column="itemSubtype"><base:propertyvalue
     585                    item="<%=item%>"
     586                    property="itemSubtype"
     587                    enableEditLink="<%=mode.hasEditLink()%>"
     588                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     589                  /></tbl:cell>
    570590                <tbl:cell column="size"><%=item.getSize()%></tbl:cell>
    571591                <tbl:cell column="extracts">
  • trunk/www/views/physicalbioassays/view_bioassay.jsp

    r5642 r5649  
    282282        <td class="prompt">Name</td>
    283283        <td><%=HTML.encodeTags(pba.getName())%></td>
     284      </tr>
     285      <tr>
     286        <td class="prompt">Type</td>
     287        <td><base:propertyvalue item="<%=pba%>" property="itemSubtype" /></td>
    284288      </tr>
    285289      <tr>
Note: See TracChangeset for help on using the changeset viewer.