continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r695323 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/dao/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-store/src/main/java/org/apache/continuum/dao/ continuum-store/src/test/java/org/apache/m...
Date Mon, 15 Sep 2008 00:51:06 GMT
Author: ctan
Date: Sun Sep 14 17:51:05 2008
New Revision: 695323

URL: http://svn.apache.org/viewvc?rev=695323&view=rev
Log:
fixed error when removing ProjectGroup and/or Projects because of the ContinuumReleaseResult
relationship

Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDao.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/ContinuumReleaseResultDaoImpl.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

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDao.java?rev=695323&r1=695322&r2=695323&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDao.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDao.java
Sun Sep 14 17:51:05 2008
@@ -37,7 +37,7 @@
         throws ContinuumStoreException;
 
     List<ContinuumReleaseResult> getContinuumReleaseResultsByProjectGroup( int projectGroupId
);
-
+    
     List<ContinuumReleaseResult> getAllContinuumReleaseResults();
 
     ContinuumReleaseResult getContinuumReleaseResult( int releaseResultId )
@@ -45,5 +45,6 @@
     
     ContinuumReleaseResult getContinuumReleaseResult( int projectId, String releaseGoal,
long startTime, long endTime )
         throws ContinuumStoreException;
-        
+
+    List<ContinuumReleaseResult> getContinuumReleaseResultsByProject( int projectId
);
 }

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=695323&r1=695322&r2=695323&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
Sun Sep 14 17:51:05 2008
@@ -345,27 +345,6 @@
             {
                 removeProject( ( (Project) o ).getId() );
             }
-            
-            List<ContinuumReleaseResult> releaseResults = releaseResultDao.getContinuumReleaseResultsByProjectGroup(
projectGroupId );
-            
-            try
-            {
-                for ( ContinuumReleaseResult releaseResult : releaseResults )
-                {
-                    releaseResultDao.removeContinuumReleaseResult( releaseResult );
-                }
-                
-                File releaseOutputDirectory = configurationService.getReleaseOutputDirectory(
projectGroupId );
-                FileUtils.deleteDirectory( releaseOutputDirectory );
-            }
-            catch ( ContinuumStoreException e )
-            {
-                throw new ContinuumException( "Error while deleting continuum release result
of project group", e );
-            }
-            catch ( IOException e )
-            {
-                throw logAndCreateException( "Error while deleting project group release
output directory.", e );
-            }
         }
 
         getLogger().info( "Remove project group " + projectGroup.getName() + "(" + projectGroup.getId()
+ ")" );
@@ -822,6 +801,27 @@
         {
             Project project = getProjectWithBuilds( projectId );
 
+            List<ContinuumReleaseResult> releaseResults = releaseResultDao.getContinuumReleaseResultsByProject(
projectId );
+            
+            try
+            {
+                for ( ContinuumReleaseResult releaseResult : releaseResults )
+                {
+                    releaseResultDao.removeContinuumReleaseResult( releaseResult );
+                }
+                
+                File releaseOutputDirectory = configurationService.getReleaseOutputDirectory(
project.getProjectGroup().getId() );
+                FileUtils.deleteDirectory( releaseOutputDirectory );
+            }
+            catch ( ContinuumStoreException e )
+            {
+                throw new ContinuumException( "Error while deleting continuum release result
of project group", e );
+            }
+            catch ( IOException e )
+            {
+                throw logAndCreateException( "Error while deleting project group release
output directory.", e );
+            }
+
             getLogger().info( "Remove project " + project.getName() + "(" + projectId + ")"
);
 
             if ( isInCheckoutQueue( projectId ) )

Modified: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDaoImpl.java?rev=695323&r1=695322&r2=695323&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDaoImpl.java
(original)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ContinuumReleaseResultDaoImpl.java
Sun Sep 14 17:51:05 2008
@@ -133,6 +133,34 @@
         }
     }
 
+    public List<ContinuumReleaseResult> getContinuumReleaseResultsByProject( int projectId
)
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
+
+            Query query = pm.newQuery( extent, "project.id == " + projectId );
+
+            List result = (List) query.execute();
+
+            result = (List) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            return result;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
     public void removeContinuumReleaseResult( ContinuumReleaseResult releaseResult )
         throws ContinuumStoreException
     {

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=695323&r1=695322&r2=695323&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
Sun Sep 14 17:51:05 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ContinuumReleaseResultDao;
 import org.apache.continuum.dao.DaoUtils;
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.InstallationDao;
@@ -29,6 +30,7 @@
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.dao.ScheduleDao;
 import org.apache.continuum.dao.SystemConfigurationDao;
+import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
@@ -83,6 +85,8 @@
 
     protected SystemConfigurationDao systemConfigurationDao;
 
+    protected ContinuumReleaseResultDao releaseResultDao;
+
     protected ProjectGroup defaultProjectGroup;
 
     protected ProjectGroup testProjectGroup2;
@@ -160,6 +164,8 @@
         scheduleDao = (ScheduleDao) lookup( ScheduleDao.class.getName() );
 
         systemConfigurationDao = (SystemConfigurationDao) lookup( SystemConfigurationDao.class.getName()
);
+
+        releaseResultDao = (ContinuumReleaseResultDao) lookup( ContinuumReleaseResultDao.class.getName()
);
     }
 
     protected void createBuildDatabase()
@@ -1362,6 +1368,35 @@
                       actualConfig.isEnabled() );
     }
 
