Changeset 5858


Ignore:
Timestamp:
Mar 10, 2020, 8:16:07 AM (21 months ago)
Author:
olle
Message:

Refs #1029. DNA/RNA extraction wizards "Lab tracking protocol for FFPE extraction" updated in step 3 "RNA/DNA details" with new button "Download DNA/RNA labels file":

  1. JSP file extraction_preparation.jsp in resources/sampleproc/ updated in step 3 "RNA/DNA details" with new button "Download DNA/RNA labels file" with id value "downloaddnarnalabelfile".
  1. Javascipt file extraction_preparation.js in resources/sampleproc/ updated:
    a. Function initPage() updated by adding click handler for id value "downloaddnarnalabelfile" coupled to new function downloadDnaRnaLabelFile().
    b. New function downloadDnaRnaLabelFile() added. It calls LabelGenerationServlet with command "GetDnaRnaLabelFile" and supplies a list of selected specimen items.
  1. Java servlet class/file LabelGenerationServlet.java in src/net/sf/basedb/meludi/servlet/ updated in protected method void doGet(HttpServletRequest req, HttpServletResponse resp) with new command "GetDnaRnaLabelFile" to create a label file for DNA/RNA items, where specimen names have been shortened by omitting ".s" from the item name. A time stamp is added to the default filename.
