continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1677082 - in /continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-store/src/main/java/org/apache/continuum/dao/ continuum-webapp/src/main/java/org/apac...
Date Thu, 30 Apr 2015 23:51:45 GMT
Author: batkinson
Date: Thu Apr 30 23:51:45 2015
New Revision: 1677082

URL: http://svn.apache.org/r1677082
Log:
[CONTINUUM-1621] Add pagination to project build history

Added:
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResultsPager.jspf
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/css/continuum.css

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Thu Apr 30 23:51:45 2015
@@ -202,6 +202,9 @@ public interface Continuum
     Collection<BuildResult> getBuildResultsForProject( int projectId )
         throws ContinuumException;
 
+    Collection<BuildResult> getBuildResultsForProject( int projectId, int offset, int
length )
+        throws ContinuumException;
+
     List<ChangeSet> getChangesSinceLastSuccess( int projectId, int buildResultId )
         throws ContinuumException;
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Thu Apr 30 23:51:45 2015
@@ -2815,6 +2815,12 @@ public class DefaultContinuum
         return buildResultDao.getBuildResultsForProject( projectId );
     }
 
+    public Collection<BuildResult> getBuildResultsForProject( int projectId, int offset,
int length )
+        throws ContinuumException
+    {
+        return buildResultDao.getBuildResultsForProject( projectId, offset, offset + length
);
+    }
+
     // ----------------------------------------------------------------------
     // Workflow
     // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
(original)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
Thu Apr 30 23:51:45 2015
@@ -595,12 +595,11 @@ public class BuildResultDaoImpl
 
             query.setFilter( "this.project.id == projectId" );
 
-            query.setOrdering( "this.startTime descending" );
-
             if ( startIndex >= 0 )
             {
                 query.setRange( startIndex, endIndex );
             }
+            query.setOrdering( "this.id descending" );
 
             List<BuildResult> result = (List<BuildResult>) query.execute( projectId
);
 

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultsListAction.java
Thu Apr 30 23:51:45 2015
@@ -38,12 +38,16 @@ import java.util.List;
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  */
-@Component( role = com.opensymphony.xwork2.Action.class, hint = "buildResults", instantiationStrategy
= "per-lookup"  )
+@Component( role = com.opensymphony.xwork2.Action.class, hint = "buildResults", instantiationStrategy
= "per-lookup" )
 public class BuildResultsListAction
     extends AbstractBuildAction
 {
     private static final Logger logger = LoggerFactory.getLogger( BuildResultsListAction.class
);
 
+    private static final int MAX_PAGE_LEN = 100;
+
+    private static final int MIN_PAGE_LEN = 10;
+
     private Project project;
 
     private Collection<BuildResult> buildResults;
@@ -58,6 +62,10 @@ public class BuildResultsListAction
 
     private String projectGroupName = "";
 
+    private int page;
+
+    private int length = MAX_PAGE_LEN / 4;
+
     public String execute()
         throws ContinuumException
     {
@@ -72,7 +80,12 @@ public class BuildResultsListAction
 
         project = getContinuum().getProject( projectId );
 
-        buildResults = getContinuum().getBuildResultsForProject( projectId );
+        int adjPage = Math.max( 1, page ), adjLength = Math.max( MIN_PAGE_LEN, Math.min(
MAX_PAGE_LEN, length ) );
+
+        page = adjPage;
+        length = adjLength;
+
+        buildResults = getContinuum().getBuildResultsForProject( projectId, ( page - 1 )
* length, length );
 
         return SUCCESS;
     }
@@ -151,6 +164,26 @@ public class BuildResultsListAction
         return CONFIRM;
     }
 
+    public int getPage()
+    {
+        return page;
+    }
+
+    public void setPage( int page )
+    {
+        this.page = page;
+    }
+
+    public int getLength()
+    {
+        return length;
+    }
+
+    public void setLength( int length )
+    {
+        this.length = length;
+    }
+
     public int getProjectId()
     {
         return projectId;

Modified: continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Thu Apr 30 23:51:45 2015
@@ -570,6 +570,9 @@ buildResults.state = State
 buildResults.result = Result
 buildResults.buildDefinition.description = Build Definition Description
 buildResults.delete.error = Unable to delete Build Results
+buildResults.page = Page {0}
+buildResults.next = Next
+buildResults.prev = Prev
 
 # ----------------------------------------------------------------------
 # Page: BuildResults

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResults.jsp Thu Apr
30 23:51:45 2015
@@ -49,6 +49,7 @@
           </div>
         </c:if>
 
+        <jsp:include page="buildResultsPager.jspf" />
         <s:form id="buildResultsForm" action="removeBuildResults" theme="simple">
           <s:token/>
           <s:set name="buildResults" value="buildResults" scope="request"/>
@@ -113,6 +114,7 @@
             </div>
           </c:if>
         </s:form>
+        <jsp:include page="buildResultsPager.jspf" />
       </div>
     </body>
   </s:i18n>

Added: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResultsPager.jspf
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResultsPager.jspf?rev=1677082&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResultsPager.jspf (added)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResultsPager.jspf Thu
Apr 30 23:51:45 2015
@@ -0,0 +1,30 @@
+<%@ taglib uri="/struts-tags" prefix="s" %>
+<page-controls>
+    <page>
+        <s:text name="buildResults.page">
+            <s:param value="page"/>
+        </s:text>
+    </page>
+    <prev>
+        <s:if test="page > 1">
+            <s:a action="buildResults" includeParams="get">
+                <s:param name="page" value="page - 1"/>
+                <s:text name="buildResults.prev"/>
+            </s:a>
+        </s:if>
+        <s:else>
+            <s:text name="buildResults.prev"/>
+        </s:else>
+    </prev>
+    <next>
+        <s:if test="buildResults.size() >= length">
+            <s:a action="buildResults" includeParams="get">
+                <s:param name="page" value="page + 1"/>
+                <s:text name="buildResults.next"/>
+            </s:a>
+        </s:if>
+        <s:else>
+            <s:text name="buildResults.next"/>
+        </s:else>
+    </next>
+</page-controls>
\ No newline at end of file

Modified: continuum/trunk/continuum-webapp/src/main/webapp/css/continuum.css
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/css/continuum.css?rev=1677082&r1=1677081&r2=1677082&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/css/continuum.css (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/css/continuum.css Thu Apr 30 23:51:45
2015
@@ -77,4 +77,13 @@ div.errormessage p, span.errorMessage {
   background: url(../images/icon_error_sml.gif) no-repeat;
   padding-left: 20px;
   min-height: 15px;
+}
+
+page-controls {
+  display: block;
+  text-align: right;
+}
+
+page-controls page {
+  font-weight: bold;
 }
\ No newline at end of file



Mime
View raw message