Changeset 3781


Ignore:
Timestamp:
Aug 23, 2010, 8:08:16 AM (13 years ago)
Author:
Gregory Vincic
Message:

Refactored and commented on ViewFeatureHits?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/feature/ViewFeatureHits.java

    r3777 r3781  
    4747
    4848/**
    49  * List subhits for a combined hit
    5049 *
    51  * @author fredrik
     50 * @author fredrik, gregory
    5251 */
    5352public class ViewFeatureHits
     
    5857      throws ActionException, InvalidParameterValue
    5958  {
    60     /*
    61      * Get hit id from valid parameter and set it as session attribute.
    62      */
    63     Integer featureId = getValidInteger(FormFactory.VID);
    64     log.debug("featureId = " + featureId);
    65     /***********************************************************************
    66      * Get external id data
    67      */
    68     // Define
     59  Integer featureId;
    6960    Table tbl;
    7061    RowLayout layout;
    7162    Title title;
     63  DbControl dc;
     64  ItemFactory factory;
     65  Feature feature;
     66  List<Hit> hits;
     67
     68    featureId = getValidInteger(FormFactory.VID);
     69    log.debug("featureId = " + featureId);
    7270    tbl = (Table) getRequest().getAttribute("table");
    7371    if (tbl == null)
    7472    {
    75       // Let ConfigureTableFactory2 action create the table for us
    76       setAttribute(ConfigureTableFactory2.VWRAPPERCLASS, Hit.class
    77         .getName());
    78       setAttribute(ConfigureTableFactory2.VDATACLASS, HitData.class
    79         .getName());
    80       setAttribute(ConfigureTableFactory2.VFORWARDTO,
    81         ViewFeatureHits.class.getName());
     73      // Use ConfigureTableFactory2 to configure TableFactory2
     74      setAttribute(ConfigureTableFactory2.VWRAPPERCLASS, Hit.class.getName());
     75      setAttribute(ConfigureTableFactory2.VDATACLASS, HitData.class.getName());
     76      setAttribute(ConfigureTableFactory2.VFORWARDTO, ViewFeatureHits.class.getName());
    8277      setAttribute(ConfigureTableFactory2.VONLYINPROJECT, true);
    8378      setAttribute(ConfigureTableFactory2.VUSEDEFAULT, false);
    8479      setForwardTo(ConfigureTableFactory2.class);
     80   return; // Stop here
    8581    }
    86     else
    87     {
    88       DbControl dc = newDbControl();
    89       ItemFactory factory = getItemFactory(dc);
    90       Feature feature = factory.getById(Feature.class, featureId);
    91       List<Hit> hits = new ArrayList<Hit>();
    92       hits.addAll(feature.getHits());
    93       getTableFactory2().setIterator(hits.iterator());
    94       tbl = getTableFactory2().build();
    95       tbl.setTitle("Hit");
    96       title = new Title("Hits matching feature (feature m/z:" + feature
    97         .getMassToChargeRatio() + ", apex RT:" + feature
    98         .getApexRetentionTimeInMinutes() + ")");
    99       layout = getLayoutFactory().getRowLayout();
    100       layout.add(title);
    101       layout.add(tbl);
    102       setLayout(layout);
    103     }
     82
     83    dc = newDbControl();
     84    factory = getItemFactory(dc);
     85    feature = factory.getById(Feature.class, featureId);
     86    hits = new ArrayList<Hit>();
     87    hits.addAll(feature.getHits());
     88
     89  // Use the preconfigured TableFactory2 to build a new table for us
     90    getTableFactory2().setIterator(hits.iterator());
     91    tbl = getTableFactory2().build();
     92
     93    tbl.setTitle("Hit");
     94    title = new Title("Hits matching feature (feature m/z:" + feature
     95      .getMassToChargeRatio() + ", apex RT:" + feature
     96      .getApexRetentionTimeInMinutes() + ")");
     97    layout = getLayoutFactory().getRowLayout();
     98    layout.add(title);
     99    layout.add(tbl);
     100    setLayout(layout);
    104101  }
    105102}
Note: See TracChangeset for help on using the changeset viewer.