Return-Path: Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org Received: (qmail 59658 invoked from network); 9 Aug 2007 20:53:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Aug 2007 20:53:33 -0000 Received: (qmail 9751 invoked by uid 500); 9 Aug 2007 20:53:32 -0000 Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org Received: (qmail 9718 invoked by uid 500); 9 Aug 2007 20:53:32 -0000 Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: continuum-dev@maven.apache.org Delivered-To: mailing list continuum-commits@maven.apache.org Received: (qmail 9705 invoked by uid 99); 9 Aug 2007 20:53:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2007 13:53:32 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2007 20:53:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F32711A981A; Thu, 9 Aug 2007 13:53:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: continuum-commits@maven.apache.org From: evenisse@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070809205308.F32711A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 Emmanuel Venisse @@ -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 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 @@ - + projectGroupSummary ${projectGroupId} 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 @@

-
+ + - " onclick="document.forms.projectsForm.submit();" /> + " onclick="document.forms.projectsForm.methodToCall='remove';document.forms.projectsForm.submit();" /> + " onclick="document.forms.projectsForm.methodToCall='build';document.forms.projectsForm.submit();" />