Changeset 4098


Ignore:
Timestamp:
Jan 21, 2011, 3:55:29 PM (12 years ago)
Author:
olle
Message:

Refs #730. Refs #535. Class/file action/hit/CreateHitsComparisonReportJob.java in client/servlet/ updated to check that at least one gel id or local sample id is selected for each hit selection, and otherwise return to the selection page and display an error message:

  1. Protected method void runMe() updated to call new private convenience method boolean stringListHasNonTrivialItem(List<String> stringList) to check that at least one gel id or local sample id is selected for each hit selection, and otherwise return to the selection page and display an error message.
  1. New private convenience method boolean stringListHasNonTrivialItem(List<String> stringList) added. It returns true if the list is not null, and contains at least one item that is not null or an empty string, otherwise false is returned.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/hit/CreateHitsComparisonReportJob.java

    r4006 r4098  
    105105        String comparisonType = getValidString(HitsComparisonReport.VHITSCOMPARISONTYPE);
    106106       
     107        // Check that at least one gel external id or local sample id has been selected
     108        log.debug("hitSelection1GelExtIdList = " + hitSelection1GelExtIdList);
     109        log.debug("hitSelection1LocalSampleIdList = " + hitSelection1LocalSampleIdList);
     110        log.debug("hitSelection2GelExtIdList = " + hitSelection2GelExtIdList);
     111        log.debug("hitSelection2LocalSampleIdList = " + hitSelection2LocalSampleIdList);
     112        boolean hitSelection1GelSelected = stringListHasNonTrivialItem(hitSelection1GelExtIdList);
     113        boolean hitSelection1LocalSampleIdSelected = stringListHasNonTrivialItem(hitSelection1LocalSampleIdList);
     114        boolean hitSelection2GelSelected = stringListHasNonTrivialItem(hitSelection2GelExtIdList);
     115        boolean hitSelection2LocalSampleIdSelected = stringListHasNonTrivialItem(hitSelection2LocalSampleIdList);
     116        log.debug("hitSelection1GelSelected = " + hitSelection1GelSelected);
     117        log.debug("hitSelection1LocalSampleIdSelected = " + hitSelection1LocalSampleIdSelected);
     118        log.debug("hitSelection2GelSelected = " + hitSelection2GelSelected);
     119        log.debug("hitSelection2LocalSampleIdSelected = " + hitSelection2LocalSampleIdSelected);
     120        if ((!hitSelection1GelSelected && !hitSelection1LocalSampleIdSelected) ||
     121          (!hitSelection2GelSelected && !hitSelection2LocalSampleIdSelected))
     122        {
     123          setError("Select at least one gel id or local sample id for each hit selection");
     124          return;
     125        }
    107126        //
    108127        Boolean ignoreFdrCutoff = getValidBoolean(HitsComparisonReport.VIGNORECOMBINEDFDRUPPERCUTOFF);
     
    346365    }
    347366   
     367
     368    /**
     369     * Checks if a string list has any item that
     370     * is not null or an empty string.
     371     *
     372     * @param stringList List<String> The string list to check.
     373     * @return boolean Returns true if any non-trivial item is found, else false.
     374     */
     375    private boolean stringListHasNonTrivialItem(List<String> stringList)
     376    {
     377      boolean hasNonTrivialItem = false;
     378      if (stringList != null)
     379      {
     380        for (String item: stringList)
     381        {
     382          if (item != null && !item.equals(""))
     383          {
     384            hasNonTrivialItem = true;
     385            break;
     386          }
     387        }
     388      }
     389      return hasNonTrivialItem;
     390    }
     391
     392
    348393    /**
    349394        * Fetch localizer key string list.
Note: See TracChangeset for help on using the changeset viewer.