continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r224534 - 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-core/...
Date Sat, 23 Jul 2005 20:04:12 GMT
Author: trygvis
Date: Sat Jul 23 13:03:53 2005
New Revision: 224534

URL: http://svn.apache.org/viewcvs?rev=224534&view=rev
Log:
o Storing new project groups that's found while building projects.

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-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    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/DefaultContinuumTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
    maven/continuum/trunk/continuum-core/src/test/resources/projects/continuum/pom.xml

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=224534&r1=224533&r2=224534&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
Sat Jul 23 13:03:53 2005
@@ -147,6 +147,9 @@
     ContinuumProjectGroup getProjectGroupByName( String name )
         throws ContinuumStoreException;
 
+    ContinuumProjectGroup getProjectGroupByGroupId( String groupId )
+        throws ContinuumStoreException;
+
     Collection getProjectGroups()
         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=224534&r1=224533&r2=224534&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
Sat Jul 23 13:03:53 2005
@@ -46,14 +46,14 @@
 import org.apache.maven.continuum.project.builder.maven.MavenOneContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.maven.MavenTwoContinuumProjectBuilder;
 import org.apache.maven.continuum.scheduler.ContinuumScheduler;
-import org.apache.maven.continuum.scheduler.ContinuumSchedulerConstants;
 import org.apache.maven.continuum.scm.ScmResult;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ProjectSorter;
 import org.codehaus.plexus.action.ActionManager;
-import org.codehaus.plexus.action.Action;
 import org.codehaus.plexus.action.ActionNotFoundException;
+import org.codehaus.plexus.action.Action;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
@@ -460,11 +460,60 @@
         ContinuumProjectBuildingResult result = (ContinuumProjectBuildingResult)
             context.get( CreateProjectsFromMetadata.KEY_PROJECT_BUILDING_RESULT );
 
+        // ----------------------------------------------------------------------
+        // Look for any warnings.
+        // ----------------------------------------------------------------------
+
         if ( result.getWarnings().size() > 0 )
         {
             return result;
         }
 
+        // ----------------------------------------------------------------------
+        // Save any new project groups that we've found
+        // ----------------------------------------------------------------------
+
+        ContinuumProjectGroup projectGroup = null;
+
+        for ( Iterator it = result.getProjectGroups().iterator(); it.hasNext(); )
+        {
+            projectGroup = (ContinuumProjectGroup) it.next();
+
+            getLogger().info( "Looking for project group '" + projectGroup.getGroupId() +
"'." );
+
+            try
+            {
+                try
+                {
+                    projectGroup = store.getProjectGroupByGroupId( projectGroup.getGroupId()
);
+
+                    getLogger().info( "Existed." );
+                }
+                catch ( ContinuumObjectNotFoundException e )
+                {
+                    projectGroup = store.addProjectGroup( projectGroup );
+
+                    getLogger().info( "Added." );
+                }
+            }
+            catch ( ContinuumStoreException e )
+            {
+                throw new ContinuumException( "Error while querying for project group.",
e );
+            }
+        }
+
+        if ( projectGroup == null )
+        {
+            getLogger().info( "Using default project group." );
+
+            projectGroup = getDefaultProjectGroup();
+        }
+
+        // ----------------------------------------------------------------------
+        // Save all the projects
+        // TODO: Validate all the projects before saving them
+        // ----------------------------------------------------------------------
+
         List projects = result.getProjects();
 
         for ( Iterator i = projects.iterator(); i.hasNext(); )
@@ -473,6 +522,8 @@
 
             project.setExecutorId( buildExecutorId );
 
+            project.setProjectGroup( projectGroup );
+
             context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
 
             executeAction( "validate-project", context );
