You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ha...@apache.org on 2007/02/27 18:34:45 UTC

svn commit: r512333 - in /maven/sandbox/trunk/continuum/continuum-client/src/main: java/org/apache/maven/continuum/client/ mdo/

Author: handyande
Date: Tue Feb 27 09:34:44 2007
New Revision: 512333

URL: http://svn.apache.org/viewvc?view=rev&rev=512333
Log:
Handle build results now too.
There is a continuum server side bug with getBuildResultsForProject though, so it is not working yet

Modified:
    maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ContinuumClient.java
    maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ProjectsReader.java
    maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/SampleClient.java
    maven/sandbox/trunk/continuum/continuum-client/src/main/mdo/continuum-client.xml

Modified: maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ContinuumClient.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ContinuumClient.java?view=diff&rev=512333&r1=512332&r2=512333
==============================================================================
--- maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ContinuumClient.java (original)
+++ maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ContinuumClient.java Tue Feb 27 09:34:44 2007
@@ -24,6 +24,7 @@
 import org.apache.maven.continuum.client.ClientException;
 import org.apache.maven.continuum.client.project.Project;
 import org.apache.maven.continuum.client.project.ProjectSummary;
+import org.apache.maven.continuum.client.project.BuildResult;
 
 import java.util.Hashtable;
 import java.net.URL;
@@ -128,5 +129,42 @@
         throws ClientException
     {
         return getProject( summary.getId() );
+    }
+
+    public BuildResult[] getBuildResultsForProject( int projectId )
+        throws ClientException
+    {
+        try
+        {
+            return source.readBuildResultsForProject( projectId );
+        }
+        catch ( Exception e )
+        {
+            throw new ClientException( e );
+        }
+    }
+
+    public BuildResult[] getBuildResultsForProject( Project project )
+        throws ClientException
+    {
+        return getBuildResultsForProject( project.getId() );
+    }
+
+    public BuildResult getBuildResult( int buildId )
+        throws ClientException
+    {
+        try
+        {
+            BuildResult ret = new BuildResult();
+
+            ret.setId( buildId );
+            source.refreshBuildResult( ret );
+
+            return ret;
+        }
+        catch ( Exception e )
+        {
+            throw new ClientException( e );
+        }
     }
 }

Modified: maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ProjectsReader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ProjectsReader.java?view=diff&rev=512333&r1=512332&r2=512333
==============================================================================
--- maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ProjectsReader.java (original)
+++ maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/ProjectsReader.java Tue Feb 27 09:34:44 2007
@@ -26,6 +26,7 @@
 import org.apache.maven.continuum.client.project.ProjectDeveloper;
 import org.apache.maven.continuum.client.project.Schedule;
 import org.apache.maven.continuum.client.project.ProjectSummary;
+import org.apache.maven.continuum.client.project.BuildResult;
 import org.apache.xmlrpc.XmlRpcClient;
 import org.apache.xmlrpc.XmlRpcException;
 
@@ -236,22 +237,7 @@
         instance.setState( Integer.parseInt( (String) hashtable.get( "state" ) ) );
         instance.setOldState( Integer.parseInt( (String) hashtable.get( "oldState" ) ) );
         instance.setBuildNumber( Integer.parseInt( (String) hashtable.get( "buildNumber" ) ) );
-        Vector deps = (Vector) hashtable.get( "dependencies" );
-        if ( deps != null )
-        {
-            Iterator it = deps.iterator();
-            List vals = new ArrayList();
-            while ( it.hasNext() )
-            {
-                Hashtable dep = (Hashtable) it.next();
-                ProjectDependency dependency = new ProjectDependency();
-                dependency.setArtifactId( (String) dep.get( "artifactId" ) );
-                dependency.setGroupId( (String) dep.get( "groupId" ) );
-                dependency.setVersion( (String) dep.get( "version" ) );
-                vals.add( dependency );
-            }
-            instance.setDependencies( vals );
-        }
+        instance.setDependencies( parseDependencies( (Vector) hashtable.get( "dependencies" ) ) );
         Hashtable par = (Hashtable) hashtable.get( "parent" );
         if ( par != null )
         {
@@ -342,6 +328,72 @@
         return instance;
     }
 
