[jboss-cvs] jboss-seam/src/main/org/jboss/seam/framework ...

Peter Muir peter at bleepbleep.org.uk
Fri Sep 28 09:54:37 EDT 2007


  User: pmuir   
  Date: 07/09/28 09:54:36

  Modified:    src/main/org/jboss/seam/framework   Query.java
                        EntityQuery.java
  Log:
  Some Javadoc for framework queries
  
  Revision  Changes    Path
  1.36      +80 -1     jboss-seam/src/main/org/jboss/seam/framework/Query.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Query.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Query.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -b -r1.35 -r1.36
  --- Query.java	20 Jul 2007 07:56:34 -0000	1.35
  +++ Query.java	28 Sep 2007 13:54:36 -0000	1.36
  @@ -59,6 +59,12 @@
         }
      }
      
  +   /**
  +    * Wrap the result set in a JSF {@link DataModel}
  +    * 
  +    * Delegates to {@link DataModels#getDataModel(Query)}
  +    * 
  +    */
      @Transactional
      public DataModel getDataModel()
      {
  @@ -69,37 +75,62 @@
         return dataModel;
      }
      
  +   /**
  +    * Get the selected row of the JSF {@link DataModel}
  +    * 
  +    */
      public Object getDataModelSelection()
      {
         return getDataModel().getRowData();
      }
      
  +   /**
  +    * Get the index of the selected row of the JSF {@link DataModel}
  +    * 
  +    */
      public int getDataModelSelectionIndex()
      {
         return getDataModel().getRowIndex();
      }
      
  +   
      public void refresh()
      {
         clearDataModel();
      }
      
  +   /**
  +    * Move the result set cursor to the beginning of the last page
  +    * 
  +    */
      @Transactional
      public void last()
      {
         setFirstResult( getLastFirstResult().intValue() );
      }
      
  +   /**
  +    * Move the result set cursor to the beginning of the next page
  +    * 
  +    */
      public void next()
      {
         setFirstResult( getNextFirstResult() );
      }
   
  +   /**
  +    * Move the result set cursor to the beginning of the previous page
  +    * 
  +    */
      public void previous()
      {
         setFirstResult( getPreviousFirstResult() );
      }
      
  +   /**
  +    * Move the result set cursor to the beginning of the first page
  +    * 
  +    */
      public void first()
      {
         setFirstResult(0);
  @@ -110,6 +141,10 @@
         dataModel = null;
      }
   
  +   /**
  +    * Get the index of the first result of the last page
  +    * 
  +    */
      @Transactional
      public Long getLastFirstResult()
      {
  @@ -117,12 +152,20 @@
         return pc==null ? null : ( pc.longValue()-1 ) * getMaxResults();
      }
      
  +   /**
  +    * Get the index of the first result of the next page
  +    * 
  +    */
      public int getNextFirstResult()
      {
         Integer fr = getFirstResult();
         return ( fr==null ? 0 : fr ) + getMaxResults();
      }
   
  +   /**
  +    * Get the index of the first result of the previous page
  +    * 
  +    */
      public int getPreviousFirstResult()
      {
         Integer fr = getFirstResult();
  @@ -131,6 +174,10 @@
                  0 : fr - mr;
      }
      
  +   /**
  +    * Get the total number of pages
  +    * 
  +    */
      @Transactional
      public Integer getPageCount()
      {
  @@ -226,6 +273,10 @@
         return ejbql;
      }
   
  +   /**
  +    * Set the ejbql to use.  Calling this causes the ejbql to be reparsed and
  +    * the query to be refreshed
  +    */
      public void setEjbql(String ejbql)
      {
         this.ejbql = ejbql;
  @@ -233,24 +284,39 @@
         refresh();
      }
   
  +   /**
  +    * Returns the index of the first result of the current page
  +    */
      public Integer getFirstResult()
      {
         return firstResult;
      }
      
  +   /**
  +    * Returns true if the previous page exists
  +    */
      public boolean isPreviousExists()
      {
         return getFirstResult()!=null && getFirstResult()!=0;
      }
   
  +   /**
  +    * Returns true if next page exists
  +    */
      public abstract boolean isNextExists();
   
  +   /**
  +    * Set the index at which the page to display should start
  +    */
      public void setFirstResult(Integer firstResult)
      {
         this.firstResult = firstResult;
         refresh();
      }
   
  +   /**
  +    * The page size
  +    */
      public Integer getMaxResults()
      {
         return maxResults;
  @@ -262,11 +328,21 @@
         refresh();
      }
   
  +   /**
  +    * List of restrictions to apply to the query.
  +    * 
  +    * For a query such as 'from Foo f' a restriction could be 
  +    * 'f.bar = #{foo.bar}'
  +    */
      public List<String> getRestrictions()
      {
         return restrictions;
      }
   
  +   /**
  +    * Calling setRestrictions causes the restrictions to be reparsed and the 
  +    * query refreshed
  +    */
      public void setRestrictions(List<String> restrictions)
      {
         this.restrictions = restrictions;
  @@ -274,6 +350,9 @@
         refresh();
      }
   
  +   /**
  +    * The order of the query
  +    */
      public String getOrder()
      {
         return order;
  
  
  
  1.17      +32 -1     jboss-seam/src/main/org/jboss/seam/framework/EntityQuery.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EntityQuery.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/EntityQuery.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- EntityQuery.java	6 Jul 2007 19:42:55 -0000	1.16
  +++ EntityQuery.java	28 Sep 2007 13:54:36 -0000	1.17
  @@ -4,6 +4,7 @@
   import java.util.Map;
   
   import javax.persistence.EntityManager;
  +import javax.persistence.NonUniqueResultException;
   import javax.transaction.SystemException;
   
   import org.jboss.seam.annotations.Transactional;
  @@ -24,6 +25,11 @@
      private Long resultCount;
      private Map<String, String> hints;
   
  +   /**
  +    * Validate the query
  +    * 
  +    * @throws IllegalStateException if the query is not valid
  +    */
      @Override
      public void validate()
      {
  @@ -43,6 +49,11 @@
      }
   
   
  +   /**
  +    * Get the list of results this query returns
  +    * 
  +    * Any changed restriction values will be applied
  +    */
      @Transactional
      @Override
      public List getResultList()
  @@ -64,6 +75,13 @@
         }
      }
      
  +   /**
  +    * Get a single result from the query
  +    * 
  +    * Any changed restriction values will be applied
  +    * 
  +    * @throws NonUniqueResultException if there is more than one result
  +    */
      @Transactional
      @Override
      public Object getSingleResult()
  @@ -86,6 +104,11 @@
         }
      }
   
  +   /**
  +    * Get the number of results this query returns
  +    * 
  +    * Any changed restriction values will be applied
  +    */
      @Transactional
      @Override
      public Long getResultCount()
  @@ -108,6 +131,14 @@
         }
      }
   
  +   /**
  +    * The refresh method will cause the result to be cleared.  The next access
  +    * to the result set will cause the query to be executed.
  +    * 
  +    * This method <b>does not</b> cause the ejbql or restrictions to reread.
  +    * If you want to update the ejbql or restrictions you must call 
  +    * {@link #setEjbql(String)} or {@link #setRestrictions(List)}
  +    */
      @Override
      public void refresh()
      {
  
  
  



More information about the jboss-cvs-commits mailing list