continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r393487 - in /maven/continuum/branches/continuum-1.0.x: continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-model/src/main/mdo/ continuum-store/src/main/java/org/a...
Date Wed, 12 Apr 2006 15:36:49 GMT
Author: evenisse
Date: Wed Apr 12 08:36:47 2006
New Revision: 393487

URL: http://svn.apache.org/viewcvs?rev=393487&view=rev
Log:
Remove projects from default fetch group of project group

Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo
    maven/continuum/branches/continuum-1.0.x/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/branches/continuum-1.0.x/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java

Modified: maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=393487&r1=393486&r2=393487&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
Wed Apr 12 08:36:47 2006
@@ -135,6 +135,9 @@
     ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException;
 
+    ProjectGroup getProjectGroupWithProjects( int projectGroupId )
+        throws ContinuumObjectNotFoundException, ContinuumStoreException;
+
     List getAllProjectGroupsWithBuildDetails();
 
     List getAllProjectsWithAllDetails();
@@ -149,6 +152,9 @@
         throws ContinuumObjectNotFoundException, ContinuumStoreException;
 
     ProjectGroup getProjectGroupByGroupId( String groupId )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException;
+
+    ProjectGroup getProjectGroupByGroupIdWithProjects( String groupId )
         throws ContinuumStoreException, ContinuumObjectNotFoundException;
 
     BuildResult getLatestBuildResultForProject( int projectId );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=393487&r1=393486&r2=393487&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Wed Apr 12 08:36:47 2006
@@ -824,7 +824,7 @@
         {
             try
             {
-                projectGroup = store.getProjectGroupByGroupId( projectGroup.getGroupId()
);
+                projectGroup = store.getProjectGroupByGroupIdWithProjects( projectGroup.getGroupId()
);
 
                 getLogger().info(
                     "Using existing project group with the group id: '" + projectGroup.getGroupId()
+ "'." );
@@ -845,7 +845,7 @@
 
                 int projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext
);
 
-                projectGroup = store.getProjectGroup( projectGroupId );
+                projectGroup = store.getProjectGroupWithProjects( projectGroupId );
             }
         }
         catch ( ContinuumStoreException e )

Modified: maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo?rev=393487&r1=393486&r2=393487&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo (original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo Wed
Apr 12 08:36:47 2006
@@ -39,10 +39,10 @@
           <version>1.0.0+</version>
           <type>String</type>
         </field>
-        <field jpox.mappedBy="projectGroup">
+        <field jpox.mappedBy="projectGroup" jpox.fetchGroupNames="projectgroup-projects
project-build-details">
           <name>projects</name>
           <version>1.0.0+</version>
-          <association stash.part="true" jpox.join="false">
+          <association jpox.join="false">
             <type>Project</type>
             <multiplicity>*</multiplicity>
           </association>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=393487&r1=393486&r2=393487&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
Wed Apr 12 08:36:47 2006
@@ -84,6 +84,8 @@
 
     private static final String PROJECT_DEPENDENCIES_FETCH_GROUP = "project-dependencies";
 
+    private static final String PROJECTGROUP_PROJECTS_FETCH_GROUP = "projectgroup-projects";
+
     private static final String DEFAULT_GROUP_ID = "default";
 
     // ----------------------------------------------------------------------
@@ -602,32 +604,7 @@
 
     public Collection getAllProjectGroupsWithProjects()
     {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( ProjectGroup.class, true );
-
-            Query query = pm.newQuery( extent );
-
-            query.setOrdering( "name ascending" );
-
-            Collection result = (Collection) query.execute();
-
-            result = pm.detachCopyAll( result );
-
-            tx.commit();
-
-            return result;
-        }
-        finally
-        {
-            rollback( tx );
-        }
+        return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECTGROUP_PROJECTS_FETCH_GROUP
);
     }
 
     public List getAllProjectsByName()
@@ -925,12 +902,31 @@
 
     public void removeProjectGroup( ProjectGroup projectGroup )
     {
-        // TODO: why do we need to do this? if not - build results are not removed and a
integrity constraint is violated. I assume its because of the fetch groups
-        for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
+        ProjectGroup pg = null;
+        try
+        {
+            pg = getProjectGroupWithProjects( projectGroup.getId() );
+        }
+        catch ( Exception e )
+        {
+            //Do nothing
+        }
+
+        if ( pg != null )
         {
-            removeProject( (Project) i.next() );
+            // TODO: why do we need to do this? if not - build results are not removed and
a integrity constraint is violated. I assume its because of the fetch groups
+            for ( Iterator i = pg.getProjects().iterator(); i.hasNext(); )
+            {
+                removeProject( (Project) i.next() );
+            }
+            removeObject( pg );
         }
-        removeObject( projectGroup );
+    }
+
+    public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
+        throws ContinuumObjectNotFoundException, ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECTGROUP_PROJECTS_FETCH_GROUP
);
     }
 
     public ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
@@ -1003,6 +999,13 @@
         return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
null );
     }
 
+    public ProjectGroup getProjectGroupByGroupIdWithProjects( String groupId )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
+                                                  PROJECTGROUP_PROJECTS_FETCH_GROUP );
+    }
+
     public Project getProjectWithBuildDetails( int projectId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
@@ -1016,7 +1019,8 @@
 
         try
         {
-            group = (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", DEFAULT_GROUP_ID,
null );
+            group = (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", DEFAULT_GROUP_ID,
+                                                       PROJECTGROUP_PROJECTS_FETCH_GROUP
);
         }
         catch ( ContinuumObjectNotFoundException e )
         {

Modified: maven/continuum/branches/continuum-1.0.x/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?rev=393487&r1=393486&r2=393487&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
Wed Apr 12 08:36:47 2006
@@ -33,14 +33,11 @@
 import org.codehaus.plexus.jdo.ConfigurableJdoFactory;
 import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
 import org.codehaus.plexus.jdo.JdoFactory;
-import org.codehaus.plexus.util.IOUtil;
 import org.jpox.SchemaTool;
 
 import javax.jdo.JDODetachedFieldAccessException;
 import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -344,7 +341,7 @@
     public void testGetProjectGroup()
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
-        ProjectGroup retrievedGroup = store.getProjectGroup( defaultProjectGroup.getId()
);
+        ProjectGroup retrievedGroup = store.getProjectGroupWithProjects( defaultProjectGroup.getId()
);
         assertProjectGroupEquals( retrievedGroup, defaultProjectGroup );
 
         List projects = retrievedGroup.getProjects();
@@ -705,7 +702,7 @@
 
         store.removeProject( project );
 
-        ProjectGroup projectGroup = store.getProjectGroup( defaultProjectGroup.getId() );
+        ProjectGroup projectGroup = store.getProjectGroupWithProjects( defaultProjectGroup.getId()
);
         assertEquals( "check size is now 1", 1, projectGroup.getProjects().size() );
         assertProjectEquals( (Project) projectGroup.getProjects().get( 0 ), testProject2
);
 



Mime
View raw message