continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r756477 - in /continuum/trunk: continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/ continuum-data-management/data-management-jdo/src/test/resources/ continuum-model/src/main/mdo/ continuum-stor...
Date Fri, 20 Mar 2009 14:16:26 GMT
Author: ctan
Date: Fri Mar 20 14:16:25 2009
New Revision: 756477

URL: http://svn.apache.org/viewvc?rev=756477&view=rev
Log:
[CONTINUUM-2140] fix backup/restore of ContinuumReleaseResult, BuildDefinitionTemplate, DirectoryPurgeConfiguration,
and RepositoryPurgeConfiguration.

TODO:
Include the RepositoryPurgeConfiguration during restore. Comment out for now because of NPE,
which is caused by how the RepositoryPurgeConfiguration is being written by ContinuumStaxWriter
(LocalRepository first before the id).



Modified:
    continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
    continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    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-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java?rev=756477&r1=756476&r2=756477&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
(original)
+++ continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
Fri Mar 20 14:16:25 2009
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.BuildDefinitionTemplateDao;
+import org.apache.continuum.dao.ContinuumReleaseResultDao;
 import org.apache.continuum.dao.DaoUtils;
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.InstallationDao;
@@ -30,9 +32,13 @@
 import org.apache.continuum.dao.ScheduleDao;
 import org.apache.continuum.dao.SystemConfigurationDao;
 import org.apache.continuum.model.project.ProjectScmRoot;
+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;
 import org.apache.continuum.utils.ProjectSorter;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.ContinuumDatabase;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -129,6 +135,16 @@
      */
     private ProjectScmRootDao projectScmRootDao;
 
+    /**
+     * @plexus.requirement
+     */
+    private BuildDefinitionTemplateDao buildDefinitionTemplateDao;
+
+    /**
+     * @plexus.requirement
+     */
+    private ContinuumReleaseResultDao releaseResultDao;
+
     protected static final String BUILDS_XML = "builds.xml";
 
     /**
@@ -169,6 +185,15 @@
         database.setDirectoryPurgeConfigurations( directoryPurgeConfigurationDao.getAllDirectoryPurgeConfigurations()
);
 
         database.setProjectScmRoots( projectScmRootDao.getAllProjectScmRoots() );
+        try
+        {
+            database.setBuildDefinitionTemplates( buildDefinitionTemplateDao.getAllBuildDefinitionTemplate()
);
+        }
+        catch ( ContinuumStoreException e )
+        {
+        }
+
+        database.setContinuumReleaseResults( releaseResultDao.getAllContinuumReleaseResults()
);
 
         ContinuumStaxWriter writer = new ContinuumStaxWriter();
 
@@ -337,6 +362,47 @@
                 continue;
             }
         }
+
+        /*
+        for ( RepositoryPurgeConfiguration repoPurge : (List<RepositoryPurgeConfiguration>)
database.getRepositoryPurgeConfigurations() )
+        {
+            repoPurge.setRepository( localRepositories.get( 
+                                     Integer.valueOf( repoPurge.getRepository().getId() )
) );
+
+            if ( repoPurge.getSchedule() != null )
+            {
+                repoPurge.setSchedule( schedules.get( 
+                                       Integer.valueOf( repoPurge.getSchedule().getId() )
) );
+            }
+
+            repoPurge = (RepositoryPurgeConfiguration) PlexusJdoUtils.addObject( pmf.getPersistenceManager(),
repoPurge );
+        }*/
+
+        for ( DirectoryPurgeConfiguration dirPurge : (List<DirectoryPurgeConfiguration>)
database.getDirectoryPurgeConfigurations() )
+        {
+            if ( dirPurge.getSchedule() != null )
+            {
+                dirPurge.setSchedule( schedules.get(
+                                      Integer.valueOf( dirPurge.getSchedule().getId() ) )
);
+            }
+
+            dirPurge = (DirectoryPurgeConfiguration) PlexusJdoUtils.addObject( pmf.getPersistenceManager(),
dirPurge );
+        }
+
+        for ( ContinuumReleaseResult releaseResult : (List<ContinuumReleaseResult>)
database.getContinuumReleaseResults() )
+        {
+            releaseResult.setProjectGroup( projectGroups.get( 
+                                           Integer.valueOf( releaseResult.getProjectGroup().getId()
) ) );
+
+            releaseResult =
+                (ContinuumReleaseResult) PlexusJdoUtils.addObject( pmf.getPersistenceManager(),
releaseResult );
+        }
+
+        for ( BuildDefinitionTemplate template : (List<BuildDefinitionTemplate>) database.getBuildDefinitionTemplates()
)
+        {
+            template = 
+                (BuildDefinitionTemplate) PlexusJdoUtils.addObject( pmf.getPersistenceManager(),
template );
+        }
     }
     
     private List<Project> getProjectsByGroupIdWithDependencies( PersistenceManagerFactory
pmf, int projectGroupId )