Location:
extensions/net.sf.basedb.meludi/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.meludi/trunk/resources/sampleproc/extraction_preparation.js

    r5852 r5858  
    6262    Buttons.addClickHandler('goregister', Wizard.goRegister);
    6363    Buttons.addClickHandler('gocreate', exprep.createProtocol);
     64    Buttons.addClickHandler('downloaddnarnalabelfile', exprep.downloadDnaRnaLabelFile);
    6465
    6566    // Final registration
     
    980981    Doc.show('gocreate');
    981982    //Doc.hide('gocreate');
     983    Doc.show('downloaddnarnalabelfile');
    982984
    983985    Wizard.keepSessionAlive();
     
    14461448      createdStartList = response.createdStartList;
    14471449    }
     1450    Doc.show('downloaddnarnalabelfile');
    14481451  }
    14491452
     
    15521555  }
    15531556
     1557  exprep.downloadDnaRnaLabelFile = function()
     1558  {
     1559    var frm = document.forms['meludi'];
     1560    // Get list of selected extract source items
     1561    var selItemsList = exprep.getSelectedItemsList();
     1562    //alert("extraction_preparation.js::downloadDnaRnaLabelFile: selItemsList = " + JSON.stringify(selItemsList));
     1563    var numItems = selItemsList.length;
     1564    //alert("extraction_preparation.js::downloadDnaRnaLabelFile: numItems = " + numItems);
     1565/*
     1566    var totNumItems = numItems;
     1567    for (var i = 0; i < totNumItems; i++)
     1568    {
     1569      var item = null;
     1570      if (i < numItems)
     1571      {
     1572        item = selItemsList[i];
     1573      }
     1574      submitInfo.items[submitInfo.items.length] = item;
     1575    }
     1576*/
     1577    var preview = false;
     1578
     1579    var url = '../LabelGeneration.servlet?ID=' + App.getSessionId();
     1580    url += '&cmd=GetDnaRnaLabelFile';
     1581    url += '&selitemslist='+encodeURIComponent(JSON.stringify(selItemsList));
     1582    url += '&preview=' + preview;
     1583    //alert("extraction_preparation.js::downloadDnaRnaLabelFile: (0) url = " + url);
     1584
     1585/*
     1586    if (preview)
     1587    {
     1588      Doc.hide('previewWrapper');
     1589      url += '&preview=1';
     1590     
     1591      Wizard.showLoadingAnimation('Working...');
     1592      Doc.hide('navigation');
     1593      Wizard.asyncJsonRequest(url, istat.onPreviewLoaded);
     1594    }
     1595    else
     1596    {
     1597      //window.location = url;   
     1598      window.open(url);   
     1599    }
     1600*/
     1601    window.open(url);   
     1602  }
     1603
    15541604  return exprep;
    15551605}();
  • extensions/net.sf.basedb.meludi/trunk/resources/sampleproc/extraction_preparation.jsp

    r4244 r5858  
    827827    <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" /></td>
    828828    <td><base:button id="gocreate" title="Create lab tracking protocol" image="<%=home+"/images/import.png"%>" /></td>
     829    <td><base:button id="downloaddnarnalabelfile" title="Download DNA/RNA labels file" image="<%=home+"/images/download.png"%>" /></td>
    829830    <td id="gonext-message" class="message"></td>
    830831  </tr>
  • extensions/net.sf.basedb.meludi/trunk/src/net/sf/basedb/meludi/servlet/LabelGenerationServlet.java

    r5744 r5858  
    341341        os.close();
    342342      }
     343      else if ("GetDnaRnaLabelFile".equals(cmd))
     344      {
     345        dc = sc.newDbControl();
     346        int activeProjectId = sc.getActiveProjectId();
     347        Project project = Project.getById(dc, activeProjectId);
     348        String sampleItemPrefix = Meludi.fetchSampleItemPrefix(activeProjectId);
     349        String bloodItemPrefix = Meludi.fetchBloodItemPrefix(activeProjectId);
     350        boolean bloodAndSampleItemPrefixesDiffer = Meludi.bloodAndSampleItemPrefixesDiffer(activeProjectId);
     351        String firstPart = "";
     352        String secondPart = "";
     353
     354        boolean preview = Values.getBoolean(req.getParameter("preview"), true);
     355        String jsonSelItemsListStr = Values.getString(req.getParameter("selitemslist"), "");
     356        // Get list of extract source item names
     357        List<String> selItemsIdList = new ArrayList<String>();
     358        JSONArray jsonItems = (JSONArray)new JSONParser().parse(jsonSelItemsListStr);
     359
     360        // Generate label file contents
     361        Integer sampleItemNumDigits = Meludi.fetchSampleItemNumDigits(sc.getActiveProjectId());
     362        String separator = "";
     363
     364        for (int i = 0; i < jsonItems.size(); ++i)
     365        {
     366          JSONObject jsonItem = (JSONObject)jsonItems.get(i);
     367          String itemName = (String)jsonItem.get("name");
     368          // Simplify item name by omitting ".s" for FFPR section (specimen)
     369          itemName = itemName.replace(".s", "");
     370          selItemsIdList.add(itemName);
     371          //firstPart += separator + itemName + ".s";
     372          firstPart += separator + itemName + ".d";
     373          separator = "\n";
     374          firstPart += separator + itemName + ".r";
     375          separator = "\n";
     376        }
     377        String labelString = "LABEL\n" + firstPart + secondPart;
     378
     379        // Get filename with time stamp
     380        String filename = "dna_rna_labels.csv";
     381        // Add time stamp to download filename
     382        DateToStringConverter d2 = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd_HHmm"));
     383        String timeStampStr = d2.convert(new Date());
     384        String fileExt = "";
     385        int fileExtIndex = filename.lastIndexOf(".");
     386        if (fileExtIndex >= 0)
     387        {
     388          // Get file extension
     389          fileExt = filename.substring(fileExtIndex);
     390          // Remove file extension
     391          filename = filename.substring(0, fileExtIndex);
     392        }
     393        filename += "_" + timeStampStr + fileExt;
     394       
     395        // Send labels in a file to the client.
     396        resp.setHeader("Content-Disposition", "attachment; filename=" + filename);
     397        resp.setContentType("text/plain");
     398        ServletOutputStream os = resp.getOutputStream();
     399        os.print(labelString);         
     400        os.flush();
     401        os.close();
     402      }
    343403    }
    344404    catch (Throwable t)
Note: See TracChangeset for help on using the changeset viewer.