continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r564378 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ continuum-webapp/src...
Date Thu, 09 Aug 2007 20:53:08 GMT
Author: evenisse
Date: Thu Aug  9 13:53:07 2007
New Revision: 564378

URL: http://svn.apache.org/viewvc?view=rev&rev=564378
Log:
[CONTINUUM-983] Add build action to build a subset of group members based on selection.

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?view=diff&rev=564378&r1=564377&r2=564378
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Thu Aug  9 13:53:07 2007
@@ -148,6 +148,16 @@
     List getProjectsInBuildOrder()
         throws CycleDetectedException, ContinuumException;
 
+    /**
+     * take a collection of projects and sort for order
+     *
+     * @param projects
+     * @return
+     * @throws CycleDetectedException
+     */
+    List getProjectsInBuildOrder( Collection projects )
+        throws CycleDetectedException;
+
     void buildProjects()
         throws ContinuumException;
 
@@ -199,8 +209,9 @@
 
     List getChangesSinceLastSuccess( int projectId, int buildResultId )
         throws ContinuumException;
-    
-    void removeBuildResult( int buildId ) throws ContinuumException;
+
+    void removeBuildResult( int buildId )
+        throws ContinuumException;
 
     // ----------------------------------------------------------------------
     // Projects

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?view=diff&rev=564378&r1=564377&r2=564378
==============================================================================
--- 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  9 13:53:07 2007
@@ -1115,7 +1115,7 @@
      * @return
      * @throws CycleDetectedException
      */
-    private List getProjectsInBuildOrder( Collection projects )
+    public List getProjectsInBuildOrder( Collection projects )
         throws CycleDetectedException
     {
         if ( projects == null || projects.isEmpty() )

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java?view=diff&rev=564378&r1=564377&r2=564378
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
Thu Aug  9 13:53:07 2007
@@ -20,11 +20,20 @@
  */
 
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+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.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -34,13 +43,40 @@
 public class ProjectsListAction
     extends ContinuumActionSupport
 {
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ContinuumStore store;
+
     private Collection selectedProjects;
 
     private String projectGroupName = "";
 
     private int projectGroupId;
 
-    public String remove()
+    private String methodToCall;
+
+    public String execute()
+        throws Exception
+    {
+        if ( StringUtils.isEmpty( methodToCall ) )
+        {
+            return SUCCESS;
+        }
+
+        if ( "build".equals( methodToCall ) )
+        {
+            return build();
+        }
+        else if ( "remove".equals( methodToCall ) )
+        {
+            return remove();
+        }
+
+        return SUCCESS;
+    }
+
+    private String remove()
         throws ContinuumException
     {
         try
@@ -75,6 +111,86 @@
         return SUCCESS;
     }
 
+    private String build()
+        throws ContinuumException
+    {
+        try
+        {
+            checkModifyProjectGroupAuthorization( getProjectGroupName() );
+        }
+        catch ( AuthorizationRequiredException e )
+        {
+            return REQUIRES_AUTHORIZATION;
+        }
+
+        if ( selectedProjects != null && !selectedProjects.isEmpty() )
+        {
+            ArrayList<Project> projectsList = new ArrayList();
+            for ( Iterator i = selectedProjects.iterator(); i.hasNext(); )
+            {
+                int projectId = Integer.parseInt( (String) i.next() );
+                Project p = getContinuum().getProjectWithAllDetails( projectId );
+                projectsList.add( p );
+            }
+
+            List sortedProjects;
+            try
+            {
+                sortedProjects = getContinuum().getProjectsInBuildOrder( projectsList );
+            }
+            catch ( CycleDetectedException e )
+            {
+                sortedProjects = projectsList;
+            }
+
+            //TODO : Change this part because it's a duplicate of DefaultContinuum.buildProjectGroup*
+            BuildDefinition groupDefaultBD = null;
+            try
+            {
+                groupDefaultBD = store.getDefaultBuildDefinitionForProjectGroup( projectGroupId
);
+            }
+            catch ( ContinuumObjectNotFoundException e )
+            {
+                throw new ContinuumException( "Project Group (id=" + projectGroupId +
+                    " doens't have a default build definition, this should be impossible,
it should always have a default definition set." );
+            }
+            catch ( ContinuumStoreException e )
+            {
+                throw new ContinuumException( "Project Group (id=" + projectGroupId +
+                    " doens't have a default build definition, this should be impossible,
it should always have a default definition set." );
+            }
+
+            for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
+            {
+                int buildDefId = groupDefaultBD.getId();
+                Project project = (Project) i.next();
+                BuildDefinition projectDefaultBD = null;
+                try
+                {
+                    projectDefaultBD = store.getDefaultBuildDefinitionForProject( project.getId()
);
+                }
+                catch ( ContinuumObjectNotFoundException e )
+                {
+                    getLogger().debug( e.getMessage() );
+                }
+                catch ( ContinuumStoreException e )
+                {
+                    getLogger().debug( e.getMessage() );
+                }
+
+                if ( projectDefaultBD != null )
+                {
+                    buildDefId = projectDefaultBD.getId();
+                    getLogger().debug( "Project " + project.getId() +
+                        " has own default build definition, will use it instead of group's."
);
+                }
+                getContinuum().buildProject( project.getId(), buildDefId, ContinuumProjectState.TRIGGER_FORCED
);
+            }
+        }
+
+        return SUCCESS;
+    }
+
     public String getProjectGroupName()
         throws ContinuumException
     {
@@ -104,5 +220,10 @@
     public void setProjectGroupId( int projectGroupId )
     {
         this.projectGroupId = projectGroupId;
+    }
+
+    public void setMethodToCall( String methodToCall )
+    {
+        this.methodToCall = methodToCall;
     }
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml?view=diff&rev=564378&r1=564377&r2=564378
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml Thu Aug  9 13:53:07
2007
@@ -201,7 +201,7 @@
       </result>
     </action>
 
-    <action name="removeProjects" class="projects" method="remove">
+    <action name="ProjectsList" class="projects">
       <result name="success" type="redirect-action">
         <param name="actionName">projectGroupSummary</param>
         <param name="projectGroupId">${projectGroupId}</param>

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp?view=diff&rev=564378&r1=564377&r2=564378
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp
Thu Aug  9 13:53:07 2007
@@ -28,7 +28,8 @@
 
   <h3><ww:text name="projectGroup.projects.title"/></h3>
 
-  <form id="projectsForm" action="removeProjects.action" method="post">
+  <form id="projectsForm" action="ProjectsList.action" method="post">
+    <input type="hidden" name="methodToCall" value="" />
   <ec:table items="projects"
             var="project"
             showExports="false"
@@ -194,7 +195,8 @@
             <td>
               <redback:ifAuthorized permission="continuum-modify-group" resource="${projectGroupName}">
                 <input type="hidden" name="projectGroupId" value="${project.projectGroupId}"
/>
-                <input type="button" name="delete-project" value="<ww:text name="delete"/>"
onclick="document.forms.projectsForm.submit();" />
+                <input type="button" name="delete-projects" value="<ww:text name="delete"/>"
onclick="document.forms.projectsForm.methodToCall='remove';document.forms.projectsForm.submit();"
/>
+                <input type="button" name="build-projects" value="<ww:text name="build"/>"
onclick="document.forms.projectsForm.methodToCall='build';document.forms.projectsForm.submit();"
/>
               </redback:ifAuthorized>
             </td>
           </tr>



Mime
View raw message