continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r219970 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/store/JdoContinuumStore.java test/java/org/apache/maven/continuum/store/NewModelTest.java
Date Thu, 21 Jul 2005 01:03:15 GMT
Author: jvanzyl
Date: Wed Jul 20 18:03:14 2005
New Revision: 219970

URL: http://svn.apache.org/viewcvs?rev=219970&view=rev
Log:
o changes to store for build settings
o tests for build settings


Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=219970&r1=219969&r2=219970&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
Wed Jul 20 18:03:14 2005
@@ -36,6 +36,7 @@
 import org.apache.maven.continuum.project.ContinuumSchedule;
 import org.apache.maven.continuum.project.ContinuumProjectGroup;
 import org.apache.maven.continuum.project.ContinuumBuildGroup;
+import org.apache.maven.continuum.project.ContinuumBuildSettings;
 import org.apache.maven.continuum.scm.ScmResult;
 
 import org.codehaus.plexus.jdo.JdoFactory;
@@ -78,7 +79,7 @@
     public String addProject( ContinuumProject project )
         throws ContinuumStoreException
     {
-        return ((ContinuumProject)addObject( project ) ).getId();
+        return ( (ContinuumProject) addObject( project ) ).getId();
     }
 
     public void removeProject( String projectId )
@@ -328,7 +329,7 @@
 
             return project;
         }
-        catch( JDOObjectNotFoundException e )
+        catch ( JDOObjectNotFoundException e )
         {
             throw new ContinuumObjectNotFoundException( ContinuumProject.class.getName(),
projectId );
         }
@@ -406,7 +407,7 @@
     public String addSchedule( ContinuumSchedule schedule )
         throws ContinuumStoreException
     {
-        return ((ContinuumSchedule)addObject( schedule ) ).getId();
+        return ( (ContinuumSchedule) addObject( schedule ) ).getId();
     }
 
     public ContinuumSchedule getSchedule( String projectId )
@@ -428,7 +429,7 @@
 
             return schedule;
         }
-        catch( JDOObjectNotFoundException e )
+        catch ( JDOObjectNotFoundException e )
         {
             throw new ContinuumObjectNotFoundException( ContinuumProject.class.getName(),
projectId );
         }
@@ -718,7 +719,7 @@
     public String addProjectGroup( ContinuumProjectGroup projectGroup )
         throws ContinuumStoreException
     {
-        return ((ContinuumProjectGroup)addObject( projectGroup )).getId();
+        return ( (ContinuumProjectGroup) addObject( projectGroup ) ).getId();
     }
 
     public void updateProjectGroup( ContinuumProjectGroup projectGroup )
@@ -821,7 +822,7 @@
     public String addBuildGroup( ContinuumBuildGroup buildGroup )
         throws ContinuumStoreException
     {
-        return ((ContinuumBuildGroup) addObject( buildGroup )).getId();
+        return ( (ContinuumBuildGroup) addObject( buildGroup ) ).getId();
     }
 
     public void updateBuildGroup( ContinuumBuildGroup schedule )
@@ -915,6 +916,140 @@
         }
     }
 
+    // ----------------------------------------------------------------------
+    // Build Settings
+    // ----------------------------------------------------------------------
+
+    public String addBuildSettings( ContinuumBuildSettings buildSettings )
+        throws ContinuumStoreException
+    {
+        return ( (ContinuumBuildSettings) addObject( buildSettings ) ).getId();
+    }
+
+    public void updateBuildSettings( ContinuumBuildSettings buildSettings )
+        throws ContinuumStoreException
+    {
+        updateObject( buildSettings );
+    }
+
+    public void removeBuildSettings( String buildSettingsId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Object id = pm.newObjectIdInstance( ContinuumBuildSettings.class, buildSettingsId
);
+
+            ContinuumBuildSettings buildSettings = (ContinuumBuildSettings) pm.getObjectById(
id );
+
+            // remove references of this buildSettings object in the build groups
+            if ( buildSettings.getBuildGroups() != null && buildSettings.getBuildGroups().size()
> 0 )
+            {
+                Set projects = buildSettings.getBuildGroups();
+
+                for ( Iterator i = projects.iterator(); i.hasNext(); )
+                {
+                    ContinuumBuildGroup buildGroup = (ContinuumBuildGroup) i.next();
+
+                    buildGroup.getBuildSettings().remove( buildSettings );
+                }
+            }
+
+            // remove references of this buildSettings object in the project groups
+            if ( buildSettings.getProjectGroups() != null && buildSettings.getProjectGroups().size()
> 0 )
+            {
+                Set projects = buildSettings.getProjectGroups();
+
+                for ( Iterator i = projects.iterator(); i.hasNext(); )
+                {
+                    ContinuumProjectGroup project = (ContinuumProjectGroup) i.next();
+
+                    project.getBuildSettings().remove( buildSettings );
+                }
+            }
+
+            pm.deletePersistent( buildSettings );
+
+            commit( tx );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public ContinuumBuildSettings getBuildSettings( String buildSettingsId )
+        throws ContinuumStoreException
+    {
+        return (ContinuumBuildSettings) getDetailedObject( ContinuumBuildSettings.class,
+                                                           buildSettingsId,
+                                                           "build-settings-detail" );
+
+        /*
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Object id = pm.newObjectIdInstance( ContinuumBuildSettings.class, buildSettingsId
);
+
+            ContinuumBuildSettings buildSettings = (ContinuumBuildSettings) pm.getObjectById(
id );
+
+            buildSettings = (ContinuumBuildSettings) pm.detachCopy( buildSettings );
+
+            commit( tx );
+
+            return buildSettings;
+        }
+        catch ( JDOObjectNotFoundException e )
+        {
+            throw new ContinuumObjectNotFoundException( ContinuumBuildSettings.class.getName(),
buildSettingsId );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+        */
+    }
+
+    public Collection getBuildSettings()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumBuildSettings.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.setOrdering( "name ascending" );
+
+            Collection result = (Collection) query.execute();
+
+            result = pm.detachCopyAll( result );
+
+            commit( tx );
+
+            return result;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
 
     // ----------------------------------------------------------------------
     //

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java?rev=219970&r1=219969&r2=219970&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
Wed Jul 20 18:03:14 2005
@@ -20,6 +20,7 @@
 import org.apache.maven.continuum.project.ContinuumBuildGroup;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectGroup;
+import org.apache.maven.continuum.project.ContinuumBuildSettings;
 
 import java.util.Collection;
 import java.util.Set;
@@ -175,6 +176,112 @@
         assertNotNull( project );
     }
 
