continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r538178 - in /maven/continuum/trunk/continuum-xmlrpc: continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ continuum-xmlrpc-api/src/main/mdo/ continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ c...
Date Tue, 15 May 2007 13:22:33 GMT
Author: evenisse
Date: Tue May 15 06:22:32 2007
New Revision: 538178

URL: http://svn.apache.org/viewvc?view=rev&rev=538178
Log:
Add more information in xmlrpc results

Modified:
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/SampleClient.java
    maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java?view=diff&rev=538178&r1=538177&r2=538178
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
Tue May 15 06:22:32 2007
@@ -170,6 +170,17 @@
     // ----------------------------------------------------------------------
 
     /**
+     * Returns the latest build result for the project.
+     *
+     * @param projectId The project id
+     * @return The build result
+     * @throws ContinuumException
+     * @throws XmlRpcException
+     */
+    BuildResult getLatestBuildResult( int projectId )
+        throws ContinuumException, XmlRpcException;
+
+    /**
      * Returns the build result.
      *
      * @param projectId The project id

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml?view=diff&rev=538178&r1=538177&r2=538178
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/mdo/continuum-service.xml
Tue May 15 06:22:32 2007
@@ -437,6 +437,16 @@
           <type>int</type>
         </field>
         <field>
+          <name>error</name>
+          <version>1.1.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>trigger</name>
+          <version>1.1.0+</version>
+          <type>int</type>
+        </field>
+        <field>
           <name>project</name>
           <version>1.1.0+</version>
           <required>true</required>
@@ -456,20 +466,33 @@
       ]]></description>
       <fields>
         <field>
-          <name>trigger</name>
+          <name>scmResult</name>
           <version>1.1.0+</version>
-          <type>int</type>
+          <association>
+            <type>ScmResult</type>
+          </association>
         </field>
         <field>
-          <name>error</name>
+          <name>changesSinceLastSuccess</name>
           <version>1.1.0+</version>
-          <type>String</type>
+          <association>
+            <type>ChangeSet</type>
+            <multiplicity>*</multiplicity>
+          </association>
         </field>
         <field>
-          <name>scmResult</name>
+          <name>testResult</name>
           <version>1.1.0+</version>
           <association>
-            <type>ScmResult</type>
+            <type>TestResult</type>
+          </association>
+        </field>
+        <field>
+          <name>modifiedDependencies</name>
+          <version>1.1.0+</version>
+          <association>
+            <type>ProjectDependency</type>
+            <multiplicity>*</multiplicity>
           </association>
         </field>
       </fields>

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java?view=diff&rev=538178&r1=538177&r2=538178
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
Tue May 15 06:22:32 2007
@@ -303,6 +303,19 @@
     // Build Results
     // ----------------------------------------------------------------------
 
+    public BuildResult getLatestBuildResult( int projectId )
+        throws ContinuumException
+    {
+        try
+        {
+            return continuum.getLatestBuildResult( projectId );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumException( "The remote method failed.", e );
+        }
+    }
+
     public BuildResult getBuildResult( int projectId, int buildId )
         throws ContinuumException
     {

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/SampleClient.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/SampleClient.java?view=diff&rev=538178&r1=538177&r2=538178
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/SampleClient.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/SampleClient.java
Tue May 15 06:22:32 2007
@@ -1,8 +1,34 @@
 package org.apache.maven.continuum.xmlrpc.client;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
 import org.apache.maven.continuum.xmlrpc.project.AddingResult;
+import org.apache.maven.continuum.xmlrpc.project.BuildResult;
+import org.apache.maven.continuum.xmlrpc.project.ProjectDependency;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
 import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
+import org.apache.maven.continuum.xmlrpc.scm.ChangeSet;
+import org.apache.maven.continuum.xmlrpc.scm.ScmResult;
+import org.apache.maven.continuum.xmlrpc.test.SuiteResult;
+import org.apache.maven.continuum.xmlrpc.test.TestCaseFailure;
+import org.apache.maven.continuum.xmlrpc.test.TestResult;
 
 import java.net.URL;
 import java.util.Iterator;
@@ -14,10 +40,12 @@
  */
 public class SampleClient
 {
+    private static ContinuumXmlRpcClient client;
+
     public static void main( String[] args )
         throws Exception
     {
-        ContinuumXmlRpcClient client = new ContinuumXmlRpcClient( new URL( args[0] ), args[1],
args[2] );
+        client = new ContinuumXmlRpcClient( new URL( args[0] ), args[1], args[2] );
 
         System.out.println( "Adding project..." );
         AddingResult result = client.addMavenTwoProject( "http://svn.codehaus.org/plexus/plexus-utils/trunk/pom.xml"
);
@@ -84,6 +112,12 @@
         }
         System.out.println( "Build done with state=" + state + "." );
 
+        System.out.println( "Build result." );
+        System.out.println( "=====================" );
+        printBuildResult( client.getLatestBuildResult( ps.getId() ) );
+
+        System.out.println();
+
         System.out.println( "Build output." );
         System.out.println( "=====================" );
         System.out.println( client.getBuildOutput( ps.getId(), ps.getLatestBuildId() ) );
@@ -107,10 +141,20 @@
         for ( Iterator i = projects.iterator(); i.hasNext(); )
         {
             ps = (ProjectSummary) i.next();
-            System.out.println( "Removing '" + ps.getName() + "' - " + ps.getVersion() +
" (" + ps.getId() + ")..." );
+            System.out.println( "Removing '" + ps.getName() + "' - " + ps.getVersion() +
" (" + ps.getId() + ")'..." );
             client.removeProject( ps.getId() );
             System.out.println( "Done." );
         }
+
+        System.out.println();
+
+        System.out.println( "Remove project group." );
+        System.out.println( "=====================" );
+        ProjectGroupSummary pg = client.getProjectGroupSummary( projectGroupId );
+        System.out.println(
+            "Removing Project Group '" + pg.getName() + "' - " + pg.getGroupId() + " (" +
pg.getId() + ")'..." );
+        client.removeProjectGroup( pg.getId() );
+        System.out.println( "Done." );
     }
 
     public static void printProjectSummary( ProjectSummary project )