+    public BuildResult[] readBuildResultsForProject( int projectId )
+        throws XmlRpcException, IOException
+    {
+        XmlRpcClient client = new XmlRpcClient( server );
+        Vector vect = new Vector();
+        vect.add( new Integer( projectId ) );
+        Object obj = client.execute( "continuum.getBuildResultsForProject", vect );
+        Collection set = new ArrayList();
+        System.out.println( obj );
+        if ( obj instanceof Hashtable )
+        {
+            Hashtable table = (Hashtable) obj;
+            Vector builds = (Vector) table.get( "builds" );
+            Iterator it = builds.iterator();
+            while ( it.hasNext() )
+            {
+                Hashtable build = (Hashtable) it.next();
+                set.add( populateBuildResult( build, new BuildResult() ) );
+            }
+        }
+        else if ( obj instanceof XmlRpcException )
+        {
+            throw (XmlRpcException) obj;
+        }
+
+        return (BuildResult[]) set.toArray( new BuildResult[set.size()] );
+    }
+
+    public void refreshBuildResult( BuildResult build )
+        throws XmlRpcException, IOException
+    {
+        XmlRpcClient client = new XmlRpcClient( server );
+        Vector vect = new Vector();
+        vect.add( new Integer( build.getId() ) );
+        Object obj = client.execute( "continuum.getBuildResult", vect );
+        if ( obj instanceof Hashtable )
+        {
+            Hashtable table = (Hashtable) obj;
+            populateBuildResult( (Hashtable) table.get( "build" ), build );
+        }
+        else if ( obj instanceof XmlRpcException )
+        {
+            throw (XmlRpcException) obj;
+        }
+    }
+
+    BuildResult populateBuildResult( Hashtable hashtable, BuildResult instance )
+    {
+        instance.setId( Integer.parseInt( (String) hashtable.get( "id" ) ) );
+        instance.setState( Integer.parseInt( (String) hashtable.get( "state" ) ) );
+        instance.setBuildNumber( Integer.parseInt( (String) hashtable.get( "buildNumber" ) ) );
+        instance.setTrigger( Integer.parseInt( (String) hashtable.get( "trigger" ) ) );
+        instance.setStartTime( Long.parseLong( (String) hashtable.get( "startTime") ) );
+        instance.setEndTime( Long.parseLong( (String) hashtable.get( "endTime" ) ) );
+        instance.setError( (String) hashtable.get( "error" ) );
+        instance.setSuccess( hashtable.get( "success" ).equals( "true" ) );
+        instance.setExitCode( Integer.parseInt( (String) hashtable.get( "exitCode" ) ) );
+// TODO: build the ScmResult
+//        instance.setScmResult( (ScmResult) hashtable.get( "scmResult" ) );
+// TODO: build the TestResult
+//        instance.setTestResult( ( TestResult ) hashtable.get( "testResult" ) );
+        instance.setModifiedDependencies( parseDependencies( (Vector) hashtable.get( "modifiedDependencies" ) ) );
+
+        return instance;
+    }
+
     private Hashtable projectToHashtable( Project project )
     {
         Hashtable map = new Hashtable();
@@ -366,4 +418,25 @@
         }
     }
 
+    private List parseDependencies( Vector deps )
+    {
+        if ( deps == null )
+        {
+            return null;
+        }
+
+        Iterator it = deps.iterator();
+        List vals = new ArrayList();
+        while ( it.hasNext() )
+        {
+            Hashtable dep = (Hashtable) it.next();
+            ProjectDependency dependency = new ProjectDependency();
+            dependency.setArtifactId( (String) dep.get( "artifactId" ) );
+            dependency.setGroupId( (String) dep.get( "groupId" ) );
+            dependency.setVersion( (String) dep.get( "version" ) );
+            vals.add( dependency );
+        }
+
+        return vals;
+    }
 }

Modified: maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/SampleClient.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/SampleClient.java?view=diff&rev=512333&r1=512332&r2=512333
==============================================================================
--- maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/SampleClient.java (original)
+++ maven/sandbox/trunk/continuum/continuum-client/src/main/java/org/apache/maven/continuum/client/SampleClient.java Tue Feb 27 09:34:44 2007
@@ -2,8 +2,10 @@
 
 import org.apache.maven.continuum.client.project.Project;
 import org.apache.maven.continuum.client.project.ProjectSummary;
+import org.apache.maven.continuum.client.project.BuildResult;
 
 import java.net.URL;
+import java.util.Date;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -78,6 +80,12 @@
 
                     System.out.println( "State: " + ContinuumClient.getStatusMessage( project.getState() ) );
 
+                    BuildResult build = client.getBuildResult( project.getLatestBuildId() );
+
+                    System.out.println( "Latest build:" );
+                    System.out.println( "    BuildId: " + build.getId() );
+                    System.out.println( "    Start time: " + new Date( build.getStartTime() ) );
+                    System.out.println( "    End time: " + new Date( build.getEndTime() ) );
                 }
                 catch ( Exception e )
                 {

Modified: maven/sandbox/trunk/continuum/continuum-client/src/main/mdo/continuum-client.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/continuum/continuum-client/src/main/mdo/continuum-client.xml?view=diff&rev=512333&r1=512332&r2=512333
==============================================================================
--- maven/sandbox/trunk/continuum/continuum-client/src/main/mdo/continuum-client.xml (original)
+++ maven/sandbox/trunk/continuum/continuum-client/src/main/mdo/continuum-client.xml Tue Feb 27 09:34:44 2007
@@ -393,14 +393,6 @@
       ]]></description>
       <fields>
         <field>
-          <name>project</name>
-          <version>1.1.0+</version>
-          <!-- required>true</required -->
-          <association xml.reference="true">
-            <type>Project</type>
-          </association>
-        </field>
-        <field>
           <name>id</name>
           <version>1.1.0+</version>
           <type>int</type>
@@ -424,13 +416,11 @@
         <field>
           <name>startTime</name>
           <version>1.1.0+</version>
-          <!-- TODO: Because JPOX persists as UTC and pulls back using the local time, we have to take over -->
           <type>long</type>
         </field>
         <field>
           <name>endTime</name>
           <version>1.1.0+</version>
-          <!-- TODO: Because JPOX persists as UTC and pulls back using the local time, we have to take over -->
           <type>long</type>
         </field>
         <field>