+    public void testBuildSettingsAdditionAndRemovalFromBuildGroup()
+        throws Exception
+    {
+        // create buildSettings
+        ContinuumBuildSettings buildSettings = createStubBuildSettings( "buildSettings1",
"1.3" );
+
+        String buildSettingsId = getStore().addBuildSettings( buildSettings );
+
+        buildSettings = getStore().getBuildSettings( buildSettingsId );
+
+        // create buildGroup
+        ContinuumBuildGroup buildGroup = createStubBuildGroup( "buildGroup1", "buildGroup1"
);
+
+        String buildGroupId = getStore().addBuildGroup( buildGroup );
+
+        buildGroup = getStore().getBuildGroup( buildGroupId );
+
+        // add build group
+        buildSettings.addBuildGroup( buildGroup );
+
+        // update buildSettings
+        getStore().updateBuildSettings( buildSettings );
+
+        // retrieve buildSettings
+        buildSettings = getStore().getBuildSettings( buildSettingsId );
+
+        assertNotNull( buildSettings );
+
+        // get buildGroups out of the buildSettings
+        Set buildGroups = buildSettings.getBuildGroups();
+
+        assertEquals( 1, buildGroups.size() );
+
+        // get individual build group
+        buildGroup = (ContinuumBuildGroup) buildSettings.getBuildGroups().iterator().next();
+
+        // test values within the build group
+        assertEquals( "buildGroup1", buildGroup.getName() );
+
+        // ----------------------------------------------------------------------
+        // Now lookup the build group on its own and make sure the build settings are
+        // present within the build build gropu.
+        // ----------------------------------------------------------------------
+
+        buildGroup = getStore().getBuildGroup( buildGroupId );
+
+        assertNotNull( buildGroup );
+
+        buildSettings = (ContinuumBuildSettings) buildGroup.getBuildSettings().iterator().next();
+
+        assertEquals( "buildSettings1", buildSettings.getName() );
+
+        // ----------------------------------------------------------------------
+        // Now delete the buildSettings from the getStore() and make sure that the build
group
+        // still remains in the getStore().
+        // ----------------------------------------------------------------------
+
+        buildSettings = getStore().getBuildSettings( buildSettingsId );
+
+        getStore().removeBuildSettings( buildSettings.getId() );
+
+        buildGroup = getStore().getBuildGroup( buildGroupId );
+
+        assertNotNull( buildGroup );
+    }
+
+    // ----------------------------------------------------------------------
+    // Simple utils
+    // ----------------------------------------------------------------------
+
+    public ContinuumBuildSettings createStubBuildSettings( String name, String jdkVersion
)
+    {
+        ContinuumBuildSettings buildSettings = new ContinuumBuildSettings();
+
+        buildSettings.setName( name );
+
+        buildSettings.setJdkVersion( jdkVersion );
+
+        return buildSettings;
+    }
+
+    public ContinuumBuildGroup createStubBuildGroup( String name, String description )
+    {
+        ContinuumBuildGroup buildGroup = new ContinuumBuildGroup();
+
+        buildGroup.setName( name );
+
+        buildGroup.setDescription( description );
+
+        return buildGroup;
+    }
+
+    public ContinuumProjectGroup createStubProjectGroup( String name, String description
)
+    {
+        ContinuumProjectGroup projectGroup = new ContinuumProjectGroup();
+
+        projectGroup.setName( name );
+
+        projectGroup.setDescription( description );
+
+        return projectGroup;
+    }
+
+    // ----------------------------------------------------------------------
+    // We're not exactly sure why this beasty doesn't work.
+    // ----------------------------------------------------------------------
 
     public void xtestBasic()
         throws Exception
@@ -320,27 +427,4 @@
 
 //        assertEquals( 0, plexusGroup.getProjects().size() );
     }
-
-    public ContinuumBuildGroup createStubBuildGroup( String name, String description )
-    {
-        ContinuumBuildGroup buildGroup = new ContinuumBuildGroup();
-
-        buildGroup.setName( name );
-
-        buildGroup.setDescription( description );
-
-        return buildGroup;
-    }
-
-    public ContinuumProjectGroup createStubProjectGroup( String name, String description
)
-    {
-        ContinuumProjectGroup projectGroup = new ContinuumProjectGroup();
-
-        projectGroup.setName( name );
-
-        projectGroup.setDescription( description );
-
-        return projectGroup;
-    }
-
 }



Mime
View raw message