@@ -122,5 +166,118 @@
         System.out.println( "Name: " + project.getName() );
         System.out.println( "Description: " + project.getDescription() );
         System.out.println( "SCM Url: " + project.getScmUrl() );
+    }
+
+    public static void printBuildResult( BuildResult result )
+    {
+        System.out.println( "Id: " + result.getId() );
+        System.out.println( "Project Id: " + result.getProject().getId() );
+        System.out.println( "Build Number: " + result.getBuildNumber() );
+        System.out.println( "Start Time: " + result.getStartTime() );
+        System.out.println( "End Time: " + result.getEndTime() );
+        System.out.println( "State: " + client.getProjectStatusAsString( result.getState()
) );
+        System.out.println( "Trigger: " + result.getTrigger() );
+        System.out.println( "Is success: " + result.isSuccess() );
+        System.out.println( "Exit code: " + result.getExitCode() );
+        System.out.println( "Error: " + result.getError() );
+
+        if ( result.getModifiedDependencies() != null )
+        {
+            System.out.println( "Modified dependencies:" );
+            for ( Iterator i = result.getModifiedDependencies().iterator(); i.hasNext();
)
+            {
+                printDependency( (ProjectDependency) i.next() );
+            }
+        }
+
+        if ( result.getScmResult() != null )
+        {
+            System.out.println( "Scm Result:" );
+            printScmResult( result.getScmResult() );
+        }
+
+        if ( result.getChangesSinceLastSuccess() != null )
+        {
+            System.out.println( "Changes since last success:" );
+            for ( Iterator i = result.getChangesSinceLastSuccess().iterator(); i.hasNext();
)
+            {
+                printChangeSet( (ChangeSet) i.next() );
+            }
+        }
+
+        if ( result.getTestResult() != null )
+        {
+            System.out.println( "TestResult:" );
+            printTestResult( result.getTestResult() );
+        }
+    }
+
+    public static void printDependency( ProjectDependency dep )
+    {
+        System.out.println( "Group Id: " + dep.getGroupId() );
+        System.out.println( "Artifact Id: " + dep.getArtifactId() );
+        System.out.println( "Version: " + dep.getVersion() );
+    }
+
+    public static void printScmResult( ScmResult scmResult )
+    {
+        System.out.println( "Command Line: " + scmResult.getCommandLine() );
+        System.out.println( "Command Output: " + scmResult.getCommandOutput() );
+        System.out.println( "SCM Providr Messqge: " + scmResult.getProviderMessage() );
+        System.out.println( "Is Success: " + scmResult.isSuccess() );
+        System.out.println( "Exception: " + scmResult.getException() );
+
+        if ( scmResult.getChanges() != null )
+        {
+            System.out.println( "Changes:" );
+            for ( Iterator i = scmResult.getChanges().iterator(); i.hasNext(); )
+            {
+                printChangeSet( (ChangeSet) i.next() );
+            }
+        }
+        System.out.println( scmResult.getCommandLine() );
+    }
+
+    public static void printChangeSet( ChangeSet changeSet )
+    {
+        System.out.println( "Author: " + changeSet.getAuthor() );
+        System.out.println( "Date: " + changeSet.getDateAsDate() );
+        System.out.println( "Comment: " + changeSet.getComment() );
+
+        if ( changeSet.getFiles() != null )
+        {
+            System.out.println( "Author: " + changeSet.getFiles() );
+        }
+    }
+
+    public static void printTestResult( TestResult testresult )
+    {
+        System.out.println( "Total Time: " + testresult.getTotalTime() );
+        System.out.println( "Nb Tests: " + testresult.getTestCount() );
+        System.out.println( "Nb Failures: " + testresult.getFailureCount() );
+
+        if ( testresult.getSuiteResults() != null )
+        {
+            System.out.println( "Suite Results:" );
+        }
+    }
+
+    public static void printSuiteResult( SuiteResult result )
+    {
+        System.out.println( "Name: " + result.getName() );
+        System.out.println( "Total Time: " + result.getTotalTime() );
+        System.out.println( "Nb Tests: " + result.getTestCount() );
+        System.out.println( "Nb Failures: " + result.getFailureCount() );
+
+        if ( result.getFailures() != null )
+        {
+            for ( Iterator i = result.getFailures().iterator(); i.hasNext(); )
+            {
+                System.out.println( "Failure:" );
+                TestCaseFailure failure = (TestCaseFailure) i.next();
+                System.out.println( "Name: " + failure.getName() );
+                System.out.println( "Exception: " + failure.getException() );
+            }
+        }
     }
 }

