Changeset 3904


Ignore:
Timestamp:
Oct 20, 2010, 4:47:19 PM (13 years ago)
Author:
olle
Message:

Refs #700. Refs #287. First version of support for simple search form
for X!Tandem searches:

  1. Class/file action/xTandemInput/ViewActiveXTandemParameterSetStorage.java

in client/servlet/ updated to support both a simple and an advanced X!Tandem search form:

  1. New public static valid parameter VBoolean VXTANDEMPARAMETERSETSIMPLEFORMFLAG

added. It is used to store a flag indicating if a simple form is desired.

  1. Public method void runMe() updated to retrieve the value of new valid

parameter VBoolean VXTANDEMPARAMETERSETSIMPLEFORMFLAG and set a flag variable useSimpleForm indicating if a simple form is desired. If the value of the valid parameter is null, the latter variable is set to true, as a simple form is the default. Since the value of the new valid parameter only is null the first time the action is entered for the form, the value is also used to set a boolean flag variable firstEntry. If a simple form is to be used, form class XTandemParameterSetFormSimple is used,
otherwise class XTandemParameterSetForm.
The first time the action is entered for a form X!Tandem data is read
from the database, otherwise it is retrieved from data supplied with the form. In this case, one of two new methods named updateAdvancedFormMultipleChoiceFields(...)
is called to update the multiple choice data in the current form.
A new button is added to toggle the form type between simple and advanced. This button sets the value of valid parameter VXTANDEMPARAMETERSETSIMPLEFORMFLAG to force a change of form type when the action is re-entered.

  1. New private method

XTandemParameterSetForm updateAdvancedFormMultipleChoiceFields(XTandemParameterSetForm form)
added. It updates advanced form multiple choice fields.

  1. New private method

XTandemParameterSetFormSimple updateAdvancedFormMultipleChoiceFields(XTandemParameterSetFormSimple form)
added. It updates simple form multiple choice fields.

  1. New private convenience method

List<String> fetchValidStringList(String quantityName, VString param)
added. It fetches a string list from for a VString valid parameter from the HTTP request.

  1. English dictionary file locale/en/dictionary in client/servlet/

updated with new entries for various string keys.

