continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r233297 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/core/action/ continuum-model...
Date Thu, 18 Aug 2005 07:48:10 GMT
Author: brett
Date: Thu Aug 18 00:47:52 2005
New Revision: 233297

URL: http://svn.apache.org/viewcvs?rev=233297&view=rev
Log:
force all projects into a group

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
    maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
    maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=233297&r1=233296&r2=233297&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
Thu Aug 18 00:47:52 2005
@@ -133,8 +133,9 @@
     void updateBuildResult( BuildResult build )
         throws ContinuumStoreException;
 
-    Project addProject( Project project );
-
     Project getProjectWithBuildDetails( int projectId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException;
+
+    ProjectGroup getDefaultProjectGroup()
+        throws ContinuumStoreException;
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=233297&r1=233296&r2=233297&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Thu Aug 18 00:47:52 2005
@@ -354,6 +354,15 @@
 
         context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
 
+        try
+        {
+            context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT_GROUP, store.getDefaultProjectGroup()
);
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error getting the default project group to work
with" );
+        }
+
         executeAction( "validate-project", context );
 
         executeAction( "store-project", context );

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java?rev=233297&r1=233296&r2=233297&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
Thu Aug 18 00:47:52 2005
@@ -18,6 +18,7 @@
 
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
@@ -37,13 +38,15 @@
     {
         Project project = getUnvalidatedProject( context );
 
+        ProjectGroup projectGroup = getUnvalidatedProjectGroup( context );
+
         // ----------------------------------------------------------------------
         //
         // ----------------------------------------------------------------------
 
-        // TODO: group!
+        projectGroup.addProject( project );
 
-        project = store.addProject( project );
+        store.updateProjectGroup( projectGroup );
 
         context.put( KEY_PROJECT_ID, new Integer( project.getId() ) );
 

Modified: maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo?rev=233297&r1=233296&r2=233297&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo Thu Aug
18 00:47:52 2005
@@ -31,7 +31,7 @@
     <class name="Project" detachable="true" identity-type="application"
            objectid-class="javax.jdo.identity.IntIdentity">
       <field name="id" primary-key="true" value-strategy="native"/>
-      <field name="projectGroup" default-fetch-group="true"/>
+      <field name="projectGroup" default-fetch-group="true" null-value="exception"/>
       <!-- Foreign key -->
       <field name="name"/>
       <field name="description"/>

Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=233297&r1=233296&r2=233297&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
Thu Aug 18 00:47:52 2005
@@ -37,6 +37,7 @@
 import javax.jdo.Query;
 import javax.jdo.Transaction;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -73,6 +74,8 @@
 
     private static final String PROJECT_ALL_DETAILS_FETCH_GROUP = "project-all-details";
 
+    private static final String DEFAULT_GROUP_ID = "default";
+
     // ----------------------------------------------------------------------
     // Component Lifecycle
     // ----------------------------------------------------------------------
@@ -603,6 +606,11 @@
 
     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(); )
+        {
+            removeProject( (Project) i.next() );
+        }
         removeObject( projectGroup );
     }
 
@@ -727,19 +735,28 @@
         return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
null );
     }
 
-    /**
-     * @param project
-     * @return
-     * @todo REMOVE
-     */
-    public Project addProject( Project project )
-    {
-        return (Project) addObject( project );
-    }
-
     public Project getProjectWithBuildDetails( int projectId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
         return (Project) getObjectById( Project.class, projectId, PROJECT_BUILD_DETAILS_FETCH_GROUP
);
+    }
+
+    public ProjectGroup getDefaultProjectGroup()
+        throws ContinuumStoreException
+    {
+        ProjectGroup group;
+        try
+        {
+            group = (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", DEFAULT_GROUP_ID,
null );
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            group = new ProjectGroup();
+            group.setName( "Default Project Group" );
+            group.setGroupId( DEFAULT_GROUP_ID );
+            group.setDescription( "Contains all projects that do not have a group of their
own" );
+            group = addProjectGroup( group );
+        }
+        return group;
     }
 }

Modified: maven/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java?rev=233297&r1=233296&r2=233297&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
(original)
+++ maven/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
Thu Aug 18 00:47:52 2005
@@ -46,12 +46,6 @@
 public abstract class AbstractContinuumTest
     extends PlexusTestCase
 {
-    /**
-     * When adding projects using addProject( project ) the project will be
-     * put in this group. All project has to belong to a group.
-     */
-    private ProjectGroup defaultProjectGroup;
-
     private ContinuumStore store;
 
     // ----------------------------------------------------------------------
@@ -66,17 +60,6 @@
         setUpConfigurationService( (ConfigurationService) lookup( ConfigurationService.ROLE
) );
 
         getStore();
-
-        ProjectGroup projectGroup = new ProjectGroup();
-
-        projectGroup.setName( "Test Project Group" );
-
-        projectGroup.setGroupId( "foo.test" );
-
-        projectGroup.setDescription(
-            "This is the default group that all projects will be added to when using addProject()."
);
-
-        defaultProjectGroup = store.addProjectGroup( projectGroup );
     }
 
     public static void setUpConfigurationService( ConfigurationService configurationService
)
@@ -90,8 +73,9 @@
     }
 
     protected ProjectGroup getDefaultProjectGroup()
+        throws ContinuumStoreException
     {
-        return defaultProjectGroup;
+        return store.getDefaultProjectGroup();
     }
 
     // ----------------------------------------------------------------------



Mime
View raw message