From 160afaa19970cff285ba5014f62da0d8d5cacf5c Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Mon, 11 Jan 2010 10:17:18 +0000 Subject: [PATCH] [MRM-1185] Archiva Reporting Modification Request submitted by Maria Catherine Tan o add ears, dlls, exes and zips count to generated repo statistics report git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@897827 13f79535-47bb-0310-9956-ffa450edef68 --- .../reporting/RepositoryStatistics.java | 16 +++- .../RepositoryStatisticsReportGenerator.java | 10 ++- ...leRepositoryStatisticsReportGenerator.java | 17 +++- ...positoryStatisticsReportGeneratorTest.java | 82 +++++++++++++++++-- .../WEB-INF/jsp/reports/statisticsReport.jsp | 16 ++++ 5 files changed, 132 insertions(+), 9 deletions(-) diff --git a/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java b/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java index 5427440db..ab99e2aa5 100644 --- a/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java +++ b/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java @@ -52,9 +52,11 @@ public class RepositoryStatistics private long dllCount = 0; private long exeCount = 0; - + private long pomCount = 0; - + + private long zipCount = 0; + private long deploymentCount = 0; private long downloadCount = 0; @@ -201,6 +203,16 @@ public class RepositoryStatistics this.pomCount = pomCount; } + public long getZipCount() + { + return zipCount; + } + + public void setZipCount( long zipCount ) + { + this.zipCount = zipCount; + } + public long getDeploymentCount() { return deploymentCount; diff --git a/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java b/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java index 27569efea..083e3ac1f 100644 --- a/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java +++ b/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java @@ -36,7 +36,15 @@ public interface RepositoryStatisticsReportGenerator public static final String WAR_TYPE = "war"; public static final String POM_TYPE = "pom"; - + + public static final String EAR_TYPE = "ear"; + + public static final String DLL_TYPE = "dll"; + + public static final String EXE_TYPE = "exe"; + + public static final String ZIP_TYPE = "distribution-zip"; + public static final String MAVEN_PLUGIN = "maven-plugin"; public static final String ARCHETYPE = "archetype"; diff --git a/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java b/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java index 21db21184..6d958815f 100644 --- a/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java +++ b/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java @@ -133,7 +133,22 @@ public class SimpleRepositoryStatisticsReportGenerator types = artifactDao.queryArtifacts( new ArtifactsByRepositoryConstraint( repository, MAVEN_PLUGIN, endDate, "whenGathered" ) ); repoStatistics.setPluginCount( types.size() ); - + + types = artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( repository, EAR_TYPE, endDate, "whenGathered" ) ); + repoStatistics.setEarCount( types.size() ); + + types = artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( repository, DLL_TYPE, endDate, "whenGathered" ) ); + repoStatistics.setDllCount( types.size() ); + + types = artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( repository, EXE_TYPE, endDate, "whenGathered" ) ); + repoStatistics.setExeCount( types.size() ); + + types = artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( repository, ZIP_TYPE, endDate, "whenGathered" ) ); + repoStatistics.setZipCount( types.size() ); // TODO: must need to be able to track archetypes. possible way of identifying an // archetype is by checking if archetype.xml exists in src/main/resources/META-INF/ diff --git a/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java b/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java index c5bedea3e..45aae75e4 100644 --- a/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java +++ b/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java @@ -160,7 +160,11 @@ public class SimpleRepositoryStatisticsReportGeneratorTest List jarArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.JAR_TYPE ); List warArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.WAR_TYPE ); List mavenPlugins = createArtifacts( RepositoryStatisticsReportGenerator.MAVEN_PLUGIN ); - + List exeArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.EXE_TYPE ); + List earArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.EAR_TYPE ); + List dllArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.DLL_TYPE ); + List zipArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.ZIP_TYPE ); + List repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO ); // get first page @@ -174,7 +178,19 @@ public class SimpleRepositoryStatisticsReportGeneratorTest artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins, 5 ); - + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EAR_TYPE, endDate, "whenGathered" ) ), earArtifacts, 5 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EXE_TYPE, endDate, "whenGathered" ) ), exeArtifacts, 5 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.DLL_TYPE, endDate, "whenGathered" ) ), dllArtifacts, 5 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.ZIP_TYPE, endDate, "whenGathered" ) ), zipArtifacts, 5 ); + daoControl.replay(); artifactDaoControl.replay(); @@ -191,6 +207,10 @@ public class SimpleRepositoryStatisticsReportGeneratorTest assertEquals( 5, stats.getJarCount() ); assertEquals( 5, stats.getWarCount() ); assertEquals( 5, stats.getPluginCount() ); + assertEquals( 5, stats.getEarCount() ); + assertEquals( 5, stats.getExeCount() ); + assertEquals( 5, stats.getDllCount() ); + assertEquals( 5, stats.getZipCount() ); assertEquals( toDate( 2008, 11, 1, 0, 0, 0 ).getTime(), stats.getDateOfScan().getTime() ); assertEquals( toDate( 2008, 9, 1, 0, 0, 0 ).getTime(), ( (RepositoryStatistics) data.get( 4 ) ).getDateOfScan().getTime() ); @@ -212,7 +232,19 @@ public class SimpleRepositoryStatisticsReportGeneratorTest artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins ); - + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EAR_TYPE, endDate, "whenGathered" ) ), earArtifacts ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EXE_TYPE, endDate, "whenGathered" ) ), exeArtifacts ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.DLL_TYPE, endDate, "whenGathered" ) ), dllArtifacts ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.ZIP_TYPE, endDate, "whenGathered" ) ), zipArtifacts ); + daoControl.replay(); artifactDaoControl.replay(); @@ -241,6 +273,10 @@ public class SimpleRepositoryStatisticsReportGeneratorTest List jarArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.JAR_TYPE ); List warArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.WAR_TYPE ); List mavenPlugins = createArtifacts( RepositoryStatisticsReportGenerator.MAVEN_PLUGIN ); + List exeArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.EXE_TYPE ); + List earArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.EAR_TYPE ); + List dllArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.DLL_TYPE ); + List zipArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.ZIP_TYPE ); List repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO ); @@ -255,7 +291,19 @@ public class SimpleRepositoryStatisticsReportGeneratorTest artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins, 21 ); - + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EAR_TYPE, endDate, "whenGathered" ) ), earArtifacts, 21 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EXE_TYPE, endDate, "whenGathered" ) ), exeArtifacts, 21 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.DLL_TYPE, endDate, "whenGathered" ) ), dllArtifacts, 21 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.ZIP_TYPE, endDate, "whenGathered" ) ), zipArtifacts, 21 ); + daoControl.replay(); artifactDaoControl.replay(); @@ -272,6 +320,10 @@ public class SimpleRepositoryStatisticsReportGeneratorTest assertEquals( 5, stats.getJarCount() ); assertEquals( 5, stats.getWarCount() ); assertEquals( 5, stats.getPluginCount() ); + assertEquals( 5, stats.getEarCount() ); + assertEquals( 5, stats.getExeCount() ); + assertEquals( 5, stats.getDllCount() ); + assertEquals( 5, stats.getZipCount() ); assertEquals( toDate( 2008, 11, 1, 0, 0, 0 ).getTime(), stats.getDateOfScan().getTime() ); assertEquals( toDate( 2008, 1, 1, 0, 0, 0 ).getTime(), ( (RepositoryStatistics) data.get( 20 ) ).getDateOfScan().getTime() ); } @@ -291,6 +343,10 @@ public class SimpleRepositoryStatisticsReportGeneratorTest List jarArtifacts = new ArrayList(); List warArtifacts = new ArrayList(); List mavenPlugins = new ArrayList(); + List earArtifacts = new ArrayList(); + List exeArtifacts = new ArrayList(); + List dllArtifacts = new ArrayList(); + List zipArtifacts = new ArrayList(); List repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO ); @@ -304,7 +360,19 @@ public class SimpleRepositoryStatisticsReportGeneratorTest artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins, 5 ); - + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EAR_TYPE, endDate, "whenGathered" ) ), earArtifacts, 5 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.EXE_TYPE, endDate, "whenGathered" ) ), exeArtifacts, 5 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.DLL_TYPE, endDate, "whenGathered" ) ), dllArtifacts, 5 ); + + artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( + new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.ZIP_TYPE, endDate, "whenGathered" ) ), zipArtifacts, 5 ); + daoControl.replay(); artifactDaoControl.replay(); @@ -321,6 +389,10 @@ public class SimpleRepositoryStatisticsReportGeneratorTest assertEquals( 0, stats.getJarCount() ); assertEquals( 0, stats.getWarCount() ); assertEquals( 0, stats.getPluginCount() ); + assertEquals( 0, stats.getEarCount() ); + assertEquals( 0, stats.getExeCount() ); + assertEquals( 0, stats.getDllCount() ); + assertEquals( 0, stats.getZipCount() ); assertEquals( toDate( 2008, 11, 1, 0, 0, 0 ).getTime(), stats.getDateOfScan().getTime() ); assertEquals( toDate( 2008, 9, 1, 0, 0, 0 ).getTime(), ( (RepositoryStatistics) data.get( 4 ) ).getDateOfScan().getTime() ); // no results found when ArtifactDAO was queried 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 5e052473e..152cdec39 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 @@ -154,6 +154,10 @@ Archetypes Jars Wars + Ears + Exes + Dlls + Zips Deployments Downloads @@ -170,6 +174,10 @@ ${stats.archetypeCount} ${stats.jarCount} ${stats.warCount} + ${stats.earCount} + ${stats.exeCount} + ${stats.dllCount} + ${stats.zipCount} ${stats.deploymentCount} ${stats.downloadCount} @@ -191,6 +199,10 @@ Archetypes Jars Wars + Ears + Exes + Dlls + Zips Deployments Downloads @@ -207,6 +219,10 @@ ${stats.archetypeCount} ${stats.jarCount} ${stats.warCount} + ${stats.earCount} + ${stats.exeCount} + ${stats.dllCount} + ${stats.zipCount} ${stats.deploymentCount} ${stats.downloadCount} -- 2.39.5