continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r953224 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/dao/ 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/c...
Date Thu, 10 Jun 2010 06:34:31 GMT
Author: ctan
Date: Thu Jun 10 06:34:30 2010
New Revision: 953224

URL: http://svn.apache.org/viewvc?rev=953224&view=rev
Log:
[CONTINUUM-2521] moved conversion to DAO and used < day + 1 instead of setting the endDate
time to 23h 59min 59s

Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
    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-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java?rev=953224&r1=953223&r2=953224&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
Thu Jun 10 06:34:30 2010
@@ -19,6 +19,7 @@ package org.apache.continuum.dao;
  * under the License.
  */
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -101,5 +102,5 @@ public interface BuildResultDao
 
     List<BuildResult> getAllBuildsForAProjectByDate( int projectId );
 
-    List<BuildResult> getBuildResultsInRange( long fromDate, long toDate, int state,
String triggeredBy, int projectGroupId );
+    List<BuildResult> getBuildResultsInRange( Date fromDate, Date toDate, int state,
String triggeredBy, int projectGroupId );
 }

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=953224&r1=953223&r2=953224&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 Jun 10 06:34:30 2010
@@ -21,6 +21,7 @@ package org.apache.maven.continuum;
 
 import java.io.File;
 import java.util.Collection;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -210,7 +211,7 @@ public interface Continuum
     void removeBuildResult( int buildId )
         throws ContinuumException;
 
-    List<BuildResult> getBuildResultsInRange( int projectGroupId, long fromDate, long
toDate, int state, String triggeredBy );
+    List<BuildResult> getBuildResultsInRange( int projectGroupId, Date fromDate, Date
toDate, int state, String triggeredBy );
 
     // ----------------------------------------------------------------------
     // Projects

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=953224&r1=953223&r2=953224&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 Jun 10 06:34:30 2010
@@ -105,6 +105,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -587,7 +588,7 @@ public class DefaultContinuum
         return ( builds.isEmpty() ? null : builds.get( 0 ) );
     }
 
-    public List<BuildResult> getBuildResultsInRange( int projectGroupId, long fromDate,
long toDate, int state, String triggeredBy )
+    public List<BuildResult> getBuildResultsInRange( int projectGroupId, Date fromDate,
Date toDate, int state, String triggeredBy )
     {
         return buildResultDao.getBuildResultsInRange( fromDate, toDate, state, triggeredBy,
projectGroupId );
     }

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=953224&r1=953223&r2=953224&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 Jun 10 06:34:30 2010
@@ -19,6 +19,8 @@ package org.apache.continuum.dao;
  * under the License.
  */
 
+import java.util.Calendar;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -750,7 +752,7 @@ public class BuildResultDaoImpl
     }
     
     @SuppressWarnings( "unchecked" )
-    public List<BuildResult> getBuildResultsInRange( long fromDate, long toDate, int
state, String triggeredBy, int projectGroupId )
+    public List<BuildResult> getBuildResultsInRange( Date fromDate, Date toDate, int
state, String triggeredBy, int projectGroupId )
     {
         PersistenceManager pm = getPersistenceManager();
 
@@ -798,20 +800,24 @@ public class BuildResultDaoImpl
                 filter += "this.username == triggeredBy && ";
             }
 
-            if ( fromDate > 0 )
+            if ( fromDate != null )
             {
-                params.put( "fromDate", fromDate );
+                params.put( "fromDate", fromDate.getTime() );
                 ctr++;
                 parameters += "long fromDate, ";
                 filter += "this.startTime >= fromDate && ";
             }
 
-            if ( toDate > 0 )
+            if ( toDate != null )
             {
-                params.put( "toDate", toDate );
+                Calendar cal = Calendar.getInstance();
+                cal.setTime( toDate );
+                cal.add( Calendar.DAY_OF_MONTH, 1 );
+
+                params.put( "toDate", cal.getTimeInMillis() );
                 ctr++;
                 parameters += "long toDate";
-                filter += "this.startTime <= toDate";
+                filter += "this.startTime < toDate";
             }
             
             if ( filter.endsWith( "&& " ) )

Modified: continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?rev=953224&r1=953223&r2=953224&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
(original)
+++ continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
Thu Jun 10 06:34:30 2010
@@ -60,6 +60,8 @@ import org.codehaus.plexus.jdo.JdoFactor
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -346,7 +348,13 @@ public abstract class AbstractContinuumS
 
         // TODO: simplify by deep copying the relationships in createTest... ?
         baseTime = System.currentTimeMillis();