Modified: maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?view=diff&rev=538178&r1=538177&r2=538178
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Tue May 15 06:22:32 2007
@@ -28,14 +28,24 @@
 import org.apache.maven.continuum.xmlrpc.project.BuildResultSummary;
 import org.apache.maven.continuum.xmlrpc.project.Project;
 import org.apache.maven.continuum.xmlrpc.project.ProjectDependency;
+import org.apache.maven.continuum.xmlrpc.project.ProjectDeveloper;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroup;
 import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
+import org.apache.maven.continuum.xmlrpc.project.ProjectNotifier;
 import org.apache.maven.continuum.xmlrpc.project.ProjectSummary;
+import org.apache.maven.continuum.xmlrpc.scm.ChangeFile;
+import org.apache.maven.continuum.xmlrpc.scm.ChangeSet;
+import org.apache.maven.continuum.xmlrpc.scm.ScmResult;
+import org.apache.maven.continuum.xmlrpc.test.SuiteResult;
+import org.apache.maven.continuum.xmlrpc.test.TestCaseFailure;
+import org.apache.maven.continuum.xmlrpc.test.TestResult;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -210,6 +220,18 @@
     // Build Results
     // ----------------------------------------------------------------------
 
+    public BuildResult getLatestBuildResult( int projectId )
+        throws ContinuumException
+    {
+        ProjectSummary ps = getProjectSummary( projectId );
+        checkViewProjectGroupAuthorization( ps.getProjectGroup().getName() );
+
+        org.apache.maven.continuum.model.project.BuildResult buildResult =
+            continuum.getLatestBuildResultForProject( projectId );
+
+        return getBuildResult( projectId, buildResult.getId() );
+    }
+
     public BuildResult getBuildResult( int projectId, int buildId )
         throws ContinuumException
     {
@@ -331,7 +353,7 @@
             return null;
         }
 
