Changeset 6996


Ignore:
Timestamp:
Nov 3, 2015, 11:32:22 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #1958: Add Kit item

Kits can now be selected for derived bioassays.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r6990 r6996  
    900900      A Hibernate query that gets bioplate events
    901901      events using a kit.
     902    </description>
     903  </query>
     904 
     905  <query id="GET_DERIVEDBIOASSAYS_FOR_KIT" type="HQL">
     906    <sql>
     907      SELECT {1}
     908      FROM DerivedBioAssayData dba
     909      WHERE dba.kit = :kit
     910    </sql>
     911    <description>
     912      A Hibernate query that gets derived bioassays using a kit.
    902913    </description>
    903914  </query>
  • trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java

    r6880 r6996  
    391391  */
    392392  @Override
    393   @SubtypableRelatedItems({Item.PHYSICALBIOASSAY, Item.DERIVEDBIOASSAY, Item.EXTRACT, Item.SOFTWARE, Item.HARDWARE, Item.PROTOCOL})
     393  @SubtypableRelatedItems({Item.PHYSICALBIOASSAY, Item.DERIVEDBIOASSAY, Item.EXTRACT, Item.SOFTWARE, Item.HARDWARE, Item.PROTOCOL, Item.KIT})
    394394  public ItemSubtype getItemSubtype()
    395395  {
     
    711711    protocolHasBeenSet = true;
    712712    getData().setProtocol(protocol == null ? null : protocol.getData());
     713  }
     714 
     715  /**
     716    Get the {@link Kit} that was used when creating this bioassay.
     717    @return A <code>Kit</code> item, or null if not known
     718    @throws PermissionDeniedException If the logged in user doesn't have
     719      read permission to the kit
     720    @throws BaseException If there is another error
     721    @since 3.7
     722  */
     723  public Kit getKit()
     724    throws PermissionDeniedException, BaseException
     725  {
     726    return getDbControl().getItem(Kit.class, getData().getKit());
     727  }
     728 
     729  /**
     730    Set the {@link Kit} that was used when creating this bioassay.
     731    @param kit A <code>Kit</code> item, or null if not known
     732    @throws PermissionDeniedException If the logged in user doesn't have
     733      write permission on this event or use permission for the kit
     734    @since 3.7
     735  */
     736  public void setKit(Kit kit)
     737    throws PermissionDeniedException
     738  {
     739    checkPermission(Permission.WRITE);
     740    if (kit != null) kit.checkPermission(Permission.USE);
     741    getData().setKit(kit == null ? null : kit.getData());
    713742  }
    714743 
  • trunk/src/core/net/sf/basedb/core/Install.java

    r6994 r6996  
    484484      ItemSubtypeData clusterKit = createItemSubtype(Item.KIT, Kit.CLUSTER_GENERATION,
    485485          "Cluster generation", "Kits used for cluster generation in a flow cell");
     486      ItemSubtypeData sequencingKit = createItemSubtype(Item.KIT, Kit.SEQUENCING,
     487          "Sequencing", "Kit used for sequencing");
    486488
    487489      // Hardware subtypes
     
    533535      ItemSubtypeData sequences = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.SEQUENCES,
    534536        "Sequences", "The original data set that consists of sequences found by the sequencer machine.",
    535         clonalAmplification, sequencer, sequencingProtocol, library);
     537        clonalAmplification, sequencer, sequencingProtocol, sequencingKit, library);
    536538      ItemSubtypeData arrangement = createItemSubtype(Item.DERIVEDBIOASSAY, DerivedBioAssay.ARRANGEMENT,
    537539        "Arrangement", "A data set of sequences that has been aligned against a reference database",
  • trunk/src/core/net/sf/basedb/core/Kit.java

    r6994 r6996  
    8484  */
    8585  public static final String CLUSTER_GENERATION = "net.sf.basedb.core.KitType.CLUSTER_GENERATION";
     86
     87  /**
     88    The ID for the sequencing kit type, for example a kit
     89    used when creating a {@link DerivedBioAssay} from a {@link PhysicalBioAssay}.
     90  */
     91  public static final String SEQUENCING = "net.sf.basedb.core.KitType.SEQUENCING";
    8692
    8793  /**
     
    270276      used = HibernateUtil.loadData(Long.class, q) > 0;
    271277    }
     278    if (!used)
     279    {
     280      org.hibernate.Query q = HibernateUtil.getPredefinedQuery(session,
     281          "GET_DERIVEDBIOASSAYS_FOR_KIT", "count(*)");
     282          /*
     283            SELECT {1}
     284            FROM DerivedBioAssayData dba
     285            WHERE dba.kit = :kit
     286          */
     287        q.setEntity("kit", this.getData());
     288        used = HibernateUtil.loadData(Long.class, q) > 0;
     289    }
    272290    return used || super.isUsed();
    273291  }
     
    275293    Get all:
    276294    <ul>
    277     <li>a {@link BioMaterial}:s and {@link PhysicalBioAssay}:s using this protocol
     295    <li>{@link BioMaterial}:s and {@link PhysicalBioAssay}:s using this kit
    278296    <li>{@link BioPlateEvents}:s with this kit
     297    <li>{@link DerivedBioAssay}: with this kit
    279298    </ul>
    280299  */
     
    317336    query.setEntity("kit", this.getData());
    318337    addUsingItems(using, Item.BIOPLATEEVENT, query);
     338   
     339    // Derived bioassays
     340    query = HibernateUtil.getPredefinedQuery(session,
     341      "GET_DERIVEDBIOASSAYS_FOR_KIT", "dba.id");
     342      /*
     343        SELECT {1}
     344        FROM DerivedBioAssayData dba
     345        WHERE dba.kit = :kit
     346      */
     347    query.setEntity("kit", this.getData());
     348    addUsingItems(using, Item.DERIVEDBIOASSAY, query);
    319349
    320350    return using;
  • trunk/src/core/net/sf/basedb/core/data/DerivedBioAssayData.java

    r6085 r6996  
    198198  }
    199199
     200  private KitData kit;
     201  /**
     202    Get the kit used to create this bioassay set.
     203    @since 3.7
     204    @hibernate.many-to-one column="`kit_id`" not-null="false" outer-join="false"
     205  */
     206  public KitData getKit()
     207  {
     208    return kit;
     209  }
     210  public void setKit(KitData kit)
     211  {
     212    this.kit = kit;
     213  }
     214 
    200215  private HardwareData hardware;
    201216  /**
  • trunk/www/biomaterials/extracts/extracts.js

    r6995 r6996  
    319319    var frm = document.forms['extract'];
    320320    var url = '&resetTemporary=1';
    321     url += '&tmpfilter:BOOLEAN:inactive=0';
    322321    url += ItemSubtype.createRelatedFilter('subtype_id', 'PROTOCOL', Data.int('page-data', 'extraction-protocoltype-id'));
    323322    if (frm.protocol_id.length > 1)
     
    346345    var frm = document.forms['extract'];
    347346    var url = '&resetTemporary=1';
     347    url += '&tmpfilter:BOOLEAN:inactive=0';
    348348    url += ItemSubtype.createRelatedFilter('subtype_id', 'KIT', Data.int('page-data', 'extraction-kittype-id'));
    349349    if (frm.kit_id.length > 1)
  • trunk/www/views/derivedbioassays/bioassays.js

    r6947 r6996  
    5454      Buttons.addClickHandler('protocol_id.select', bioassays.selectProtocol);
    5555      Events.addEventHandler('protocol_id', 'base-selected', bioassays.setProtocolCallback);
     56
     57      // Kit
     58      Buttons.addClickHandler('kit_id.select', bioassays.selectKit);
     59      Events.addEventHandler('kit_id', 'base-selected', bioassays.setKitCallback);
    5660     
    5761      // Hardware
     
    252256    var frm = document.forms['bioAssay'];
    253257    var subtypeId = ItemSubtype.getSubtypeId('subtype_id');
    254     var recentInfo = ItemSubtype.getRelatedProjectDefaultAndRecentItems('DERIVEDBIOASSAY', subtypeId, ['PROTOCOL', 'HARDWARE', 'SOFTWARE']);
     258    var recentInfo = ItemSubtype.getRelatedProjectDefaultAndRecentItems('DERIVEDBIOASSAY', subtypeId, ['PROTOCOL', 'KIT', 'HARDWARE', 'SOFTWARE']);
    255259    ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']);
     260    ItemSubtype.updateSelectionList(frm.kit_id, recentInfo.KIT['recent']);
    256261    ItemSubtype.updateSelectionList(frm.hardware_id, recentInfo.HARDWARE['recent'], recentInfo.HARDWARE['default']);
    257262    ItemSubtype.updateSelectionList(frm.software_id, recentInfo.SOFTWARE['recent'], recentInfo.SOFTWARE['default']);
     
    275280    var frm = document.forms['bioAssay'];
    276281    var list = frm.protocol_id;
     282    if (list.length < 2 || list[1].value == '0')
     283    {
     284      Forms.addListOption(list, 1, new Option());
     285    }
     286    list[1].value = event.detail.id;
     287    list[1].text = event.detail.name;
     288    list.selectedIndex = 1;
     289  }
     290
     291  bioassays.selectKit = function()
     292  {
     293    var frm = document.forms['bioAssay'];
     294    var url = '&resetTemporary=1';
     295    url += '&tmpfilter:BOOLEAN:inactive=0';
     296    url += ItemSubtype.createRelatedFilter('subtype_id', 'KIT');
     297    if (frm.kit_id.length > 1)
     298    {
     299      var id = Math.abs(parseInt(frm.kit_id[1].value));       
     300      url += '&item_id='+id;
     301    }
     302    Dialogs.selectItem('KIT', 'kit_id', 0, url);
     303  }
     304 
     305  bioassays.setKitCallback = function(event)
     306  {
     307    var frm = document.forms['bioAssay'];
     308    var list = frm.kit_id;
    277309    if (list.length < 2 || list[1].value == '0')
    278310    {
  • trunk/www/views/derivedbioassays/edit_bioassay.jsp

    r6947 r6996  
    2828  import="net.sf.basedb.core.ItemSubtype"
    2929  import="net.sf.basedb.core.Protocol"
     30  import="net.sf.basedb.core.Kit"
    3031  import="net.sf.basedb.core.Hardware"
    3132  import="net.sf.basedb.core.Software"
     
    8586  boolean readCurrentProtocol = true;
    8687  Protocol currentProtocol = null;
     88
     89  boolean readCurrentKit = true;
     90  Kit currentKit = null;
    8791 
    8892  boolean readCurrentHardware = true;
     
    200204    {
    201205      readCurrentProtocol = false;
     206    }
     207    try
     208    {
     209      currentKit = bioAssay.getKit();
     210    }
     211    catch (PermissionDeniedException ex)
     212    {
     213      readCurrentKit = false;
    202214    }
    203215    try
     
    234246  // Load recently used items
    235247  List<Protocol> recentProtocols = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL, currentSubtype);
     248  List<Kit> recentKits = (List<Kit>)cc.getRecent(dc, Item.KIT, currentSubtype);
    236249  List<Hardware> recentHardware = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE, currentSubtype);
    237250  List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE, currentSubtype);
     
    478491      </tr>
    479492      <tr>
     493        <th>Kit</th>
     494        <td>
     495          <base:select
     496            id="kit_id"
     497            clazz="selectionlist"
     498            required="false"
     499            current="<%=currentKit%>"
     500            denied="<%=!readCurrentKit%>"
     501            recent="<%=recentKits%>"
     502            newitem="<%=bioAssay == null%>"
     503          />
     504        </td>
     505        <td></td>
     506      </tr>
     507      <tr>
    480508        <th>Hardware</th>
    481509        <td>
  • trunk/www/views/derivedbioassays/index.jsp

    r6813 r6996  
    3131  import="net.sf.basedb.core.ItemSubtype"
    3232  import="net.sf.basedb.core.Extract"
     33  import="net.sf.basedb.core.Kit"
    3334  import="net.sf.basedb.core.Protocol"
    3435  import="net.sf.basedb.core.Software"
     
    240241      }
    241242     
     243      int kitId = Values.getInt(request.getParameter("kit_id"), -1);
     244      if (kitId >= 0) // < 0 = denied or unchanged
     245      {
     246        Kit kit = kitId == 0 ? null : Kit.getById(dc, kitId);
     247        bas.setKit(kit);
     248        if (kit != null) cc.setRecent(kit, subtype, maxRecent);
     249      }
     250     
    242251      int hardwareId = Values.getInt(request.getParameter("hardware_id"), -1);
    243252      if (hardwareId >= 0) // < 0 denied or unchanged
  • trunk/www/views/derivedbioassays/list_bioassays.jsp

    r6842 r6996  
    277277        datatype="string"
    278278        title="Protocol"
     279        sortable="true"
     280        filterable="true"
     281        exportable="true"
     282      />
     283      <tbl:columndef
     284        id="kit"
     285        property="kit.name"
     286        datatype="string"
     287        title="Kit"
    279288        sortable="true"
    280289        filterable="true"
     
    793802                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    794803                  /></tbl:cell>
     804                <tbl:cell column="kit"
     805                  ><base:propertyvalue
     806                    item="<%=item%>"
     807                    property="kit"
     808                    enableEditLink="<%=mode.hasEditLink()%>"
     809                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     810                  /></tbl:cell>
    795811                <tbl:cell column="hardware"
    796812                  ><base:propertyvalue
  • trunk/www/views/derivedbioassays/view_bioassay.jsp

    r6988 r6996  
    303303          <th>Protocol</th>
    304304          <td><base:propertyvalue item="<%=bioAssay%>" property="protocol" /></td>
     305        </tr>
     306        <tr>
     307          <th>Kit</th>
     308          <td><base:propertyvalue item="<%=bioAssay%>" property="kit" /></td>
    305309        </tr>
    306310        <tr>
Note: See TracChangeset for help on using the changeset viewer.