Changeset 5069


Ignore:
Timestamp:
Nov 1, 2018, 8:37:13 AM (5 years ago)
Author:
olle
Message:

Refs #1029. FFPE section order form wizard updated to create label files for FFPE sections and FFPE H&E glass slides for unused material. The final stage of the wizard is extended with two new buttons for downloading the label files. These buttons will be placed beside the button for downloading the FFPE section order form PDF file. The latter button is renamed to better describe that it is an FFPE section order form that is to be downloaded:

  1. JSP file ffpe_section_order_form.jsp in resources/personal/ updated by renaming button for downloading FFPE section order form to "Download FFPE section order form", and by adding two new buttons, "Download FFPE section labels file" and "Download HE glass labels file".
  2. Javascript file ffpe_section_order_form.js in resources/personal/ updated:
    a. Function initPage() updated with click handlers for buttons to download labels for FFPE sections and FFPE H&E glass slides, coupled to new functions downloadFfpeSectionLabelFile() and downloadHeGlassLabelFile(), respectively.
    b. Function initializeStep2(response) updated to show buttons to download labels for FFPE sections and FFPE H&E glass slides.
    c. New function downloadFfpeSectionLabelFile() added. It calls LabelGenerationServlet with new command "GetFfpeSectionLabelFile", supplying a list of selected FFPE blocks.
    d. New function downloadHeGlassLabelFile() added. It calls LabelGenerationServlet with new command "GetHeGlassLabelFile", supplying a list of selected FFPE blocks.
  3. Java servlet class/file LabelGenerationServlet.java in src/net/sf/basedb/meludi/servlet/ updated:
    a. Protected method void doGet(HttpServletRequest req, HttpServletResponse resp) updated with new command "GetFfpeSectionLabelFile" to created a label file for FFPE sections. The name for an FFPE section consists of the FFPE block name plus suffix ".s".
    b. Protected method void doGet(HttpServletRequest req, HttpServletResponse resp) updated with new command "GetHeGlassLabelFile" to created a label file for FFPE H&E glass slides. Two FFPE H&E glass slide labels will be created for each FFPE block, with names consisting of the FFPE block name plus suffix ".he-F" and ".he-E", respectively, where "F" and "E" indicates rest material at the front and end of the sectioned block (historically, the letters indicates the Swedish words "Före" and "Efter", meaning "Before" and "After").