+
+        Calendar cal = Calendar.getInstance();
+        cal.setTime( new Date( baseTime ) );
+        cal.add( Calendar.DAY_OF_MONTH, 1 );
         
+        long newTime = cal.getTimeInMillis();
+
         // successful forced build
         testBuildResult1 = createTestBuildResult( 1, true, 2, 1, "error1", 1, baseTime, baseTime
+ 1000, "user" );
         BuildResult buildResult1 = createTestBuildResult( testBuildResult1 );
@@ -360,12 +368,15 @@ public abstract class AbstractContinuumS
         testProject1.addBuildResult( buildResult1 );
 
         // failed scheduled build
-        testBuildResult2 = createTestBuildResult( 2, false, 3, 2, "error2", 2, baseTime +
2000, baseTime + 3000, "schedule" );
+        testBuildResult2 = createTestBuildResult( 2, false, 3, 2, "error2", 2, newTime, newTime
+ 3000, "schedule" );
         BuildResult buildResult2 = createTestBuildResult( testBuildResult2 );
         testProject1.addBuildResult( buildResult2 );
 
+        cal.add( Calendar.DAY_OF_MONTH, 2 );
+        newTime = cal.getTimeInMillis();
+
         // successful scheduled build
-        testBuildResult3 = createTestBuildResult( 2, true, 2, 3, "error3", 3, baseTime +
4000, baseTime + 5000, "schedule" );
+        testBuildResult3 = createTestBuildResult( 2, true, 2, 3, "error3", 3, newTime, newTime
+ 5000, "schedule" );
         BuildResult buildResult3 = createTestBuildResult( testBuildResult3 );
         scmResult = createTestScmResult( "commandOutput3", "providerMessage3", true, "3"
);
         buildResult3.setScmResult( scmResult );

Modified: continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?rev=953224&r1=953223&r2=953224&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
(original)
+++ continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
Thu Jun 10 06:34:30 2010
@@ -45,7 +45,9 @@ import org.apache.maven.continuum.model.
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -1402,34 +1404,38 @@ public class ContinuumStoreTest
     public void testGetBuildResultsInRange()
         throws Exception
     {
-        List<BuildResult> results = buildResultDao.getBuildResultsInRange( 0, 0, 0,
null, 0 );	    
+        List<BuildResult> results = buildResultDao.getBuildResultsInRange( null, null,
0, null, 0 );	    
         assertEquals( "check number of build results returned", 3, results.size() );
 
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 2, null, 0 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 2, null, 0 );
         assertEquals( "check number of build results returned with state == OK", 2, results.size()
);
 
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 0, "user", 0 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 0, "user", 0 );
         assertEquals( "check number of build results returned with triggeredBy == user",
1, results.size() );
 	    
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 0, "schedule", 0 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 0, "schedule", 0 );
         assertEquals( "check number of build results returned with triggeredBy == schedule",
2, results.size() );
         
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 2, "schedule", 0 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 2, "schedule", 0 );
         assertEquals( "check number of build results returned with state == Ok and triggeredBy
== schedule", 1, results.size() );
 
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 3, "user", 0 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 3, "user", 0 );
         assertEquals( "check number of build results returned with state == Failed and triggeredBy
== user", 0, results.size() );
 
-        results = buildResultDao.getBuildResultsInRange( baseTime, baseTime + 2000, 0, null,
0 );
+        Calendar cal = Calendar.getInstance();
+        cal.setTime( new Date( baseTime ) );
+        cal.add( Calendar.DAY_OF_MONTH, 1 );
+
+        results = buildResultDao.getBuildResultsInRange( new Date( baseTime ), cal.getTime(),
0, null, 0 );
         assertEquals( "check number of build results returned with startDate and endDate",
2, results.size() );
 
-        results = buildResultDao.getBuildResultsInRange( baseTime, baseTime, 0, null, 0 );
+        results = buildResultDao.getBuildResultsInRange( new Date( baseTime ), new Date(
baseTime ), 0, null, 0 );
         assertEquals( "check number of build results returned with the same startDate and
endDate", 1, results.size() );
         
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 0, null, 1 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 0, null, 1 );
         assertEquals( "check number of build results returned with an existing group id",
3, results.size() );
         
-        results = buildResultDao.getBuildResultsInRange( 0, 0, 0, null, 2 );
+        results = buildResultDao.getBuildResultsInRange( null, null, 0, null, 2 );
         assertEquals( "check number of build results returned with non-existing group id",
0, results.size() );
     }
     // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java?rev=953224&r1=953223&r2=953224&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java