-        Project ps = new Project();
+        ProjectSummary ps = new Project();
         ps.setArtifactId( project.getArtifactId() );
         ps.setBuildNumber( project.getBuildNumber() );
         ps.setDescription( project.getDescription() );
@@ -375,13 +397,78 @@
             p.setDependencies( deps );
         }
 
-        //TODO
-        //p.setBuildDefinitions( );
-        //p.setDevelopers( );
-        //p.setNotifiers( );
+        //TODO: p.setBuildDefinitions( );
+
+        if ( project.getDevelopers() != null )
+        {
+            for ( Iterator i = project.getDevelopers().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.ProjectDeveloper developer =
+                    (org.apache.maven.continuum.model.project.ProjectDeveloper) i.next();
+                p.addDeveloper( populateProjectDeveloper( developer ) );
+            }
+        }
+
+        if ( project.getNotifiers() != null )
+        {
+            for ( Iterator i = project.getNotifiers().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.project.ProjectNotifier notifier =
+                    (org.apache.maven.continuum.model.project.ProjectNotifier) i.next();
+                p.addNotifier( populateProjectNotifier( notifier ) );
+            }
+        }
+
         return p;
     }
 
+    private ProjectDeveloper populateProjectDeveloper(
+        org.apache.maven.continuum.model.project.ProjectDeveloper developer )
+    {
+        if ( developer == null )
+        {
+            return null;
+        }
+
+        ProjectDeveloper res = new ProjectDeveloper();
+        res.setContinuumId( developer.getContinuumId() );
+        res.setEmail( developer.getEmail() );
+        res.setName( developer.getName() );
+        res.setScmId( developer.getScmId() );
+        return res;
+    }
+
+    private ProjectNotifier populateProjectNotifier( org.apache.maven.continuum.model.project.ProjectNotifier
notifier )
+    {
+        if ( notifier == null )
+        {
+            return null;
+        }
+
+        ProjectNotifier res = new ProjectNotifier();
+        res.setEnabled( notifier.isEnabled() );
+        res.setFrom( notifier.getFrom() );
+        res.setId( notifier.getId() );
+        res.setRecipientType( notifier.getRecipientType() );
+        res.setSendOnError( notifier.isSendOnError() );
+        res.setSendOnFailure( notifier.isSendOnFailure() );
+        res.setSendOnSuccess( notifier.isSendOnSuccess() );
+        res.setSendOnWarning( notifier.isSendOnWarning() );
+        res.setType( notifier.getType() );
+
+        if ( notifier.getConfiguration() != null )
+        {
+            Map conf = new HashMap();
+            for ( Iterator i = notifier.getConfiguration().keySet().iterator(); i.hasNext();
)
+            {
+                String key = (String) i.next();
+                conf.put( key, notifier.getConfiguration().get( key ) );
+            }
+            res.setConfiguration( conf );
+        }
+        return res;
+    }
+
     private org.apache.maven.continuum.model.project.Project populateProject( ProjectSummary
projectSummary )
     {
         if ( projectSummary == null )
@@ -399,7 +486,7 @@
         project.setId( projectSummary.getId() );
         project.setLatestBuildId( projectSummary.getLatestBuildId() );
         project.setName( projectSummary.getName() );
-        //project.setProjectGroup( populateProjectGroupSummary( projectSummary.getProjectGroup()
) );
+        //TODO: project.setProjectGroup( populateProjectGroupSummary( projectSummary.getProjectGroup()
) );
         project.setScmTag( projectSummary.getScmTag() );
         project.setScmUrl( projectSummary.getScmUrl() );
         project.setScmUseCache( projectSummary.isScmUseCache() );
