continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r232681 [2/2] - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/notification/ continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-...
Date Mon, 15 Aug 2005 00:35:26 GMT
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=232681&r1=232680&r2=232681&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
Sun Aug 14 17:34:39 2005
@@ -24,7 +24,6 @@
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.apache.maven.continuum.model.system.Installation;
-import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumBuildSettings;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
@@ -40,10 +39,7 @@
 import javax.jdo.PersistenceManagerFactory;
 import javax.jdo.Query;
 import javax.jdo.Transaction;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
@@ -76,8 +72,6 @@
 
     private static final String BUILD_DETAIL_FG = "build-detail";
 
-    private static final String SCHEDULE_DETAIL_FG = "schedule-detail";
-
     private static final String BUILD_SETTINGS_DETAIL_FG = "build-settings-detail";
 
     private static final String PROJECT_WITH_BUILDS_FETCH_GROUP = "project-with-builds";
@@ -186,6 +180,7 @@
 
             result = pm.detachCopyAll( result );
 
+            // TODO: we want to do this on updating the latest build, not all gets.
             for ( Iterator it = result.iterator(); it.hasNext(); )
             {
                 setProjectState( (ContinuumProject) it.next() );
@@ -308,7 +303,7 @@
         }
     }
 
-    public ContinuumBuild addBuild( String projectId, ContinuumBuild build )
+    public BuildResult addBuildResult( ContinuumProject project, BuildResult build )
         throws ContinuumStoreException
     {
         PersistenceManager pm = pmf.getPersistenceManager();
@@ -319,19 +314,21 @@
         {
             tx.begin();
 
-            ContinuumProject project = getContinuumProject( pm, projectId, false );
+            project = getContinuumProject( pm, project.getId(), true );
 
-            build = (ContinuumBuild) makePersistent( pm, build, false );
+            build = (BuildResult) makePersistent( pm, build, false );
 
-            project.setLatestBuildId( build.getId() );
+            // TODO: these are in the wrong spot - set them on success
+            project.setLatestBuildId( Integer.toString( build.getId() ) );
 
             project.setBuildNumber( project.getBuildNumber() + 1 );
 
-            project.getBuilds().add( build );
+            project.addBuild( build );
 
             tx.commit();
 
-            return (ContinuumBuild) getDetailedObject( ContinuumBuild.class, build.getId(),
BUILD_DETAIL_FG );
+            // TODO: I think this can be replaced by a detach
+            return getBuildResult( build.getId() );
         }
         finally
         {
@@ -339,20 +336,13 @@
         }
     }
 
-    public ContinuumBuild updateBuild( ContinuumBuild build )
+    public void updateBuildResult( BuildResult build )
         throws ContinuumStoreException
     {
         updateObject( build );
-        return build;
-    }
-
-    public ContinuumBuild getBuild( String buildId )
-        throws ContinuumStoreException
-    {
-        return (ContinuumBuild) getDetailedObject( ContinuumBuild.class, buildId, BUILD_DETAIL_FG
);
     }
 