Modified: continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml?rev=756477&r1=756476&r2=756477&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
(original)
+++ continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
Fri Mar 20 14:16:25 2009
@@ -549,4 +549,11 @@
       <projectGroup id="2"></projectGroup>
     </projectScmRoot>
   </projectScmRoots>
+  <continuumReleaseResults>
+    <continuumReleaseResult>
+      <id>1</id>
+      <projectGroup id="2"></projectGroup>
+      <releaseGoal>releaseGoal</releaseGoal>
+    </continuumReleaseResult>
+  </continuumReleaseResults>
 </continuumDatabase>

Modified: continuum/trunk/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/src/main/mdo/continuum.xml?rev=756477&r1=756476&r2=756477&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ continuum/trunk/continuum-model/src/main/mdo/continuum.xml Fri Mar 20 14:16:25 2009
@@ -108,6 +108,24 @@
           </association>
           <defaultValue>new java.util.ArrayList()</defaultValue>
         </field>
+        <field>
+          <name>continuumReleaseResults</name>
+          <version>1.1.3+</version>
+          <association java.init="field">
+            <type>ContinuumReleaseResult</type>
+            <multiplicity>*</multiplicity>
+          </association>
+          <defaultValue>new java.util.ArrayList()</defaultValue>
+        </field>
+        <field>
+          <name>buildDefinitionTemplates</name>
+          <version>1.1.3+</version>
+          <association java.init="field">
+            <type>BuildDefinitionTemplate</type>
+            <multiplicity>*</multiplicity>
+          </association>
+          <defaultValue>new java.util.ArrayList()</defaultValue>
+        </field>
       </fields>
     </class>
 

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=756477&r1=756476&r2=756477&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
Fri Mar 20 14:16:25 2009
@@ -141,6 +141,8 @@
 
     protected ProjectScmRoot testProjectScmRoot;
 
+    protected ContinuumReleaseResult testContinuumReleaseResult;
+
     private SystemConfiguration systemConfiguration;
 
     @Override
@@ -541,7 +543,7 @@
 
         if ( addToStore )
         {
-            projectGroupDao.addProjectGroup( group );
+            group = projectGroupDao.addProjectGroup( group );
             defaultProjectGroup.setId( group.getId() );
             testProject1.setId( project1.getId() );
             testProject2.setId( project2.getId() );
@@ -582,6 +584,7 @@
         }
         else
         {
+            group.setId( 2 );
             testProjectGroup2.setId( 2 ); // from expected.xml, continuum-data-management
         }
 
@@ -632,10 +635,29 @@
         }
         
         testProjectScmRoot = createTestProjectScmRoot( "scmRootAddress1", 1, 0, "error1",
group );
-        
+        ProjectScmRoot scmRoot = createTestProjectScmRoot( testProjectScmRoot );
+
+        if ( addToStore )
+        {
+            scmRoot = projectScmRootDao.addProjectScmRoot( scmRoot );
+            testProjectScmRoot.setId( scmRoot.getId() );
+        }
+        else
+        {
+            testProjectScmRoot.setId( 1 );
+        }
+
+        testContinuumReleaseResult = createTestContinuumReleaseResult( group, null, "releaseGoal",
0, 0, 0 );
+        ContinuumReleaseResult releaseResult = createTestContinuumReleaseResult( testContinuumReleaseResult
);
+
         if ( addToStore )
         {
-            projectScmRootDao.addProjectScmRoot( testProjectScmRoot );
+            releaseResult = releaseResultDao.addContinuumReleaseResult( releaseResult );
+            testContinuumReleaseResult.setId( releaseResult.getId() );
+        }
+        else
+        {
+            testContinuumReleaseResult.setId( 1 );
         }
     }
 
@@ -819,7 +841,26 @@
         store.addProjectGroup( group );
         testProjectGroup2.setId( group.getId() );
 */