+    protected static ContinuumReleaseResult createTestContinuumReleaseResult( ProjectGroup
group, Project project, 
+                                                                              String releaseGoal,
int resultCode,
+                                                                              long startTime,
long endTime )
+    {
+        ContinuumReleaseResult releaseResult = new ContinuumReleaseResult();
+        releaseResult.setProjectGroup( group );
+        releaseResult.setProject( project );
+        releaseResult.setReleaseGoal( releaseGoal );
+        releaseResult.setResultCode( resultCode );
+        releaseResult.setStartTime( startTime );
+        releaseResult.setEndTime( endTime );
+        
+        return releaseResult;
+    }
+    
+    protected static void assertReleaseResultEquals( ContinuumReleaseResult expectedConfig,

+                                                     ContinuumReleaseResult actualConfig
)
+    {
+        assertEquals( "compare continuum release result - id", expectedConfig.getId(), actualConfig.getId()
);
+        assertEquals( "compare continuum release result - releaseGoal", expectedConfig.getReleaseGoal(),
+                      actualConfig.getReleaseGoal() );
+        assertEquals( "compare continuum release result - resultCode", expectedConfig.getResultCode(),

+                      actualConfig.getResultCode() );
+        assertEquals( "compare continuum release result - startTime", expectedConfig.getStartTime(),

+                      actualConfig.getStartTime() );
+        assertEquals( "compare continuum release result - endTime", expectedConfig.getEndTime(),
+                      actualConfig.getEndTime() );
+    }
+    
     /**
      * Setup JDO Factory
      *

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=695323&r1=695322&r2=695323&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
Sun Sep 14 17:51:05 2008
@@ -22,6 +22,7 @@
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.BuildDefinitionTemplateDao;
 import org.apache.continuum.dao.BuildResultDao;
+import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
@@ -1248,6 +1249,31 @@
         assertRepositoryPurgeConfigurationEquals( testRepoPurgeConfiguration3, repoPurgeList.get(
1 ) );
         assertDirectoryPurgeConfigurationEquals( testDirectoryPurgeConfig, dirPurgeList.get(
0 ) );
     }
+    
+    public void testRemoveProjectWithReleaseResult()
+        throws Exception
+    {
+        Project project = projectDao.getProject( testProject1.getId() );
+        ProjectGroup group = project.getProjectGroup();
+        
+        ContinuumReleaseResult releaseResult = createTestContinuumReleaseResult( group, project,
"releaseGoal", 0, 0, 0 );
+        releaseResult = releaseResultDao.addContinuumReleaseResult( releaseResult );
+        
+        List<ContinuumReleaseResult> releaseResults = releaseResultDao.getAllContinuumReleaseResults();
+        assertEquals( "check size of continuum release results", 1, releaseResults.size()
);
+        
+        ContinuumReleaseResult retrievedResult = releaseResults.get( 0 );
+        assertReleaseResultEquals( releaseResult, retrievedResult );
+        assertProjectGroupEquals( group, retrievedResult.getProjectGroup() );
+        assertProjectEquals( project, retrievedResult.getProject() );
+        
+        releaseResultDao.removeContinuumReleaseResult( releaseResult );
+        projectDao.removeProject( project );
+        assertFalse( projectDao.getProjectsInGroup( group.getId() ).contains( project ) );
+        
+        releaseResults = releaseResultDao.getAllContinuumReleaseResults();
+        assertEquals( "check size of continuum release results", 0, releaseResults.size()
);
+    }
 
     // ----------------------------------------------------------------------
     //  HELPER METHODS



Mime
View raw message