-    public ContinuumBuild getLatestBuildForProject( String projectId )
+    public BuildResult getLatestBuildResultForProject( String projectId )
         throws ContinuumStoreException
     {
         PersistenceManager pm = pmf.getPersistenceManager();
@@ -367,114 +357,24 @@
 
             String buildId = project.getLatestBuildId();
 
-            if ( buildId == null )
-            {
-                tx.commit();
-
-                return null;
-            }
-
-            Object id = pm.newObjectIdInstance( ContinuumBuild.class, buildId );
-
-            Object object = pm.getObjectById( id );
-
-            ContinuumBuild build = (ContinuumBuild) pm.detachCopy( object );
-
-            tx.commit();
-
-            return build;
-        }
-        finally
-        {
-            rollback( tx );
-        }
-    }
-
-    public Collection getBuildsForProject( String projectId, int start, int end )
-        throws ContinuumStoreException
-    {
-        ContinuumProject project = (ContinuumProject) getDetailedObject( ContinuumProject.class,
projectId,
-                                                                         PROJECT_DETAIL_FG
);
-        List builds = new ArrayList( project.getBuilds() );
-        Collections.sort( builds, new Comparator()
-        {
-            public int compare( Object o1, Object o2 )
+            if ( buildId != null )
             {
-                ContinuumBuild b1 = (ContinuumBuild) o1;
-                ContinuumBuild b2 = (ContinuumBuild) o2;
-
-                return (int) ( ( b2 != null ? b2.getStartTime() : 0 ) - ( b1 != null ? b1.getStartTime()
: 0 ) );
-            }
-        } );
-        return builds;
-/* TODO: remove - check usages and replace by project.getBuilds
-        PersistenceManager pm = pmf.getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( ContinuumBuild.class, true );
-
-            Query query = pm.newQuery( extent );
-
-            query.setFilter( "this.project.id == id" );
-
-            query.declareImports( "import java.lang.String" );
-
-            query.declareParameters( "String id" );
-
-            query.setOrdering( "startTime descending" );
-
-            Collection builds = (Collection) query.execute( projectId );
-
-            builds = pm.detachCopyAll( builds );
-
-            tx.commit();
-
-            return builds;
-        }
-        finally
-        {
-            rollback( tx );
-        }
-*/
-    }
-
-    public List getChangedFilesForBuild( String buildId )
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = pmf.getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
+                Object id = pm.newObjectIdInstance( BuildResult.class, Integer.valueOf( buildId
) );
 
-            ContinuumBuild build = getContinuumBuild( pm, buildId );
+                Object object = pm.getObjectById( id );
 
-            ScmResult scmResult = build.getScmResult();
+                BuildResult build = (BuildResult) pm.detachCopy( object );
 
-            if ( scmResult == null )
-            {
                 tx.commit();
 
-                return null;
+                return build;
             }
-
-            List files = (List) pm.detachCopyAll( scmResult.getChanges() );
-
-            tx.commit();
-
-            return files;
         }
         finally
         {
             rollback( tx );
         }
+        return null;
     }
 
     public void removeNotifier( ProjectNotifier notifier )