Location:
trunk/client/servlet/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/locale/en/dictionary

    r3892 r3904  
    5151Address=Address
    5252Administrator=Administrator
     53AdvancedSearchForm=Advanced Search Form
    5354All=All
    5455AllowedFDR=Allowed FDR
     
    770771Show=Show
    771772SignalToNoiseRatio=S/N
     773SimpleSearchForm=Simple Search Form
    772774SizeInBytes=Size (bytes)
    773775Size=Size
  • trunk/client/servlet/src/org/proteios/action/xTandemInput/ViewActiveXTandemParameterSetStorage.java

    r3881 r3904  
    4242import org.proteios.io.XTandemParameterFileUtil;
    4343import org.proteios.io.XTandemParameterSet;
    44 //import org.proteios.io.XTandemParameterSetOptionsUtil;
    4544import se.lu.thep.waf.ActionException;
    4645import se.lu.thep.waf.constraints.InvalidParameterValue;
     46import se.lu.thep.waf.constraints.VBoolean;
    4747import se.lu.thep.waf.constraints.VInteger;
     48import se.lu.thep.waf.constraints.VString;
    4849
    4950/**
     
    5556  public static final VInteger VXTANDEMPARAMETERSETSTORAGEID = new VInteger(
    5657    "active.xtandemparametersetstorage.id", 1, false);
     58  public static final VBoolean VXTANDEMPARAMETERSETSIMPLEFORMFLAG = new VBoolean(
     59    "active.xtandemparametersetstoragesimpleformflag", false);
    5760
    5861
     
    8588    List<Integer> spectrumFileIds = getValidIntegerList(SearchXTandem.VSPECTRUMFILEID);
    8689    log.debug("spectrumFileIds = " + spectrumFileIds);
     90    // Get the useSimpleForm flag
     91    Boolean useSimpleForm = getValidBoolean(VXTANDEMPARAMETERSETSIMPLEFORMFLAG);
     92    log.debug("useSimpleForm from VXTANDEMPARAMETERSETSIMPLEFORMFLAG = " + useSimpleForm);
     93    boolean firstEntry = false;
     94    if (useSimpleForm == null)
     95    {
     96      // Default form type is simple form
     97      useSimpleForm = true;
     98      firstEntry = true;
     99    }
     100    log.debug("useSimpleForm = " + useSimpleForm);
     101    log.debug("firstEntry = " + firstEntry);
    87102    //
    88103    DbControl dc = newDbControl();
     
    94109    xTandemParameterFileUtil.setXMLInputStream(iStream);
    95110    XTandemParameterSet xTandemParameterSet = xTandemParameterFileUtil.fetchXTandemParameterSet();
    96     Form xTandemParameterSetForm = new XTandemParameterSetForm(xTandemParameterSet);
     111    // Get X!Tandem parameter set display form
     112    Form xTandemParameterSetDisplayForm;
     113    if (useSimpleForm)
     114    {
     115      log.debug("### Simple X!Tandem Parameter Set Form");
     116      // Use simple X!Tandem parameter set form
     117      if (firstEntry)
     118      {
     119        // Fill in form fields with data from stored X!Tandem parameter set
     120        Form xTandemParameterSetFormSimple = new XTandemParameterSetFormSimple(xTandemParameterSet);
     121        xTandemParameterSetDisplayForm = xTandemParameterSetFormSimple;
     122      }
     123      else
     124      {
     125        // Fill in form fields with data from previously displayed simple/advanced form
     126        Form xTandemParameterSetFormSimple = new XTandemParameterSetFormSimple();
     127        populateForm(xTandemParameterSetFormSimple);
     128        xTandemParameterSetFormSimple = updateSimpleFormMultipleChoiceFields((XTandemParameterSetFormSimple) xTandemParameterSetFormSimple);
     129        xTandemParameterSetDisplayForm = xTandemParameterSetFormSimple;
     130      }
     131    }
     132    else
     133    {
     134      log.debug("### Advanced X!Tandem Parameter Set Form");
     135      // Use advanced X!Tandem parameter set form
     136      if (firstEntry)
     137      {
     138        // Fill in form fields with data from stored X!Tandem parameter set       
     139        Form xTandemParameterSetForm = new XTandemParameterSetForm(xTandemParameterSet);
     140        xTandemParameterSetDisplayForm = xTandemParameterSetForm;
     141      }
     142      else
     143      {
     144        // Fill in form fields with data from previously displayed simple/advanced form
     145        Form xTandemParameterSetForm = new XTandemParameterSetForm();
     146        populateForm(xTandemParameterSetForm);
     147        xTandemParameterSetForm = updateAdvancedFormMultipleChoiceFields((XTandemParameterSetForm) xTandemParameterSetForm);
     148        xTandemParameterSetDisplayForm = xTandemParameterSetForm;
     149      }
     150    }
    97151    /***********************************************************************
    98152     * Annotations table
     
    139193      for (Integer spectrumFileId : spectrumFileIds)
    140194      {
    141         getFormFactory().addHiddenField(xTandemParameterSetForm, SearchXTandem.VSPECTRUMFILEID, spectrumFileId);
     195        getFormFactory().addHiddenField(xTandemParameterSetDisplayForm, SearchXTandem.VSPECTRUMFILEID, spectrumFileId);
    142196      }
    143197      searchXTandemViaWebInterface.addParameter(SearchXTandem.VXTANDEMUSEWEBINTERFACEFLAG, true);
     
    169223      */
    170224    }
    171     xTandemParameterSetForm.setToolbar(toolbar);
     225    // Add button to toggle between simple/advanced form
     226    String toggleFormTypeButtonLabel;
     227    if (useSimpleForm)
     228    {
     229      toggleFormTypeButtonLabel = new String("AdvancedSearchForm");
     230    }
     231    else
     232    {
     233      toggleFormTypeButtonLabel = new String("SimpleSearchForm");
     234    }
     235    ActionLink toggleFormTypeButton = getActionLink(ViewActiveXTandemParameterSetStorage.class, toggleFormTypeButtonLabel);
     236    toggleFormTypeButton.addParameter(VXTANDEMPARAMETERSETSIMPLEFORMFLAG, !useSimpleForm);
     237    toggleFormTypeButton.addParameter(VXTANDEMPARAMETERSETSTORAGEID, xtpssId);
     238    toolbar.add(toggleFormTypeButton);
     239    // Add tool bar
     240    xTandemParameterSetDisplayForm.setToolbar(toolbar);
    172241    /***********************************************************************
    173242     * Layout
     
    183252    ts.add(annotations);
    184253    */
    185     layout.add(xTandemParameterSetForm);
     254    layout.add(xTandemParameterSetDisplayForm);
    186255    setLayout(layout);
    187256  }
     257
     258
     259  /**
     260   * Update advanced form multiple choice fields.
     261   *
     262   * @param form XTandemParameterSetForm An advanced X!Tandem parameter set form.
     263   * @return XTandemParameterSetForm The updated form.
     264   */
     265  private XTandemParameterSetForm updateAdvancedFormMultipleChoiceFields(XTandemParameterSetForm form)
     266  {
     267    List<String> stringList;
     268    // Residue potential modification mass
     269    stringList = fetchValidStringList("residue potential modification mass",
     270      XTandemParameterSetForm.VXTANDEM_RESIDUE_POTENTIAL_MODIFICATION_MASS_SELECT);
     271    if (stringList != null)
     272    {
     273      form.residuePotentialModificationMassSB.selectOptions(stringList);
     274    }
     275    // Protein taxon Eukaryotes
     276    stringList = fetchValidStringList("protein taxon Eukaryotes",
     277      XTandemParameterSetForm.VXTANDEM_PROTEIN_TAXON);
     278    if (stringList != null)
     279    {
     280      form.taxonSB.selectOptions(stringList);
     281    }
     282    // Protein taxon Prokaryotes
     283    stringList = fetchValidStringList("protein taxon Prokaryotes",
     284      XTandemParameterSetForm.VXTANDEM_PROTEIN_TAXON1);
     285    if (stringList != null)
     286    {
     287      form.taxon1SB.selectOptions(stringList);
     288    }
     289    // Refine potential modification mass
     290    List<Option> startList = form.refinePotentialModificationMassSB.getOptions();
     291    if (startList != null)
     292    {
     293      log.debug("Start - refine potential modification mass select list size: " + startList.size());     
     294      for (Option opt: startList)
     295      {
     296        if (opt.isSelected())
     297        {
     298          log.debug("Start - refine potential modification mass selected: \"" + opt.getValue() + "\" content: \"" + opt.getValue() + "\"");
     299        }
     300      }
     301    }
     302    stringList = fetchValidStringList("refine potential modification mass",
     303      XTandemParameterSetForm.VXTANDEM_REFINE_POTENTIAL_MODIFICATION_MASS_SELECT);
     304    log.debug("refine potential modification mass select list = " + stringList);
     305    if (stringList != null)
     306    {
     307      log.debug("refine potential modification mass select field list size = " + stringList.size());
     308      form.refinePotentialModificationMassSB.selectOptions(stringList);
     309    }
     310    return form;
     311  }
     312
     313
     314  /**
     315   * Update simple form multiple choice fields.
     316   *
     317   * @param form XTandemParameterSetFormSimple A simple X!Tandem parameter set form.
     318   * @return XTandemParameterSetFormSimple The updated form.
     319   */
     320  private XTandemParameterSetFormSimple updateSimpleFormMultipleChoiceFields(XTandemParameterSetFormSimple form)
     321  {
     322    List<String> stringList;
     323    // Residue potential modification mass
     324    stringList = fetchValidStringList("residue potential modification mass",
     325      XTandemParameterSetForm.VXTANDEM_RESIDUE_POTENTIAL_MODIFICATION_MASS_SELECT);
     326    if (stringList != null)
     327    {
     328      form.residuePotentialModificationMassSB.selectOptions(stringList);
     329    }
     330    // Protein taxon Eukaryotes
     331    stringList = fetchValidStringList("protein taxon Eukaryotes",
     332      XTandemParameterSetForm.VXTANDEM_PROTEIN_TAXON);
     333    if (stringList != null)
     334    {
     335      form.taxonSB.selectOptions(stringList);
     336    }
     337    // Protein taxon Prokaryotes
     338    stringList = fetchValidStringList("protein taxon Prokaryotes",
     339      XTandemParameterSetForm.VXTANDEM_PROTEIN_TAXON1);
     340    if (stringList != null)
     341    {
     342      form.taxon1SB.selectOptions(stringList);
     343    }
     344    // Refine potential modification mass
     345    stringList = fetchValidStringList("refine potential modification mass",
     346      XTandemParameterSetForm.VXTANDEM_REFINE_POTENTIAL_MODIFICATION_MASS_SELECT);
     347    log.debug("refine potential modification mass select list = " + stringList);
     348    if (stringList != null)
     349    {
     350      form.refinePotentialModificationMassSB.selectOptions(stringList);
     351    }
     352    return form;
     353  }
     354
     355
     356  /**
     357   * Convenience method for fetching string list from request.
     358   *
     359   * @param quantityName String Name of the list quantity.
     360   * @param param VString Valid parameter coupled to the list.
     361   * @return List<String> The string list obtained from the request.
     362   */
     363  private List<String> fetchValidStringList(String quantityName, VString param)
     364  {
     365    // Fetch string list from request
     366    List<String> stringList = null;
     367    try
     368    {
     369      stringList = getValidStringList(param);
     370      log.debug(quantityName + " = " + stringList);
     371    }
     372    catch (InvalidParameterValue e)
     373    {
     374      log.debug("InvalidParameterValue when trying to obtain " + quantityName);
     375    }
     376    return stringList;
     377  }
    188378}
Note: See TracChangeset for help on using the changeset viewer.