Location:
extensions/net.sf.basedb.meludi/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.meludi/trunk/resources/personal/ffpe_section_order_form.js

    r5061 r5069  
    1616    // Step 2
    1717    Buttons.addClickHandler('downloadformbatch2', istat.downloadFormBatch2);
     18    Buttons.addClickHandler('downloadffpesectionlabelfile', istat.downloadFfpeSectionLabelFile);
     19    Buttons.addClickHandler('downloadheglasslabelfile', istat.downloadHeGlassLabelFile);
    1820   
    1921    // Navigation
     
    135137    Doc.hide('gonext');
    136138    Doc.show('downloadformbatch2');
     139    Doc.show('downloadffpesectionlabelfile');
     140    Doc.show('downloadheglasslabelfile');
    137141 
    138142    Doc.show('step-2');
     
    159163    url += '&nofFfpeBlocks='+encodeURIComponent(nofFfpeBlocks);
    160164    window.open(url);
     165  }
     166
     167  istat.downloadFfpeSectionLabelFile = function()
     168  {
     169    var frm = document.forms['meludi'];
     170    var ffpeBlockList = istat.getSelectedItemsList();
     171    var preview = false;
     172
     173    var url = '../LabelGeneration.servlet?ID=' + App.getSessionId();
     174    url += '&cmd=GetFfpeSectionLabelFile';
     175    url += '&ffpeblocklist='+encodeURIComponent(JSON.stringify(ffpeBlockList));
     176    url += '&preview=' + preview;
     177   
     178    if (preview)
     179    {
     180      Doc.hide('previewWrapper');
     181      url += '&preview=1';
     182     
     183      Wizard.showLoadingAnimation('Working...');
     184      Doc.hide('navigation');
     185      Wizard.asyncJsonRequest(url, istat.onPreviewLoaded);
     186    }
     187    else
     188    {
     189      window.location = url;   
     190    }
     191  }
     192
     193  istat.downloadHeGlassLabelFile = function()
     194  {
     195    var frm = document.forms['meludi'];
     196    var ffpeBlockList = istat.getSelectedItemsList();
     197    var preview = false;
     198
     199    var url = '../LabelGeneration.servlet?ID=' + App.getSessionId();
     200    url += '&cmd=GetHeGlassLabelFile';
     201    url += '&ffpeblocklist='+encodeURIComponent(JSON.stringify(ffpeBlockList));
     202    url += '&preview=' + preview;
     203   
     204    if (preview)
     205    {
     206      Doc.hide('previewWrapper');
     207      url += '&preview=1';
     208     
     209      Wizard.showLoadingAnimation('Working...');
     210      Doc.hide('navigation');
     211      Wizard.asyncJsonRequest(url, istat.onPreviewLoaded);
     212    }
     213    else
     214    {
     215      window.location = url;   
     216    }
    161217  }
    162218
  • extensions/net.sf.basedb.meludi/trunk/resources/personal/ffpe_section_order_form.jsp

    r5048 r5069  
    137137    <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" /></td>
    138138    <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" /></td>
    139     <td><base:button id="downloadformbatch2" title="Download form batch file 2" image="<%=home+"/images/download.png"%>" /></td>
     139    <td><base:button id="downloadformbatch2" title="Download FFPE section order form" image="<%=home+"/images/download.png"%>" /></td>
     140    <td><base:button id="downloadffpesectionlabelfile" title="Download FFPE section labels file" image="<%=home+"/images/download.png"%>" /></td>
     141    <td><base:button id="downloadheglasslabelfile" title="Download HE glass labels file" image="<%=home+"/images/download.png"%>" /></td>
    140142  </tr>
    141143  </table>
  • extensions/net.sf.basedb.meludi/trunk/src/net/sf/basedb/meludi/servlet/LabelGenerationServlet.java

    r4876 r5069  
    33import java.io.FileWriter;
    44import java.io.IOException;
     5import java.util.ArrayList;
    56import java.util.Date;
    67import java.util.HashMap;
     8import java.util.List;
    79import java.util.Set;
    810
     
    2123import net.sf.basedb.meludi.JsonUtil;
    2224import net.sf.basedb.meludi.Meludi;
     25import net.sf.basedb.meludi.dao.Annotationtype;
     26import net.sf.basedb.meludi.dao.FfpeBlock;
    2327import net.sf.basedb.meludi.dao.Subtype;
    2428import net.sf.basedb.util.Values;
    2529import net.sf.basedb.util.error.ThrowableUtil;
    2630
     31import org.json.simple.JSONArray;
    2732import org.json.simple.JSONObject;
     33import org.json.simple.parser.JSONParser;
    2834
    2935public class LabelGenerationServlet
     
    186192        }
    187193      }
     194      else if ("GetFfpeSectionLabelFile".equals(cmd))
     195      {
     196        dc = sc.newDbControl();
     197        int activeProjectId = sc.getActiveProjectId();
     198        Project project = Project.getById(dc, activeProjectId);
     199        String sampleItemPrefix = Meludi.fetchSampleItemPrefix(activeProjectId);
     200        String bloodItemPrefix = Meludi.fetchBloodItemPrefix(activeProjectId);
     201        boolean bloodAndSampleItemPrefixesDiffer = Meludi.bloodAndSampleItemPrefixesDiffer(activeProjectId);
     202        String firstPart = "";
     203        String secondPart = "";
     204
     205        boolean preview = Values.getBoolean(req.getParameter("preview"), true);
     206        String jsonFfpeBlockListStr = Values.getString(req.getParameter("ffpeblocklist"), "");
     207        //System.out.println("LabelGenerationServlet::doGet(): cmd = \"" + cmd + "\" jsonFfpeBlockListStr = " + jsonFfpeBlockListStr);
     208        // Get list of extract source item names
     209        List<String> ffpeBlockIdList = new ArrayList<String>();
     210        JSONArray jsonItems = (JSONArray)new JSONParser().parse(jsonFfpeBlockListStr);
     211        //System.out.println("LabelGenerationServlet::doGet(): cmd = \"" + cmd + "\" jsonItems = " + jsonItems);
     212
     213        // Generate label file contents
     214        Integer sampleItemNumDigits = Meludi.fetchSampleItemNumDigits(sc.getActiveProjectId());
     215        String separator = "";
     216
     217        for (int i = 0; i < jsonItems.size(); ++i)
     218        {
     219          JSONObject jsonItem = (JSONObject)jsonItems.get(i);
     220          String itemName = (String)jsonItem.get("name");
     221          ffpeBlockIdList.add(itemName);
     222          firstPart += separator + itemName + ".s";
     223          separator = "\n";
     224        }
     225        String labelString = "LABEL\n" + firstPart + secondPart;
     226       
     227        // Send labels in a file to the client.
     228        resp.setHeader("Content-Disposition", "attachment; filename=FFPE_section_labels.csv");
     229        resp.setContentType("text/plain");
     230        ServletOutputStream os = resp.getOutputStream();
     231        os.print(labelString);         
     232        os.flush();
     233        os.close();
     234      }
     235      else if ("GetHeGlassLabelFile".equals(cmd))
     236      {
     237        dc = sc.newDbControl();
     238        int activeProjectId = sc.getActiveProjectId();
     239        Project project = Project.getById(dc, activeProjectId);
     240        String sampleItemPrefix = Meludi.fetchSampleItemPrefix(activeProjectId);
     241        String bloodItemPrefix = Meludi.fetchBloodItemPrefix(activeProjectId);
     242        boolean bloodAndSampleItemPrefixesDiffer = Meludi.bloodAndSampleItemPrefixesDiffer(activeProjectId);
     243        String firstPart = "";
     244        String secondPart = "";
     245
     246        boolean preview = Values.getBoolean(req.getParameter("preview"), true);
     247        String jsonFfpeBlockListStr = Values.getString(req.getParameter("ffpeblocklist"), "");
     248        //System.out.println("LabelGenerationServlet::doGet(): cmd = \"" + cmd + "\" jsonFfpeBlockListStr = " + jsonFfpeBlockListStr);
     249        // Get list of extract source item names
     250        List<String> ffpeBlockIdList = new ArrayList<String>();
     251        JSONArray jsonItems = (JSONArray)new JSONParser().parse(jsonFfpeBlockListStr);
     252        //System.out.println("LabelGenerationServlet::doGet(): cmd = \"" + cmd + "\" jsonItems = " + jsonItems);
     253
     254        // Generate label file contents
     255        Integer sampleItemNumDigits = Meludi.fetchSampleItemNumDigits(sc.getActiveProjectId());
     256        String separator = "";
     257
     258        for (int i = 0; i < jsonItems.size(); ++i)
     259        {
     260          JSONObject jsonItem = (JSONObject)jsonItems.get(i);
     261          String itemName = (String)jsonItem.get("name");
     262          ffpeBlockIdList.add(itemName);
     263          firstPart += separator + itemName + ".he-F";
     264          separator = "\n";
     265          firstPart += separator + itemName + ".he-E";
     266        }
     267        String labelString = "LABEL\n" + firstPart + secondPart;
     268       
     269        // Send labels in a file to the client.
     270        resp.setHeader("Content-Disposition", "attachment; filename=HE_glass_labels.csv");
     271        resp.setContentType("text/plain");
     272        ServletOutputStream os = resp.getOutputStream();
     273        os.print(labelString);         
     274        os.flush();
     275        os.close();
     276      }
    188277    }
    189278    catch (Throwable t)
Note: See TracChangeset for help on using the changeset viewer.