@@ -569,7 +469,7 @@
     private ContinuumProject setProjectState( ContinuumProject project )
         throws ContinuumStoreException
     {
-        ContinuumBuild build = getLatestBuildForProject( project.getId() );
+        BuildResult build = getLatestBuildResultForProject( project.getId() );
 
         if ( build == null )
         {
@@ -593,13 +493,6 @@
         Object id = pm.newObjectIdInstance( ContinuumProject.class, projectId );
 
         return (ContinuumProject) pm.getObjectById( id );
-    }
-
-    private ContinuumBuild getContinuumBuild( PersistenceManager pm, String buildId )
-    {
-        Object id = pm.newObjectIdInstance( ContinuumBuild.class, buildId );
-
-        return (ContinuumBuild) pm.getObjectById( id );
     }
 
     private Object addObject( Object object, String detailedFetchGroup )

Modified: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/ContinuumStateContentGenerator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/ContinuumStateContentGenerator.java?rev=232681&r1=232680&r2=232681&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/ContinuumStateContentGenerator.java
(original)
+++ maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/tool/ContinuumStateContentGenerator.java
Sun Aug 14 17:34:39 2005
@@ -16,14 +16,13 @@
  * limitations under the License.
  */
 
-import org.codehaus.plexus.formica.web.ContentGenerator;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-
-import org.apache.maven.continuum.project.ContinuumProject;
-import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.codehaus.plexus.formica.web.ContentGenerator;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -33,7 +32,9 @@
     extends AbstractLogEnabled
     implements ContentGenerator
 {
-    /** @plexus.requirement */
+    /**
+     * @plexus.requirement
+     */
     private Continuum continuum;
 
     public String generate( Object item )
@@ -44,9 +45,10 @@
         {
             ContinuumProject project = (ContinuumProject) item;
 
+            // TODO: can't we just use project.getState()?
             try
             {
-                ContinuumBuild build = continuum.getLatestBuildForProject( project.getId()
);
+                BuildResult build = continuum.getLatestBuildResultForProject( project.getId()
);
 
                 if ( build == null )
                 {
@@ -64,7 +66,7 @@
         }
         else
         {
-            state = ( (ContinuumBuild) item ).getState();
+            state = ( (BuildResult) item ).getState();
         }
 
         if ( state == ContinuumProjectState.NEW )

Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumXmlRpc.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumXmlRpc.java?rev=232681&r1=232680&r2=232681&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumXmlRpc.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumXmlRpc.java
Sun Aug 14 17:34:39 2005
@@ -43,26 +43,15 @@
 
     Hashtable getScmResultForProject( String projectId );
 
-    Hashtable getLatestBuildForProject( String projectId );
-
     // ----------------------------------------------------------------------
     // Building
     // ----------------------------------------------------------------------
 
-    Hashtable buildProject( String projectId,
-                            boolean force );
+    Hashtable buildProject( String projectId, boolean force );
 
     // ----------------------------------------------------------------------
     // Builds
     // ----------------------------------------------------------------------
-
-    Hashtable getBuild( String buildId );
-
-    Hashtable getBuildsForProject( String projectId,
-                                   int start,
-                                   int end );
-
-    Hashtable getChangedFilesForBuild( String buildId );
 
     // ----------------------------------------------------------------------
     // Maven 2.x projects

Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java?rev=232681&r1=232680&r2=232681&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
Sun Aug 14 17:34:39 2005
@@ -20,7 +20,6 @@
 import org.apache.maven.continuum.execution.shell.ShellBuildExecutor;
 import org.apache.maven.continuum.model.scm.ScmResult;
 import org.apache.maven.continuum.project.AntProject;
-import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.MavenOneProject;
 import org.apache.maven.continuum.project.MavenTwoProject;
@@ -125,22 +124,6 @@
         }
     }
 
-    public Hashtable getLatestBuildForProject( String projectId )
-    {
-        try
-        {
-            ContinuumBuild build = continuum.getLatestBuildForProject( projectId );
-
-            return makeHashtable( "latestBuild", convertContinuumBuild( build ) );
-        }
-        catch ( Throwable e )
-        {
-            return handleException( "ContinuumXmlRpc.getLatestBuildForProject()", "Project
id: '" + projectId + "'.",
-                                    e );
-        }
-
-    }
-
     // ----------------------------------------------------------------------
     // Build handling
     // ----------------------------------------------------------------------
@@ -156,69 +139,6 @@
         catch ( Throwable e )
         {
             return handleException( "ContinuumXmlRpc.buildProject()", "Project id: '" + projectId
+ "'.", e );
-        }
-    }
-
-    public Hashtable getBuild( String buildId )
-    {
-        try
-        {
-            ContinuumBuild build = continuum.getBuild( buildId );
-
-            return makeHashtable( "build", convertContinuumBuild( build ) );
-        }
-        catch ( Throwable e )
-        {
-            return handleException( "ContinuumXmlRpc.getBuild()", "Build id: '" + buildId
+ "'.", e );
-        }
-    }
-
-    public Hashtable getBuildsForProject( String projectId, int start, int end )
-    {
-        try
-        {
-            if ( start != 0 || end != 0 )
-            {
-                getLogger().warn( "ContinuumXmlRpc.getBuildsForProject() " +
-                    "doesn't support usage of the start and end parameters yet." );
-            }
-
-            // TODO: use start and end
-            Collection builds = continuum.getBuildsForProject( projectId );
-
-            Vector result = new Vector( builds.size() );
-
-            for ( Iterator it = builds.iterator(); it.hasNext(); )
-            {
-                result.add( convertContinuumBuild( it.next() ) );
-            }
-
-            return makeHashtable( "builds", result );
-        }
-        catch ( Throwable e )
-        {
-            return handleException( "ContinuumXmlRpc.getBuildsForProject()", "Project id:
'" + projectId + "'.", e );
-        }
-    }
-
-    public Hashtable getChangedFilesForBuild( String buildId )
-    {
-        try
-        {
-            Collection changedFiles = continuum.getChangedFilesForBuild( buildId );
-
-            Vector result = new Vector( changedFiles.size() );
-
-            for ( Iterator it = changedFiles.iterator(); it.hasNext(); )
-            {
-                result.add( convertScmFile( it.next() ) );
-            }
-
-            return makeHashtable( "changedFiles", result );
-        }
-        catch ( Throwable e )
-        {
-            return handleException( "ContinuumXmlRpc.getBuildResultForProject()", "Build
id: '" + buildId + "'.", e );
         }
     }
 



Mime
View raw message