Changeset 4977


Ignore:
Timestamp:
Sep 24, 2018, 9:37:40 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #1054: Even more functionality in the Flagged alignment wizard

Messages are registration now reports number of specimen, lysates, rna and libraries instead of total number. Also fixed so that messages are correct for "one" and "multiple" items.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/GenotypeServlet.java

    r4975 r4977  
    429429        if (numChecked > 0)
    430430        {
    431           jsonMessages.add(0, numChecked + " alignments have been checked and will be used for future genotype QC comparisons.");
     431          jsonMessages.add(0, countMessage(numChecked, "alignment has", "alignments have") + " been checked and will be used for future genotype QC comparisons.");
    432432        }
    433433        dc.commit();
     
    478478          }
    479479        }
    480         if (numReProcess > 0) jsonMessages.add(numReProcess + " items has been scheduled for re-processing");
    481         if (numFlagged > 0) jsonMessages.add(numFlagged + " alignments have been flagged");
    482         if (numComments > 0) jsonMessages.add(numComments + " comments have been updated");
     480        if (numReProcess > 0) jsonMessages.add(countMessage(numReProcess, "item has", "items have") + " been scheduled for re-processing");
     481        if (numFlagged > 0) jsonMessages.add(countMessage(numFlagged, "alignment has", "alignments have") + " been flagged");
     482        if (numComments > 0) jsonMessages.add(countMessage(numComments, "comment has", "comments have") + " been updated");
    483483        dc.commit();
    484484       
     
    500500        ItemSubtype mergedType = Subtype.MERGED_SEQUENCES.get(dc);
    501501        ItemSubtype alignedType = Subtype.ALIGNED_SEQUENCES.get(dc);
     502        ItemSubtype specimenType = Subtype.SPECIMEN.get(dc);
     503        ItemSubtype lysateType = Subtype.LYSATE.get(dc);
     504        ItemSubtype rnaType = Subtype.RNA.get(dc);
     505        ItemSubtype libraryType = Subtype.LIBRARY.get(dc);
    502506        ItemList flaggedAlignments = BiomaterialList.FLAGGED_ALIGNMENT.get(dc);
    503507       
     
    506510        checker.preloadSpecimenData(dc);
    507511
     512        // Items marked with DoNotUse - total and per item type
    508513        int numRootDoNotUse = 0;
     514        int numSpecimen = 0;
     515        int numLysate = 0;
     516        int numRna = 0;
     517        int numLibrary = 0;
     518       
    509519        int numTotalDoNotUse = 0;
    510520        int numUnflagged = 0;
     
    562572              jsonDebug.add("[Debug]Do not use: " + basicItem + " ["+doNotUse+"]");
    563573              numTotalDoNotUse++;
    564               if (basicItem == rootItem) numRootDoNotUse++;
     574              if (basicItem == rootItem)
     575              {
     576                numRootDoNotUse++;
     577                if (specimenType.equals(subtype)) numSpecimen++;
     578                else if (lysateType.equals(subtype)) numLysate++;
     579                else if (rnaType.equals(subtype)) numRna++;
     580                else if (libraryType.equals(subtype)) numLibrary++;
     581              }
    565582            }
    566583           
     
    639656        if (numRootDoNotUse > 0)
    640657        {
    641           jsonMessages.add(numRootDoNotUse + " main items and " + (numTotalDoNotUse-numRootDoNotUse) + " related items marked as DoNotUse.");
     658          StringBuilder msg = new StringBuilder();
     659          if (numSpecimen > 0)
     660          {
     661            msg.append(countMessage(numSpecimen, "specimen", "specimens"));
     662          }
     663          if (numLysate > 0)
     664          {
     665            if (msg.length() > 0) msg.append(", ");
     666            msg.append(countMessage(numLysate, "lysate", "lysates"));
     667          }
     668          if (numRna > 0)
     669          {
     670            if (msg.length() > 0) msg.append(", ");
     671            msg.append(countMessage(numRna, "RNA", "RNA"));
     672          }
     673          if (numLibrary > 0)
     674          {
     675            if (msg.length() > 0) msg.append(", ");
     676            msg.append(countMessage(numLibrary, "library", "libraries"));
     677          }
     678          jsonMessages.add(msg + " and " + countMessage(numTotalDoNotUse-numRootDoNotUse, "related item", "related items") + " marked as DoNotUse.");
    642679        }
    643680       
    644681        if (numDisabled > 0)
    645682        {
    646           jsonMessages.add(numDisabled + " alignments have been disabled for future genotype checks.");
     683          jsonMessages.add(countMessage(numDisabled, "alignment has", "alignments have") + " been disabled for future genotype checks.");
    647684        }
    648685
    649686        if (numOkToUse > 0)
    650687        {
    651           jsonMessages.add(numOkToUse + " alignments are ok to use.");
     688          jsonMessages.add(countMessage(numOkToUse, "alignment is", "alignments are") + " ok to use.");
    652689        }
    653690       
    654691        if (numAutoUnflagged > 0)
    655692        {
    656           jsonMessages.add(numAutoUnflagged + " related alignments have been automatically unflagged.");
     693          jsonMessages.add(countMessage(numAutoUnflagged, "related alignment has", "related alignments have") + " been automatically unflagged.");
    657694        }
    658695       
     
    958995  }
    959996
     997  private String countMessage(int count, String one, String more)
     998  {
     999    return count + " " + (count > 1 ? more : one);
     1000  }
     1001 
    9601002}
Note: See TracChangeset for help on using the changeset viewer.