From: Maria Odea B. Ching Date: Thu, 2 Oct 2008 08:35:42 +0000 (+0000) Subject: [MRM-84] X-Git-Tag: archiva-1.2-M1~46 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=31d7e3515916d3ed98441fd70a2e1ea87ce43224;p=archiva.git [MRM-84] -added row count config in statistics report -added pagination in report git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@701033 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java index f254422df..0fcb62342 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java @@ -22,6 +22,8 @@ package org.apache.maven.archiva.web.action.reports; import com.opensymphony.webwork.interceptor.ServletRequestAware; import com.opensymphony.xwork.Preparable; +import org.apache.commons.lang.time.DateFormatUtils; +import org.apache.commons.lang.time.DateUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArchivaDatabaseException; @@ -51,6 +53,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; + +import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; @@ -123,9 +127,9 @@ public class GenerateReportAction private List availableRepositories; - private Date startDate; + private String startDate; - private Date endDate; + private String endDate; private int reposSize; @@ -133,6 +137,11 @@ public class GenerateReportAction private List repositoryStatistics = new ArrayList(); + private DataLimits limits = new DataLimits(); + + private String[] datePatterns = new String[] { "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", + "dd MMMMM yyyy", "dd/MM/yy", "dd/MM/yyyy", "yyyy/MM/dd" }; + public void prepare() { repositoryIds = new ArrayList(); @@ -177,9 +186,48 @@ public class GenerateReportAction */ public String generateStatistics() { - DataLimits limits = new DataLimits(); - setDefaults(); + if( rowCount < 10 ) + { + addFieldError( "rowCount", "Row count must be larger than 10." ); + return INPUT; + } reposSize = selectedRepositories.size(); + Date startDateInDateFormat = null; + Date endDateInDateFormat = null; + + if( startDate == null || "".equals( startDate ) ) + { + startDateInDateFormat = getDefaultStartDate(); + } + else + { + try + { + startDateInDateFormat = DateUtils.parseDate( startDate, datePatterns ); + } + catch ( ParseException e ) + { + addFieldError( "startDate", "Invalid date format."); + return INPUT; + } + } + + if( endDate == null || "".equals( endDate ) ) + { + endDateInDateFormat = getDefaultEndDate(); + } + else + { + try + { + endDateInDateFormat = DateUtils.parseDate( endDate, datePatterns ); + } + catch ( ParseException e ) + { + addFieldError( "endDate", "Invalid date format."); + return INPUT; + } + } try { @@ -197,7 +245,7 @@ public class GenerateReportAction try { List contentStats = repoContentStatsDao.queryRepositoryContentStatistics( - new RepositoryContentStatisticsByRepositoryConstraint( repo, startDate, endDate ) ); + new RepositoryContentStatisticsByRepositoryConstraint( repo, startDateInDateFormat, endDateInDateFormat ) ); if( contentStats == null || contentStats.isEmpty() ) { @@ -206,7 +254,7 @@ public class GenerateReportAction continue; } - repositoryStatistics.addAll( generator.generateReport( contentStats, repo, startDate, endDate, limits ) ); + repositoryStatistics.addAll( generator.generateReport( contentStats, repo, startDateInDateFormat, endDateInDateFormat, limits ) ); } catch ( ObjectNotFoundException oe ) { @@ -229,7 +277,7 @@ public class GenerateReportAction try { List contentStats = repoContentStatsDao.queryRepositoryContentStatistics( - new RepositoryContentStatisticsByRepositoryConstraint( selectedRepo, startDate, endDate ) ); + new RepositoryContentStatisticsByRepositoryConstraint( selectedRepo, startDateInDateFormat, endDateInDateFormat ) ); if( contentStats == null || contentStats.isEmpty() ) { @@ -242,7 +290,7 @@ public class GenerateReportAction int totalPages = ( limits.getTotalCount() / limits.getPerPageCount() ) + extraPage; limits.setCountOfPages( totalPages ); - repositoryStatistics = generator.generateReport( contentStats, selectedRepo, startDate, endDate, limits ); + repositoryStatistics = generator.generateReport( contentStats, selectedRepo, startDateInDateFormat, endDateInDateFormat, limits ); } catch ( ObjectNotFoundException oe ) { @@ -259,7 +307,23 @@ public class GenerateReportAction { addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." ); return INPUT; - } + } + + if( repositoryStatistics.isEmpty() ) + { + return BLANK; + } + + if( startDate.equals( getDefaultStartDate() ) ) + { + startDate = null; + } + else + { + startDate = DateFormatUtils.format( startDateInDateFormat, "MM/dd/yyyy" ); + } + + endDate = DateFormatUtils.format( endDateInDateFormat, "MM/dd/yyyy" ); } catch ( ArchivaReportException e ) { @@ -269,21 +333,19 @@ public class GenerateReportAction return SUCCESS; } - - private void setDefaults() + + private Date getDefaultStartDate() { - if( startDate == null ) - { - Calendar cal = Calendar.getInstance(); - cal.clear(); - cal.set( 1900, 1, 1, 0, 0, 0 ); - startDate = cal.getTime(); - } + Calendar cal = Calendar.getInstance(); + cal.clear(); + cal.set( 1900, 1, 1, 0, 0, 0 ); - if( endDate == null ) - { - endDate = Calendar.getInstance().getTime(); - } + return cal.getTime(); + } + + private Date getDefaultEndDate() + { + return Calendar.getInstance().getTime(); } public String execute() @@ -525,22 +587,22 @@ public class GenerateReportAction this.availableRepositories = availableRepositories; } - public Date getStartDate() + public String getStartDate() { return startDate; } - public void setStartDate( Date startDate ) + public void setStartDate( String startDate ) { this.startDate = startDate; } - public Date getEndDate() + public String getEndDate() { return endDate; } - public void setEndDate( Date endDate ) + public void setEndDate( String endDate ) { this.endDate = endDate; } @@ -574,4 +636,14 @@ public class GenerateReportAction { this.selectedRepo = selectedRepo; } + + public DataLimits getLimits() + { + return limits; + } + + public void setLimits( DataLimits limits ) + { + this.limits = limits; + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp index 5bcdb7986..62c12bb38 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp @@ -39,6 +39,7 @@ + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp index 8366f3eba..dd70758c2 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp @@ -30,84 +30,182 @@

Statistics Report

+ + + + +
+ + <%-- TODO: fix problem in date format! --%> + + <%-- Pagination - start --%> +

+ + <%-- Set Prev & Next icons --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- Google-style pagination --%> + + + + + 0 + 10 + + + ${(limits.countOfPages -1) - 10} + ${limits.countOfPages - 1} + + + ${page - 5} + ${page + 5} + + + + + 0 + ${limits.countOfPages - 1} + + + + + + + + + + + + + + + + ${i + 1} + + + ${i + 1} + + + + + + + + + + + + + + +

+ <%-- Pagination - end --%> + - + -

Latest Statistics Comparison Report

- - - - - - - - - - - - - - - +

Latest Statistics Comparison Report

+
RepositoryTotal File CountTotal SizeArtifact CountGroup CountProject CountPluginsArchetypesJarsWarsDeploymentsDownloads
+ + + + + + + + + + + + + + - - - - - - - - - - - - - - - - -
RepositoryTotal File CountTotal SizeArtifact CountGroup CountProject CountPluginsArchetypesJarsWarsDeploymentsDownloads
${stats.repositoryId}${stats.fileCount}${stats.totalSize}${stats.artifactCount}${stats.groupCount}${stats.projectCount}${stats.pluginCount}${stats.archetypeCount}${stats.jarCount}${stats.warCount}${stats.deploymentCount}${stats.downloadCount}
- -
- + + + ${stats.repositoryId} + ${stats.fileCount} + ${stats.totalSize} + ${stats.artifactCount} + ${stats.groupCount} + ${stats.projectCount} + ${stats.pluginCount} + ${stats.archetypeCount} + ${stats.jarCount} + ${stats.warCount} + ${stats.deploymentCount} + ${stats.downloadCount} + + + +
+ -

Statistics for Repository '${selectedRepo}'

- - - - - - - - - - - - - - - +

Statistics for Repository '${selectedRepo}'

+
Date of ScanTotal File CountTotal SizeArtifact CountGroup CountProject CountPluginsArchetypesJarsWarsDeploymentsDownloads
+ + + + + + + + + + + + + + - - - - - - - - - - - - - - - - -
Date of ScanTotal File CountTotal SizeArtifact CountGroup CountProject CountPluginsArchetypesJarsWarsDeploymentsDownloads
${stats.dateOfScan}${stats.fileCount}${stats.totalSize}${stats.artifactCount}${stats.groupCount}${stats.projectCount}${stats.pluginCount}${stats.archetypeCount}${stats.jarCount}${stats.warCount}${stats.deploymentCount}${stats.downloadCount}
- -
+ + + ${stats.dateOfScan} + ${stats.fileCount} + ${stats.totalSize} + ${stats.artifactCount} + ${stats.groupCount} + ${stats.projectCount} + ${stats.pluginCount} + ${stats.archetypeCount} + ${stats.jarCount} + ${stats.warCount} + ${stats.deploymentCount} + ${stats.downloadCount} + + + + +