[jboss-cvs] jboss-seam/examples/dvdstore/src/com/jboss/dvd/seam ...

Norman Richards norman.richards at jboss.com
Sat Jul 14 22:49:31 EDT 2007


  User: nrichards
  Date: 07/07/14 22:49:31

  Modified:    examples/dvdstore/src/com/jboss/dvd/seam 
                        FullTextSearchAction.java
  Log:
  more cleanup
  
  Revision  Changes    Path
  1.5       +163 -201  jboss-seam/examples/dvdstore/src/com/jboss/dvd/seam/FullTextSearchAction.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FullTextSearchAction.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/dvdstore/src/com/jboss/dvd/seam/FullTextSearchAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- FullTextSearchAction.java	15 Jul 2007 02:21:31 -0000	1.4
  +++ FullTextSearchAction.java	15 Jul 2007 02:49:31 -0000	1.5
  @@ -1,4 +1,4 @@
  -//$Id: FullTextSearchAction.java,v 1.4 2007/07/15 02:21:31 nrichards Exp $
  +//$Id: FullTextSearchAction.java,v 1.5 2007/07/15 02:49:31 nrichards Exp $
   package com.jboss.dvd.seam;
   
   import java.io.Serializable;
  @@ -51,7 +51,6 @@
      @RequestParameter
      Long id;
   
  -   //Category category;
      int pageSize = 15;
      int currentPage = 0;
      boolean hasMore = false;
  @@ -72,80 +71,65 @@
      Map<Product, Boolean> searchSelections;
   
   
  -   public String getSearchQuery()
  -   {
  +    public String getSearchQuery() {
         return searchQuery;
      }
   
  -   public void setSearchQuery(String searchQuery)
  -   {
  +    public void setSearchQuery(String searchQuery) {
         this.searchQuery = searchQuery;
      }
   
   
  -   public int getNumberOfResults()
  -   {
  +    public int getNumberOfResults() {
         return numberOfResults;
      }
   
      @Begin(join = true)
  -   public String doSearch()
  -   {
  +    public String doSearch() {
         currentPage = 0;
         updateResults();
   
         return "browse";
      }
   
  -   public void nextPage()
  -   {
  -      if (!isLastPage())
  -      {
  +    public void nextPage() {
  +        if (!isLastPage()) {
            currentPage++;
            updateResults();
         }
      }
   
  -   public void prevPage()
  -   {
  -      if (!isFirstPage())
  -      {
  +    public void prevPage() {
  +        if (!isFirstPage()) {
            currentPage--;
            updateResults();
         }
      }
   
      @Begin(join = true)
  -   public void selectFromRequest()
  -   {
  -      if (id != null)
  -      {
  +    public void selectFromRequest() {
  +        if (id != null)  {
            dvd = em.find(Product.class, id);
  -      }
  -      else if (selectedProduct != null)
  -      {
  +        } else if (selectedProduct != null) {
            dvd = selectedProduct;
         }
      }
   
  -   public boolean isLastPage()
  -   {
  +    public boolean isLastPage() {
         return ( searchResults != null ) && !hasMore;
      }
   
  -   public boolean isFirstPage()
  -   {
  +    public boolean isFirstPage() {
         return ( searchResults != null ) && ( currentPage == 0 );
      }
   
  -   private void updateResults()
  -   {
  +    private void updateResults() {
         FullTextQuery query;
  -      try
  -      {
  +        try {
            query = searchQuery(searchQuery);
  +        } catch (ParseException pe) { 
  +            return; 
         }
  -      catch (ParseException pe) { return; }
         
         List<Product> items = query
               .setMaxResults(pageSize + 1)
  @@ -153,13 +137,10 @@
               .list();
         numberOfResults = query.getResultSize();
   
  -      if (items.size() > pageSize)
  -      {
  +        if (items.size() > pageSize) {
            searchResults = new ArrayList(items.subList(0, pageSize));
            hasMore = true;
  -      }
  -      else
  -      {
  +        } else {
            searchResults = items;
            hasMore = false;
         }
  @@ -170,10 +151,11 @@
      private FullTextQuery searchQuery(String searchQuery) throws ParseException
      {
         Map<String,Float> boostPerField = new HashMap<String,Float>();
  -      boostPerField.put( "title", 4f );
  -      boostPerField.put( "description", 2f );
  -      boostPerField.put( "actors.name", 2f );
  -      boostPerField.put( "categories.name", 0.5f );
  +        boostPerField.put("title", 4f);
  +        boostPerField.put("description", 2f);
  +        boostPerField.put("actors.name", 2f);
  +        boostPerField.put("categories.name", 0.5f);
  +
         String[] productFields = {"title", "description", "actors.name", "categories.name"};
         QueryParser parser = new MultiFieldQueryParser(productFields, new StandardAnalyzer(), boostPerField);
         parser.setAllowLeadingWildcard(true);
  @@ -182,8 +164,7 @@
         return getFullTextSession().createFullTextQuery(luceneQuery, Product.class);
      }
   
  -   private FullTextSession getFullTextSession()
  -   {
  +    private FullTextSession getFullTextSession() {
         return (FullTextSession) em.getDelegate();
      }
   
  @@ -200,46 +181,27 @@
       */
      public void addAllToCart()
      {
  -      for (Product item : searchResults)
  -      {
  +        for (Product item : searchResults) {
            Boolean selected = searchSelections.get(item);
  -         if (selected != null && selected)
  -         {
  +            if (selected != null && selected) {
               searchSelections.put(item, false);
               cart.addProduct(item, 1);
            }
         }
      }
   
  -   /*public void setCategory(Category category) 
  -   {
  -      this.category = category; 
  -   }
  -   
  -   public Category getCategory() 
  -   {
  -      return category;
  -   }*/
  -
  -   public int getPageSize()
  -   {
  +    public int getPageSize() {
         return pageSize;
      }
   
  -   public void setPageSize(int pageSize)
  -   {
  +    public void setPageSize(int pageSize) {
         this.pageSize = pageSize;
      }
   
      @End
  -   public void reset()
  -   {
  -   }
  +    public void reset() { }
   
      @Destroy
      @Remove
  -   public void destroy()
  -   {
  -   }
  -
  +    public void destroy() { }
   }
  
  
  



More information about the jboss-cvs-commits mailing list