continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r219955 - 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 Wed, 20 Jul 2005 17:40:58 GMT
Author: jvanzyl
Date: Wed Jul 20 10:40:57 2005
New Revision: 219955

URL: http://svn.apache.org/viewcvs?rev=219955&view=rev
Log: (empty)

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=219955&r1=219954&r2=219955&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 10:40:57 2005
@@ -721,6 +721,91 @@
         return ((ContinuumProjectGroup)addObject( projectGroup )).getId();
     }
 
+    public void updateProjectGroup( ContinuumProjectGroup projectGroup )
+        throws ContinuumStoreException
+    {
+        updateObject( projectGroup );
+    }
+
+    public Collection getProjectGroups()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumProjectGroup.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 );
+        }
+    }
+
+    public void removeProjectGroup( String projectGroupId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Object id = pm.newObjectIdInstance( ContinuumProjectGroup.class, projectGroupId
);
+
+            ContinuumProjectGroup projectGroup = (ContinuumProjectGroup) pm.getObjectById(
id );
+
+            // ----------------------------------------------------------------------
+            // We need to remove this projectGroup reference from any project in the
+            // system. So grab the list of projects this projectGroup belongs to
+            // then iterate through the collection of projects removing the
+            // reference to this projectGroup. This seems like a bit much but the
+            // only thing that works.
+            // ----------------------------------------------------------------------
+
+            /*
+            if ( projectGroup.getProjects() != null && projectGroup.getProjects().size()
> 0 )
+            {
+                Set projects = projectGroup.getProjects();
+
+                for ( Iterator i = projects.iterator(); i.hasNext(); )
+                {
+                    ContinuumProject project = (ContinuumProject) i.next();
+
+                    project.getBuildGroups().remove( projectGroup );
+                }
+            }
+            */
+
+            pm.deletePersistent( projectGroup );
+
+            commit( tx );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+
     public ContinuumProjectGroup getProjectGroup( String projectGroupId )
         throws ContinuumStoreException
     {
@@ -829,6 +914,7 @@
             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=219955&r1=219954&r2=219955&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 10:40:57 2005
@@ -20,7 +20,6 @@
 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.ContinuumSchedule;
 
 import java.util.Collection;
 import java.util.Set;
@@ -113,6 +112,69 @@
         assertNotNull( project );
     }
 
+    public void testProjectAdditionAndRemovalFromProjectGroup()
+        throws Exception
+    {
+        // create projectGroup
+        ContinuumProjectGroup projectGroup = createStubProjectGroup( "projectGroup1", "projectGroup1"
);
+
+        String projectGroupId = getStore().addProjectGroup( projectGroup );
+
+        projectGroup = getStore().getProjectGroup( projectGroupId );
+
+        String projectId = addMavenTwoProject( getStore(), "project2", "scm:scheduling" );
+
+        ContinuumProject project = getStore().getProject( projectId );
+
+        // add project
+        projectGroup.addProject( project );
+
+        // update projectGroup
+        getStore().updateProjectGroup( projectGroup );
+
+        // retrieve projectGroup
+        projectGroup = getStore().getProjectGroup( projectGroupId );
+
+        assertNotNull( projectGroup );
+
+        // get projects out of the projectGroup
+        Set projects = projectGroup.getProjects();
+
+        assertEquals( 1, projects.size() );
+
+        // get individual project
+        project = (ContinuumProject) projectGroup.getProjects().iterator().next();
+
+        // test values within project
+        assertEquals( "project2", project.getName() );
+
+        // ----------------------------------------------------------------------
+        // Now lookup the project on its own and make sure the projectGroup is
+        // present within the project.
+        // ----------------------------------------------------------------------
+
+        project = getStore().getProject( projectId );
+
+        assertNotNull( project );
+
+        projectGroup = project.getProjectGroup();
+
+        assertEquals( "projectGroup1", projectGroup.getName() );
+
+        // ----------------------------------------------------------------------
+        // Now delete the projectGroup from the getStore() and make sure that the project
+        // still remains in the getStore().
+        // ----------------------------------------------------------------------
+
+        projectGroup = getStore().getProjectGroup( projectGroupId );
+
+        getStore().removeProjectGroup( projectGroup.getId() );
+
+        project = getStore().getProject( projectId );
+
+        assertNotNull( project );
+    }
+
 
     public void xtestBasic()
         throws Exception
@@ -269,4 +331,16 @@
 
         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