Thu Jun 10 06:34:30 2010
@@ -131,28 +131,13 @@ public class ViewBuildsReportAction
             return REQUIRES_AUTHORIZATION;
         }
 
-        long fromDate = 0;
-        long toDate = 0;
+        Date fromDate = null;
+        Date toDate = null;
 
         try
         {
-            if ( !StringUtils.isEmpty( startDate ) )
-            {
-                fromDate = DateUtils.parseDate( startDate, datePatterns ).getTime();
-            }
-    
-            if ( !StringUtils.isEmpty( endDate ) )
-            {
-                Date toDateInDateFormat = DateUtils.parseDate( endDate, datePatterns );
-                
-                Calendar toDateCal = Calendar.getInstance();
-                toDateCal.setTime( toDateInDateFormat );
-                toDateCal.set( Calendar.HOUR_OF_DAY, 23 );
-                toDateCal.set( Calendar.MINUTE, 59 );
-                toDateCal.set( Calendar.SECOND, 59 );
-                
-                toDate = toDateCal.getTimeInMillis();
-            }
+            fromDate = getStartDateInDateFormat();
+            toDate = getEndDateInDateFormat();
         }
         catch ( ParseException e )
         {
@@ -160,7 +145,7 @@ public class ViewBuildsReportAction
             return ERROR;
         }
 
-        if ( fromDate != 0 && toDate != 0 && new Date( fromDate ).after(
new Date( toDate ) ) )
+        if ( fromDate != null && toDate != null && fromDate.after( toDate
) )
         {
             addFieldError( "startDate", "Start Date must be earlier than the End Date" );
             return INPUT;
@@ -219,28 +204,13 @@ public class ViewBuildsReportAction
             return REQUIRES_AUTHORIZATION;
         }
 
-        long fromDate = 0;
-        long toDate = 0;
+        Date fromDate = null;
+        Date toDate = null;
 
         try
         {
-            if ( !StringUtils.isEmpty( startDate ) )
-            {
-                fromDate = DateUtils.parseDate( startDate, datePatterns ).getTime();
-            }
-            
-            if ( !StringUtils.isEmpty( endDate ) )
-            {
-                Date toDateInDateFormat = DateUtils.parseDate( endDate, datePatterns );
-                
-                Calendar toDateCal = Calendar.getInstance();
-                toDateCal.setTime( toDateInDateFormat );
-                toDateCal.set( Calendar.HOUR_OF_DAY, 23 );
-                toDateCal.set( Calendar.MINUTE, 59 );
-                toDateCal.set( Calendar.SECOND, 59 );
-                
-                toDate = toDateCal.getTimeInMillis();
-            }
+            fromDate = getStartDateInDateFormat();
+            toDate = getEndDateInDateFormat();
         }
         catch ( ParseException e )
         {
@@ -248,7 +218,7 @@ public class ViewBuildsReportAction
             return ERROR;
         }
 
-        if ( fromDate != 0 && toDate != 0 && new Date( fromDate ).after(
new Date( toDate ) ) )
+        if ( fromDate != null && toDate != null && fromDate.after( toDate
) )
         {
             addFieldError( "startDate", "Start Date must be earlier than the End Date" );
             return INPUT;
@@ -336,6 +306,32 @@ public class ViewBuildsReportAction
         return buildsSummary;
     }
 
+    private Date getStartDateInDateFormat()
+        throws ParseException
+    {
+        Date date = null;
+
+        if ( !StringUtils.isEmpty( startDate ) )
+        {
+            date = DateUtils.parseDate( startDate, datePatterns );
+        }
+
+        return date;
+    }
+
+    private Date getEndDateInDateFormat()
+        throws ParseException
+    {
+        Date date = null;
+
+        if ( !StringUtils.isEmpty( endDate ) )
+        {
+            date = DateUtils.parseDate( endDate, datePatterns );
+        }
+
+        return date;
+    }
+
     public int getBuildStatus()
     {
         return this.buildStatus;



Mime
View raw message