@@ -434,7 +521,7 @@
             return null;
         }
 
-        ProjectGroup g = new ProjectGroup();
+        ProjectGroupSummary g = new ProjectGroup();
         g.setDescription( group.getDescription() );
         g.setGroupId( group.getGroupId() );
         g.setId( group.getId() );
@@ -472,7 +559,7 @@
         {
             return null;
         }
-        BuildResult br = new BuildResult();
+        BuildResultSummary br = new BuildResult();
         br.setBuildNumber( buildResult.getBuildNumber() );
         br.setEndTime( buildResult.getEndTime() );
         br.setError( buildResult.getError() );
@@ -482,32 +569,42 @@
         br.setState( buildResult.getState() );
         br.setSuccess( buildResult.isSuccess() );
         br.setTrigger( buildResult.getTrigger() );
+        br.setProject( populateProjectSummary( buildResult.getProject() ) );
         return br;
     }
 
     private BuildResult populateBuildResult( org.apache.maven.continuum.model.project.BuildResult
buildResult )
+        throws ContinuumException
     {
         if ( buildResult == null )
         {
             return null;
         }
         BuildResult br = (BuildResult) populateBuildResultSummary( buildResult );
-        //TODO:
-        //br.setScmResult( populateScmResult(br.getScmResult()));
+
+        List changeSet = continuum.getChangesSinceLastSuccess( br.getProject().getId(), br.getId()
);
+        if ( changeSet != null )
+        {
+            for ( Iterator i = changeSet.iterator(); i.hasNext(); )
+            {
+                br.addChangesSinceLastSucces(
+                    populateChangeSet( (org.apache.maven.continuum.model.scm.ChangeSet) i.next()
) );
+            }
+        }
+
+        br.setScmResult( populateScmResult( buildResult.getScmResult() ) );
+
         if ( buildResult.getModifiedDependencies() != null )
         {
-            List deps = new ArrayList();
             for ( Iterator i = buildResult.getModifiedDependencies().iterator(); i.hasNext();
)
             {
                 org.apache.maven.continuum.model.project.ProjectDependency dependency =
                     (org.apache.maven.continuum.model.project.ProjectDependency) i.next();
                 ProjectDependency dep = populateProjectDependency( dependency );
-                deps.add( dep );
+                br.addModifiedDependency( dep );
             }
-            //br.setModifiedDependencies( deps );
         }
-        //br.setProject( populateProjectSummary(buildResult.getProject() ) );
-        //br.setTestResult( populateTestResult( buildResult.getTestResult() ) );
+        br.setTestResult( populateTestResult( buildResult.getTestResult() ) );
         return br;
     }
 
@@ -548,6 +645,137 @@
             }
         }
 