-        assertSystemConfiguration( systemConfiguration, systemConfigurationDao.getSystemConfiguration()
);        
+        assertSystemConfiguration( systemConfiguration, systemConfigurationDao.getSystemConfiguration()
);
+
+        assertLocalRepositoryEquals( testLocalRepository1, localRepositoryDao.getLocalRepository(
testLocalRepository1.getId() ) );
+        assertLocalRepositoryEquals( testLocalRepository2, localRepositoryDao.getLocalRepository(
testLocalRepository2.getId() ) );
+        assertLocalRepositoryEquals( testLocalRepository3, localRepositoryDao.getLocalRepository(
testLocalRepository3.getId() ) );
+
+/*
+        assertRepositoryPurgeConfigurationEquals( testRepoPurgeConfiguration1,
+                                                  repositoryPurgeConfigurationDao.getRepositoryPurgeConfiguration(
testRepoPurgeConfiguration1.getId() ) );
+        assertRepositoryPurgeConfigurationEquals( testRepoPurgeConfiguration2,
+                                                  repositoryPurgeConfigurationDao.getRepositoryPurgeConfiguration(
testRepoPurgeConfiguration2.getId() ) );
+        assertRepositoryPurgeConfigurationEquals( testRepoPurgeConfiguration3,
+                                                  repositoryPurgeConfigurationDao.getRepositoryPurgeConfiguration(
testRepoPurgeConfiguration3.getId() ) );
+
+        assertDirectoryPurgeConfigurationEquals( testDirectoryPurgeConfig, 
+                                                 directoryPurgeConfigurationDao.getDirectoryPurgeConfiguration(
testDirectoryPurgeConfig.getId() ) );
+*/
+        assertProjectScmRootEquals( testProjectScmRoot, projectScmRootDao.getProjectScmRoot(
testProjectScmRoot.getId() ) );
+
+        assertReleaseResultEquals( testContinuumReleaseResult, releaseResultDao.getContinuumReleaseResult(
testContinuumReleaseResult.getId() ) );
     }
 
     private void assertSystemConfiguration( SystemConfiguration expected, SystemConfiguration
actual )
@@ -1430,6 +1471,12 @@
         return projectScmRoot;
     }
 
+    protected static ProjectScmRoot createTestProjectScmRoot( ProjectScmRoot scmRoot )
+    {
+        return createTestProjectScmRoot( scmRoot.getScmRootAddress(), scmRoot.getState(),
scmRoot.getOldState(), 
+                                         scmRoot.getError(), scmRoot.getProjectGroup() );
+    }
+
     protected static void assertProjectScmRootEquals( ProjectScmRoot expectedConfig, ProjectScmRoot
actualConfig )
     {
         assertEquals( "compare project scm root - id", expectedConfig.getId(), actualConfig.getId()
);
@@ -1454,7 +1501,14 @@
         
         return releaseResult;
     }
-    
+
+    protected static ContinuumReleaseResult createTestContinuumReleaseResult( ContinuumReleaseResult
releaseResult )
+    {
+        return createTestContinuumReleaseResult( releaseResult.getProjectGroup(), releaseResult.getProject(),

+                                                 releaseResult.getReleaseGoal(), releaseResult.getResultCode(),
+                                                 releaseResult.getStartTime(), releaseResult.getEndTime()
);
+    }
+
     protected static void assertReleaseResultEquals( ContinuumReleaseResult expectedConfig,

                                                      ContinuumReleaseResult actualConfig
)
     {
@@ -1468,7 +1522,7 @@
         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=756477&r1=756476&r2=756477&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
Fri Mar 20 14:16:25 2009
@@ -1300,9 +1300,9 @@
         releaseResult = releaseResultDao.addContinuumReleaseResult( releaseResult );
         
         List<ContinuumReleaseResult> releaseResults = releaseResultDao.getAllContinuumReleaseResults();
-        assertEquals( "check size of continuum release results", 1, releaseResults.size()
);
+        assertEquals( "check size of continuum release results", 2, releaseResults.size()
);
         
-        ContinuumReleaseResult retrievedResult = releaseResults.get( 0 );
+        ContinuumReleaseResult retrievedResult = releaseResults.get( 1 );
         assertReleaseResultEquals( releaseResult, retrievedResult );
         assertProjectGroupEquals( group, retrievedResult.getProjectGroup() );
         assertProjectEquals( project, retrievedResult.getProject() );
@@ -1312,7 +1312,7 @@
         assertFalse( projectDao.getProjectsInGroup( group.getId() ).contains( project ) );
         
         releaseResults = releaseResultDao.getAllContinuumReleaseResults();
-        assertEquals( "check size of continuum release results", 0, releaseResults.size()
);
+        assertEquals( "check size of continuum release results", 1, releaseResults.size()
);
     }
     // ----------------------------------------------------------------------
     //  HELPER METHODS



Mime
View raw message