@@ -746,34 +797,6 @@
     public ContinuumBuildSettings getDefaultBuildSettings()
     {
         return initializer.getDefaultBuildSettings();
-    }
-
-    // ----------------------------------------------------------------------
-    // Default Object Management
-    // ----------------------------------------------------------------------
-
-    private boolean defaultScheduleExists()
-    {
-        // ----------------------------------------------------------------------
-        // Perform a lookup for the default schedule to see if it exists.
-        // ----------------------------------------------------------------------
-
-        return true;
-    }
-
-    private void createDefaultSchedule()
-    {
-        ContinuumSchedule schedule = new ContinuumSchedule();
-
-        schedule.setName( ContinuumSchedulerConstants.DEFAULT_SCHEDULE_NAME );
-
-        schedule.setDescription( ContinuumSchedulerConstants.DEFAULT_SCHEDULE_NAME );
-
-        schedule.setScmMode( ContinuumSchedulerConstants.DEFAULT_SCHEDULE_SCM_MODE );
-
-        schedule.setActive( true );
-
-        schedule.setCronExpression( ContinuumSchedulerConstants.DEFAULT_CRON_EXPRESSION );
     }
 
     // ----------------------------------------------------------------------

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=224534&r1=224533&r2=224534&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
Sat Jul 23 13:03:53 2005
@@ -1,7 +1,20 @@
+package org.apache.maven.continuum.core.action;
+
 /*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-package org.apache.maven.continuum.core.action;
 
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.project.ContinuumProject;

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=224534&r1=224533&r2=224534&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Sat Jul 23 13:03:53 2005
@@ -186,7 +186,7 @@
             return null;
         }
 
-        projectGroup.setGroupId( projectGroup.getGroupId() );
+        projectGroup.setGroupId( mavenProject.getGroupId() );
 
         // ----------------------------------------------------------------------
         // Name

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=224534&r1=224533&r2=224534&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
Sat Jul 23 13:03:53 2005
@@ -806,41 +806,18 @@
     public ContinuumProjectGroup getProjectGroupByName( String name )
         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" );
-
-            query.declareParameters( "String filter" );
-
-            query.setFilter( "this.name == name" );
-
-            Collection result = (Collection) query.execute( name );
-
-            if ( result.size() == 0 )
-            {
-                throw new ContinuumObjectNotFoundException( ContinuumProjectGroup.class.getName(),
name );
-            }
-
-            Object object = pm.detachCopy( result.iterator().next() );
+        return (ContinuumProjectGroup) getObjectFromQuery( ContinuumProjectGroup.class,
+                                                           "name",
+                                                           name );
+    }
 
-            commit( tx );
+    public ContinuumProjectGroup getProjectGroupByGroupId( String groupId )
+        throws ContinuumStoreException
+    {
+        return (ContinuumProjectGroup) getObjectFromQuery( ContinuumProjectGroup.class,
+                                                           "groupId",
+                                                           groupId );
 
-            return (ContinuumProjectGroup) object;
-        }
-        finally
-        {
-            rollback( tx );
-        }
     }
 
     // ----------------------------------------------------------------------
@@ -1201,6 +1178,51 @@
         catch ( JDOObjectNotFoundException e )
         {
             throw new ContinuumObjectNotFoundException( clazz.getName(), id );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    private Object getObjectFromQuery( Class clazz, String idField, String id )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( clazz, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareParameters( "String " + idField );
+
+            query.setFilter( "this." + idField + " == " + idField );
+
+            Collection result = (Collection) query.execute( id );
+
+            if ( result.size() == 0 )
+            {
+                throw new ContinuumObjectNotFoundException( clazz.getName(), id );
+            }
+
+            if ( result.size() > 1 )
+            {
+                throw new ContinuumStoreException( "A query for object of " +
+                                                   "type " + clazz.getName() + " on the "
+
+                                                   "field '" + idField + "' returned more
than one object." );
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            commit( tx );
+
+            return object;
         }
         finally
         {

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=224534&r1=224533&r2=224534&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Sat Jul 23 13:03:53 2005
@@ -18,7 +18,6 @@
 
 import org.apache.maven.continuum.project.MavenTwoProject;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
-import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java?rev=224534&r1=224533&r2=224534&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java
Sat Jul 23 13:03:53 2005
@@ -25,7 +25,7 @@
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id:$
+ * @version $Id$
  */
 public class ConfigurationServiceTest
     extends PlexusTestCase
@@ -102,4 +102,4 @@
         assertEquals( "/jdks/1.5", jdk.getHome() );
 
     }
-}
\ No newline at end of file
+}

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java?rev=224534&r1=224533&r2=224534&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
Sat Jul 23 13:03:53 2005
@@ -26,6 +26,7 @@
 
 import org.apache.maven.continuum.project.ContinuumNotifier;
 import org.apache.maven.continuum.project.MavenTwoProject;
+import org.apache.maven.continuum.project.ContinuumProjectGroup;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 
@@ -120,18 +121,42 @@
         assertNotNull( result );
 
         // ----------------------------------------------------------------------
-        //
+        // Assert the warnings
         // ----------------------------------------------------------------------
 
         assertNotNull( result.getWarnings() );
 
         assertEquals( 1, result.getWarnings().size() );
 
-        assertTrue( result.getWarnings().get( 0 ).toString().indexOf( "I'm-not-here-project/pom.xml"
) != -1 );
+        assertTrue( "Does not end with I'm-not-here-project/pom.xml",
+                    result.getWarnings().get( 0 ).toString().endsWith( "I'm-not-here-project/pom.xml"
) );
 
         // ----------------------------------------------------------------------
-        //
+        // Assert the project group built
         // ----------------------------------------------------------------------
+
+        assertNotNull( result.getProjectGroups() );
+
+        assertEquals( 1, result.getProjectGroups().size() );
+
+        ContinuumProjectGroup projectGroup = (ContinuumProjectGroup) result.getProjectGroups().iterator().next();
+
+        assertEquals( "projectGroup.groupId", "org.apache.maven.continuum", projectGroup.getGroupId()
);
+
+        assertEquals( "projectGroup.name", "Continuum Parent Project", projectGroup.getName()
);
+
+        assertEquals( "projectGroup.description", "Continuum Project Description", projectGroup.getDescription()
);
+
+        assertEquals( "projectGroup.url", "http://cvs.continuum.codehaus.org/", projectGroup.getUrl()
);
+
+        assertEquals( "projectGroup.issueManagementUrl", "http://jira.codehaus.org/browse/CONTINUUM",
+                      projectGroup.getIssueManagementUrl() );
+
+        // ----------------------------------------------------------------------
+        // Assert the projects built
+        // ----------------------------------------------------------------------
+
+        assertNotNull( result.getProjects() );
 
         assertEquals( 5, result.getProjects().size() );
 

Modified: maven/continuum/trunk/continuum-core/src/test/resources/projects/continuum/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/resources/projects/continuum/pom.xml?rev=224534&r1=224533&r2=224534&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/resources/projects/continuum/pom.xml (original)
+++ maven/continuum/trunk/continuum-core/src/test/resources/projects/continuum/pom.xml Sat
Jul 23 13:03:53 2005
@@ -5,6 +5,7 @@
   <version>1.0-alpha-2-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>Continuum Parent Project</name>
+  <description>Continuum Project Description</description>
   <url>http://cvs.continuum.codehaus.org/</url>
   <ciManagement>
     <system>continuum</system>
@@ -16,6 +17,10 @@
       </notifier>
     </notifiers>
   </ciManagement>
+  <issueManagement>
+    <system>jira</system>
+    <url>http://jira.codehaus.org/browse/CONTINUUM</url>
+  </issueManagement>
   <inceptionYear>2003</inceptionYear>
   <mailingLists>
     <mailingList>



Mime
View raw message