continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r358054 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ java/org/apache/maven/continuum/web/model/ java/org/apache/maven/continuum/web/util/ java/org/apache/maven/continuum/web/view/ webapp/
Date Tue, 20 Dec 2005 17:58:55 GMT
Author: evenisse
Date: Tue Dec 20 09:58:46 2005
New Revision: 358054

URL: http://svn.apache.org/viewcvs?rev=358054&view=rev
Log:
Use extremecomponents table with some cell renderer instead of full html

Added:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java
  (with props)
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
  (with props)
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java
  (with props)
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
    maven/continuum/trunk/continuum-webapp/src/main/webapp/summary.jsp

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java?rev=358054&r1=358053&r2=358054&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
Tue Dec 20 09:58:46 2005
@@ -17,36 +17,72 @@
  */
 
 import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.web.model.SummaryProjectModel;
 
 import com.opensymphony.xwork.ActionSupport;
 import com.opensymphony.webwork.ServletActionContext;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
 
 public class SummaryAction
     extends ActionSupport
 {
     private Continuum continuum;
     
-    private Collection projects;
-
     public String execute()
         throws Exception
     {
         try
         {
-            projects = continuum.getProjects();
-            ServletActionContext.getRequest().setAttribute( "projects", projects );
+            //TODO: Create a summary jpox request so code will be more simple and performance
will be better
+            Collection projects = continuum.getProjects();
+            Map buildResults = continuum.getLatestBuildResults();
+            Map buildResultsInSuccess = continuum.getBuildResultsInSuccess();
+
+            Collection summary = new ArrayList();
+
+            for ( Iterator i = projects.iterator(); i.hasNext(); )
+            {
+                Project project = (Project) i.next();
+                SummaryProjectModel model = new SummaryProjectModel();
+                model.setId( project.getId() );
+                model.setName( project.getName() );
+                model.setVersion( project.getVersion() );
+                model.setProjectGroupName( project.getProjectGroup().getName() );
+                if ( continuum.isInBuildingQueue( project.getId() ) || continuum.isInCheckoutQueue(
project.getId() ) )
+                {
+                    model.setInQueue( true );
+                }
+                else
+                {
+                    model.setInQueue( false );
+                }
+                model.setState( project.getState() );
+                model.setBuildNumber( project.getBuildNumber() );
+                BuildResult buildInSuccess = (BuildResult) buildResultsInSuccess.get( new
Integer( project.getId() ) );
+                if ( buildInSuccess != null )
+                {
+                    model.setBuildInSuccessId( buildInSuccess.getId() );
+                }
+                BuildResult latestBuild = (BuildResult) buildResults.get( new Integer( project.getId()
) );
+                if ( latestBuild != null )
+                {
+                    model.setLatestBuildId( latestBuild.getId() );
+                }
+                summary.add( model );
+            }
+
+            ServletActionContext.getRequest().setAttribute( "projects", summary );
         }
         catch( Exception e )
         {
             e.printStackTrace();
         }
         return SUCCESS;
-    }
-
-    public Collection getProjects()
-    {
-        return projects;
     }
 }

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java?rev=358054&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java
Tue Dec 20 09:58:46 2005
@@ -0,0 +1,120 @@
+package org.apache.maven.continuum.web.model;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class SummaryProjectModel
+{
+    private int id = -1;
+    private String name;
+    private String version;
+    private String projectGroupName;
+    private int latestBuildId = -1;
+    private int buildInSuccessId = -1;
+    private int buildNumber = -1;
+    private int state = -1;
+    private boolean inQueue = false;
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getProjectGroupName()
+    {
+        return projectGroupName;
+    }
+
+    public void setProjectGroupName( String projectGroupName )
+    {
+        this.projectGroupName = projectGroupName;
+    }
+
+    public int getLatestBuildId()
+    {
+        return latestBuildId;
+    }
+
+    public void setLatestBuildId( int latestBuildId )
+    {
+        this.latestBuildId = latestBuildId;
+    }
+
+    public int getBuildInSuccessId()
+    {
+        return buildInSuccessId;
+    }
+
+    public void setBuildInSuccessId( int buildInSuccessId )
+    {
+        this.buildInSuccessId = buildInSuccessId;
+    }
+
+    public int getBuildNumber()
+    {
+        return buildNumber;
+    }
+
+    public void setBuildNumber( int buildNumber )
+    {
+        this.buildNumber = buildNumber;
+    }
+
+    public int getState()
+    {
+        return state;
+    }
+
+    public void setState( int state )
+    {
+        this.state = state;
+    }
+
+    public boolean isInQueue()
+    {
+        return inQueue;
+    }
+
+    public void setInQueue( boolean inQueue )
+    {
+        this.inQueue = inQueue;
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/model/SummaryProjectModel.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java?rev=358054&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
Tue Dec 20 09:58:46 2005
@@ -0,0 +1,64 @@
+package org.apache.maven.continuum.web.util;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.project.ContinuumProjectState;
+
+public class StateGenerator
+{
+    public static final String NEW = "NEW";
+    public static final String BUILDING = "Building";
+    public static final String UPDATING = "Updating";
+    public static final String CHECKING_OUT = "Checking Out";
+    public static final String UNKNOWN = "Unknown";
+
+    public static String generate( int state, String contextPath )
+    {
+        if ( state == ContinuumProjectState.NEW )
+        {
+            return NEW;
+        }
+        else if ( state == ContinuumProjectState.OK )
+        {
+            return "<img src=\"" + contextPath + "/images/icon_success_sml.gif\" alt=\"Success\"
title=\"Success\" border=\"0\" />";
+        }
+        else if ( state == ContinuumProjectState.FAILED )
+        {
+            return "<img src=\"" + contextPath + "/images/icon_warning_sml.gif\" alt=\"Failed\"
title=\"Failed\" border=\"0\" />";
+        }
+        else if ( state == ContinuumProjectState.ERROR )
+        {
+            return "<img src=\"" + contextPath + "/images/icon_error_sml.gif\" alt=\"Error\"
title=\"Error\" border=\"0\" />";
+        }
+        else if ( state == ContinuumProjectState.BUILDING )
+        {
+            return BUILDING;
+        }
+        else if ( state == ContinuumProjectState.UPDATING )
+        {
+            return UPDATING;
+        }
+        else if ( state == ContinuumProjectState.CHECKING_OUT )
+        {
+            return CHECKING_OUT;
+        }
+        else
+        {
+            return UNKNOWN;
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java?rev=358054&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java
Tue Dec 20 09:58:46 2005
@@ -0,0 +1,62 @@
+package org.apache.maven.continuum.web.view;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.web.model.SummaryProjectModel;
+import org.apache.maven.continuum.web.util.StateGenerator;
+
+import org.extremecomponents.table.bean.Column;
+import org.extremecomponents.table.cell.DisplayCell;
+import org.extremecomponents.table.core.BaseModel;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Used in Summary view
+ */
+public class BuildCell
+    extends DisplayCell
+{
+    public void init(BaseModel model, Column column)
+    {
+        super.init(model, column);
+
+        SummaryProjectModel project = (SummaryProjectModel) model.getCurrentCollectionBean();
+
+        int buildNumber = project.getBuildNumber();
+
+        if ( project.isInQueue() )
+        {
+            column.setValue( "In&nbsp;queue" );
+        }
+        else if ( project.getState() == 1 || project.getState() == 2 || project.getState()
== 3 || project.getState() == 4 )
+        {
+            if ( project.getBuildNumber() > 0 )
+            {
+                column.setValue( "<a href=\"TO_BE_DEFINE\">" + project.getBuildNumber()
+ "</a>" );
+            }
+            else
+            {
+                column.setValue( "&nbsp;" );
+            }
+        }
+        else
+        {
+            column.setValue( "In&nbsp;progress" );
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/BuildCell.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java?rev=358054&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
Tue Dec 20 09:58:46 2005
@@ -0,0 +1,58 @@
+package org.apache.maven.continuum.web.view;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.web.model.SummaryProjectModel;
+import org.apache.maven.continuum.web.util.StateGenerator;
+
+import org.extremecomponents.table.bean.Column;
+import org.extremecomponents.table.cell.DisplayCell;
+import org.extremecomponents.table.core.BaseModel;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Used in Summary view
+ */
+public class StateCell
+    extends DisplayCell
+{
+    public void init(BaseModel model, Column column)
+    {
+        super.init(model, column);
+
+        SummaryProjectModel project = (SummaryProjectModel) model.getCurrentCollectionBean();
+
+        int latestBuildId = project.getLatestBuildId();
+
+        HttpServletRequest request = (HttpServletRequest) model.getPageContext().getRequest();
+
+        String state = StateGenerator.generate( project.getState(), request.getContextPath()
);
+
+        if ( project.getState() == 1 || project.getState() == 2 || project.getState() ==
3 || project.getState() == 4 )
+        {
+            if ( latestBuildId != -1 && !StateGenerator.NEW.equals( state ) )
+            {
+                column.setValue( "<a href=\"TO_BE_DEFINE\">" + state + "</a>"
);
+            }
+            else
+            {
+                column.setValue( state );
+            }
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/summary.jsp
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/webapp/summary.jsp?rev=358054&r1=358053&r2=358054&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/summary.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/summary.jsp Tue Dec 20 09:58:46
2005
@@ -6,6 +6,8 @@
         <title><ww:text name="summary.page.title"/></title>
     </head>
     <body>
+      <div id="h3">
+        <h3><ww:text name="summary.section.title"/></h3>
         <ec:table items="projects"
                   var="project"
                   showExports="false"
@@ -13,45 +15,17 @@
                   showStatusBar="false"
                   filterable="false">
           <ec:row highlightRow="true">
-            <ec:column property="status" title="&nbsp;">
-                &nbsp;
+            <ec:column property="state" title="&nbsp;" cell="org.apache.maven.continuum.web.view.StateCell"/>
+            <ec:column property="name">
+                <a href="TO_BE_DEFINE">${pageScope.project.name}</a>
             </ec:column>
-            <ec:column property="name"/>
             <ec:column property="version"/>
-            <ec:column property="buildNumber" title="summary.projectTable.build">
-                &nbsp;
-            </ec:column>
+            <ec:column property="buildNumber" title="summary.projectTable.build"  cell="org.apache.maven.continuum.web.view.BuildCell"/>
             <ec:column property="groupName" title="summary.projectTable.group">
-                ${pageScope.project.projectGroup.name}
+                ${pageScope.project.projectGroupName}
             </ec:column>
           </ec:row>
         </ec:table>
-      <div id="h3">
-        <h3><ww:text name="summary.section.title"/></h3>
-        <table border="1" cellspacing="2" cellpadding="3" width="100%" id="projectSummaryTable">
-    
-          <tbody><tr>
-            <th>&nbsp;</th>
-            <th width="100%"><ww:text name="summary.projectTable.name"/></th>
-            <th><ww:text name="summary.projectTable.version"/></th>
-            <th><ww:text name="summary.projectTable.build"/></th>
-            <th><ww:text name="summary.projectTable.group"/></th>
-            <th colspan="7"></th>
-          </tr>
-          <% String trStyle = "a"; %>
-          <ww:iterator value="projects">
-            <tr class="<%= "a".equals( trStyle ) ? "b" : "a" %>">
-              <td>&nbsp;</td>
-              <td><ww:property value="name"/></td>
-              <td><ww:property value="version"/></td>
-              <td>&nbsp;</td>
-              <td><ww:property value="projectGroup.name"/></td>
-              <td colspan="7">&nbsp;</td>
-            </tr>
-            <% trStyle = "a".equals( trStyle ) ? "b" : "a"; %>
-          </ww:iterator>
-          </tbody>
-        </table>
         <div class="functnbar3">
           <img src="<ww:url value="/images/icon_success_sml.gif"/>" alt="<ww:text
name="message.success"/>" title="<ww:text name="message.success"/>"/> <font
color="red">TODO</font>
           <img src="<ww:url value="/images/icon_warning_sml.gif"/>" alt="<ww:text
name="message.failed"/>" title="<ww:text name="message.failed"/>"/> <font color="red">TODO</font>



Mime
View raw message