Last result date shown as beginning of epoch when in-progress.
git-svn-id: https://svn.apache.org/repos/asf/continuum/trunk@1676048 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectViewAction.java b/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectViewAction.java
index c6e4275..bd04ea7 100644
--- a/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectViewAction.java
+++ b/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectViewAction.java
@@ -33,17 +33,17 @@
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
*/
-@Component( role = com.opensymphony.xwork2.Action.class, hint = "projectView", instantiationStrategy = "per-lookup" )
+@Component( role = com.opensymphony.xwork2.Action.class, hint = "projectView", instantiationStrategy = "per-lookup" )
public class ProjectViewAction
extends ContinuumActionSupport
{
- private static final Logger logger = LoggerFactory.getLogger( ProjectViewAction.class );
+ private static final Logger log = LoggerFactory.getLogger( ProjectViewAction.class );
private Project project;
- private int projectId;
+ private BuildResult latestResult;
- private String lastBuildDateTime;
+ private int projectId;
public String execute()
throws ContinuumException
@@ -60,19 +60,16 @@
}
project = getContinuum().getProjectWithAllDetails( projectId );
- if ( project.getLatestBuildId() > 0 )
+ int latestResultId = project.getLatestBuildId();
+ if ( latestResultId > 0 )
{
try
{
- BuildResult lastBuildResult = getContinuum().getBuildResult( project.getLatestBuildId() );
- if ( lastBuildResult != null )
- {
- this.setLastBuildDateTime( dateFormatter.format( new Date( lastBuildResult.getEndTime() ) ) );
- }
+ latestResult = getContinuum().getBuildResult( latestResultId );
}
catch ( ContinuumException e )
{
- logger.info( "buildResult with id " + project.getLatestBuildId() + " has been deleted" );
+ log.debug( "project {} lists non-existent result {} as its latest", projectId, latestResult );
}
}
@@ -106,13 +103,32 @@
return getContinuum().getProjectGroupByProjectId( projectId );
}
- public String getLastBuildDateTime()
+ public BuildResult getLatestResult()
{
- return lastBuildDateTime;
+ return latestResult;
}
- public void setLastBuildDateTime( String lastBuildDateTime )
+ /**
+ * Maps the time to an alternative range.
+ *
+ * @param time the time to translate
+ * @return current time in milliseconds if time == 0, otherwise original time value
+ */
+ public long mapZeroTime( long time )
{
- this.lastBuildDateTime = lastBuildDateTime;
+ if ( time == 0 )
+ return System.currentTimeMillis();
+ return time;
+ }
+
+ /**
+ * Convenience method for using time values as dates in views.
+ *
+ * @param time the time to convert to a date
+ * @return a {@link Date} created with the specified time
+ */
+ public Date timeToDate( long time )
+ {
+ return new Date( time );
}
}
diff --git a/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp b/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp
index b8e6b80..b8794e8 100644
--- a/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp
+++ b/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectView.jsp
@@ -78,7 +78,7 @@
</tr>
<tr class="b">
<th><label class="label"><s:text name='projectView.project.lastBuildDateTime'/>:</label></th>
- <td><s:property value="lastBuildDateTime"/></td>
+ <td><s:date name="timeToDate(mapZeroTime(latestResult.endTime))"/></td>
</tr>
</table>