+        return res;
+    }
+
+    private ScmResult populateScmResult( org.apache.maven.continuum.model.scm.ScmResult scmResult
)
+    {
+        if ( scmResult == null )
+        {
+            return null;
+        }
+
+        ScmResult res = new ScmResult();
+
+        if ( scmResult.getChanges() != null )
+        {
+            for ( Iterator i = scmResult.getChanges().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.scm.ChangeSet changeSet =
+                    (org.apache.maven.continuum.model.scm.ChangeSet) i.next();
+                res.addChange( populateChangeSet( changeSet ) );
+            }
+        }
+
+        res.setCommandLine( scmResult.getCommandLine() );
+        res.setCommandOutput( scmResult.getCommandOutput() );
+        res.setException( scmResult.getException() );
+        res.setProviderMessage( scmResult.getProviderMessage() );
+        res.setSuccess( scmResult.isSuccess() );
+        return res;
+    }
+
+    private ChangeSet populateChangeSet( org.apache.maven.continuum.model.scm.ChangeSet changeSet
)
+    {
+        if ( changeSet == null )
+        {
+            return null;
+        }
+
+        ChangeSet res = new ChangeSet();
+        res.setAuthor( changeSet.getAuthor() );
+        res.setComment( changeSet.getComment() );
+        res.setDate( changeSet.getDate() );
+
+        if ( changeSet.getFiles() != null )
+        {
+            for ( Iterator i = changeSet.getFiles().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.scm.ChangeFile changeFile =
+                    (org.apache.maven.continuum.model.scm.ChangeFile) i.next();
+                res.addFile( populateChangeFile( changeFile ) );
+            }
+        }
+
+        res.setId( changeSet.getId() );
+        return res;
+    }
+
+    private ChangeFile populateChangeFile( org.apache.maven.continuum.model.scm.ChangeFile
changeFile )
+    {
+        if ( changeFile == null )
+        {
+            return null;
+        }
+
+        ChangeFile res = new ChangeFile();
+        res.setName( changeFile.getName() );
+        res.setRevision( changeFile.getRevision() );
+        res.setStatus( changeFile.getStatus() );
+        return res;
+    }
+
+    private TestResult populateTestResult( org.apache.maven.continuum.model.scm.TestResult
testResult )
+    {
+        if ( testResult == null )
+        {
+            return null;
+        }
+
+        TestResult res = new TestResult();
+        res.setFailureCount( testResult.getFailureCount() );
+
+        if ( testResult.getSuiteResults() != null )
+        {
+            for ( Iterator i = testResult.getSuiteResults().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.scm.SuiteResult suiteResult =
+                    (org.apache.maven.continuum.model.scm.SuiteResult) i.next();
+                res.addSuiteResult( populateSuiteResult( suiteResult ) );
+            }
+        }
+
+        res.setTestCount( testResult.getTestCount() );
+        res.setTotalTime( testResult.getTotalTime() );
+        return res;
+    }
+
+    private SuiteResult populateSuiteResult( org.apache.maven.continuum.model.scm.SuiteResult
suiteresult )
+    {
+        if ( suiteresult == null )
+        {
+            return null;
+        }
+
+        SuiteResult res = new SuiteResult();
+        res.setFailureCount( suiteresult.getFailureCount() );
+
+        if ( suiteresult.getFailures() != null )
+        {
+            for ( Iterator i = suiteresult.getFailures().iterator(); i.hasNext(); )
+            {
+                org.apache.maven.continuum.model.scm.TestCaseFailure failure =
+                    (org.apache.maven.continuum.model.scm.TestCaseFailure) i.next();
+                res.addFailure( populateTestCaseFailure( failure ) );
+            }
+        }
+
+        res.setName( suiteresult.getName() );
+        res.setTestCount( suiteresult.getTestCount() );
+        res.setTotalTime( suiteresult.getTotalTime() );
+        return res;
+    }
+
+    private TestCaseFailure populateTestCaseFailure( org.apache.maven.continuum.model.scm.TestCaseFailure
failure )
+    {
+        if ( failure == null )
+        {
+            return null;
+        }
+
+        TestCaseFailure res = new TestCaseFailure();
+        res.setException( failure.getException() );
+        res.setName( failure.getName() );
         return res;
     }
 }



Mime
View raw message