archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r700729 [1/2] - in /archiva/trunk/archiva-modules: archiva-base/archiva-model/src/main/mdo/ archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ archiva-database/src/test/java/org/apache/maven/archiva/database/const...
Date Wed, 01 Oct 2008 10:27:18 GMT
Author: oching
Date: Wed Oct  1 03:27:16 2008
New Revision: 700729

URL: http://svn.apache.org/viewvc?rev=700729&view=rev
Log:
[MRM-84]
-added statistics report in reports UI
-added statistics report generator with tests
-added new fields (totalProjectCount, totalGroupCount, totalArtifactCount and totalSize) to RepositoryContentStatistics table

Added:
    archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/ArchivaReportException.java
    archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java
    archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java
    archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java
    archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp
Removed:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/reports/GenerateReportAction-validation.xml
Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
    archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java
    archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
    archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java
    archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java
    archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java
    archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java
    archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java
    archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java
    archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml
    archiva/trunk/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/maven-theme.css

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml Wed Oct  1 03:27:16 2008
@@ -2346,6 +2346,46 @@
             The number of new files discovered.
           </description>
         </field>
+        <field>
+          <name>totalProjectCount</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total number of unique projects in the repository.
+          </description>
+        </field>
+        <field>
+          <name>totalGroupCount</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total number of unique groups in the repository.
+          </description>
+        </field>
+        <field>
+          <name>totalArtifactCount</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total number of artifacts in the repository. 
+          </description>
+        </field>
+        <field>
+          <name>totalSize</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total size in bytes of the repository.
+          </description>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>

Modified: archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java Wed Oct  1 03:27:16 2008
@@ -40,6 +40,8 @@
     protected Object[] params;
 
     protected int[] range;
+    
+    protected String sortDirection = Constraint.ASCENDING;
 
     public String getFilter()
     {
@@ -68,7 +70,7 @@
 
     public String getSortDirection()
     {
-        return Constraint.ASCENDING;
+        return sortDirection;
     }
     
     public String[] getVariables()

Modified: archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java Wed Oct  1 03:27:16 2008
@@ -44,14 +44,26 @@
         params = new Object[] { repoId };
 	}
 		
-	public ArtifactsByRepositoryConstraint( String repoId, Date targetWhenGathered, String sortColumn )
+	public ArtifactsByRepositoryConstraint( String repoId, Date targetWhenGathered, String sortColumn, boolean isBefore )
     {
+	    String condition = isBefore ? "<=" : ">=";
+	    
 	    declImports = new String[] { "import java.util.Date" };
-	    whereClause = "this.repositoryId == repoId && this.whenGathered >= targetWhenGathered";        
+	    whereClause = "this.repositoryId == repoId && this.whenGathered " + condition + " targetWhenGathered";        
         declParams = new String[] { "String repoId", "Date targetWhenGathered" };
         params = new Object[] { repoId, targetWhenGathered };        
         this.sortColumn = sortColumn;
     }
+	
+	public ArtifactsByRepositoryConstraint( String repoId, String type, Date before, String sortColumn )
+	{
+	    declImports = new String[] { "import java.util.Date" };
+        whereClause =
+            "this.repositoryId == repoId && this.type == type && this.whenGathered <= before";        
+        declParams = new String[] { "String repoId", "String type", "Date before" };
+        params = new Object[] { repoId, type, before };        
+        this.sortColumn = sortColumn;
+	}
 		
 	public String getSortColumn() 
 	{		

Modified: archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java Wed Oct  1 03:27:16 2008
@@ -1,5 +1,9 @@
 package org.apache.maven.archiva.database.constraints;
 
+import java.util.Date;
+
+import org.apache.maven.archiva.database.Constraint;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -36,6 +40,16 @@
         declParams = new String[] { "String repoId" };
         params = new Object[] { repoId };
     }
+    
+    public RepositoryContentStatisticsByRepositoryConstraint( String repoId, Date startDate, Date endDate )
+    {    
+        declImports = new String[] { "import java.util.Date" };
+        whereClause = "repositoryId == repoId && whenGathered >= startDate && whenGathered <= endDate";
+        declParams = new String[] { "String repoId", "Date startDate", "Date endDate" };
+        params = new Object[] { repoId, startDate, endDate };
+        
+        sortDirection = Constraint.DESCENDING;
+    }
 
     public String getSortColumn()
     {

Modified: archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java Wed Oct  1 03:27:16 2008
@@ -35,7 +35,9 @@
     implements Constraint
 {
     private StringBuffer sql = new StringBuffer();
-
+    
+    private Class resultClass;
+    
     /**
      * Obtain a set of unique ArtifactIds for the specified groupId.
      * 
@@ -43,7 +45,7 @@
      */
     public UniqueArtifactIdConstraint( List<String> selectedRepositoryIds, String groupId )
     {
-        appendSelect( sql );
+        appendSelect( sql, false );
         sql.append( " WHERE " );
         SqlBuilder.appendWhereSelectedRepositories( sql, "repositoryId", selectedRepositoryIds );
         sql.append( " && " );
@@ -60,17 +62,36 @@
      */
     public UniqueArtifactIdConstraint( String groupId )
     {
-        appendSelect( sql );
+        appendSelect( sql, false );
         sql.append( " WHERE " );
         appendWhereSelectedGroupId( sql );
         appendGroupBy( sql );
 
         super.params = new Object[] { groupId };
     }
+    
+    /**
+     * Obtain a set of unique artifactIds with respect to their groups from the specified repository.
+     * 
+     * @param repoId
+     * @param isUnique
+     */
+    public UniqueArtifactIdConstraint( String repoId, boolean isUnique )
+    {
+        appendSelect( sql, isUnique );
+        sql.append( " WHERE repositoryId == \"" + repoId + "\"" );
+        
+        resultClass = Object[].class;
+    }
 
     @SuppressWarnings("unchecked")
     public Class getResultClass()
     {
+        if( resultClass != null )
+        {
+            return resultClass;
+        }
+        
         return String.class;
     }
 
@@ -84,9 +105,16 @@
         buf.append( " GROUP BY artifactId ORDER BY artifactId ASCENDING" );
     }
 
-    private void appendSelect( StringBuffer buf )
+    private void appendSelect( StringBuffer buf, boolean isUnique )
     {
-        buf.append( "SELECT artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
+        if( isUnique )
+        {
+            buf.append( "SELECT DISTINCT groupId, artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
+        }
+        else
+        {
+            buf.append( "SELECT artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
+        }
     }
 
     private void appendWhereSelectedGroupId( StringBuffer buf )

Modified: archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java Wed Oct  1 03:27:16 2008
@@ -37,20 +37,20 @@
 public class ArtifactsByRepositoryConstraintTest
     extends AbstractArchivaDatabaseTestCase
 {
-    private ArtifactDAO artifactDao;
+    private ArtifactDAO artifactDao; 
 
     public void setUp()
         throws Exception
     {
-        super.setUp();
+        super.setUp(); 
 
         ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
         artifactDao = dao.getArtifactDAO();
     }
 
-    private ArchivaArtifact createArtifact( String groupId, String artifactId, String version )
+    private ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type )
     {
-        ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, null, "jar" );
+        ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, null, type );
         artifact.getModel().setLastModified( new Date() );
         artifact.getModel().setRepositoryId( "test-repo" );
 
@@ -63,19 +63,19 @@
         Date whenGathered = Calendar.getInstance().getTime();
         whenGathered.setTime( 123456789 );
 
-        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0" );
+        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.0.2" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.0.2", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" );
         artifact.getModel().setRepositoryId( "different-repo" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
@@ -88,19 +88,19 @@
     {
         Date whenGathered = Calendar.getInstance().getTime();
 
-        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0" );
+        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" );
         artifact.getModel().setRepositoryId( "different-repo" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
@@ -108,18 +108,63 @@
         Date olderWhenGathered = Calendar.getInstance().getTime();
         olderWhenGathered.setTime( 123456789 );
         
-        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT", "jar" );
         artifact.getModel().setWhenGathered( olderWhenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
         assertConstraint( "Artifacts By Repository and When Gathered", 4,
-                          new ArtifactsByRepositoryConstraint( "test-repo", whenGathered, "repositoryId" ) );
+                          new ArtifactsByRepositoryConstraint( "test-repo", whenGathered, "repositoryId", false ) );
     }
+    
+    public void testQueryArtifactsInRepoByType()
+        throws Exception
+    {
+        Calendar cal = Calendar.getInstance();
+        cal.set( 2008, 9, 1 );
+        Date whenGathered = cal.getTime();
+
+        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2", "jar" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+        
+        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT", "war" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+
+        artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1", "war" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
 
+        Calendar cal2 = Calendar.getInstance();
+        cal2.set( 2008, 12, 12 );
+        Date diffWhenGathered = cal2.getTime();
+        
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" );
+        artifact.getModel().setWhenGathered( diffWhenGathered );
+        artifactDao.saveArtifact( artifact );
+        
+        cal2 = Calendar.getInstance();
+        cal2.set( 2008, 10, 30 );
+        Date before = cal2.getTime();
+        
+        assertConstraint( "Artifacts of Type 'jar' By Repository and When Gathered", 3,
+                          new ArtifactsByRepositoryConstraint( "test-repo", "jar", before, "whenGathered" ) );
+        assertConstraint( "Artifacts of Type 'war' By Repository and When Gathered", 2,
+                          new ArtifactsByRepositoryConstraint( "test-repo", "war", before, "whenGathered" ) );
+    }
+    
     private void assertConstraint( String msg, int count, ArtifactsByRepositoryConstraint constraint )
         throws Exception
     {

Modified: archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java Wed Oct  1 03:27:16 2008
@@ -32,7 +32,7 @@
  * @version
  */
 public class RepositoryContentStatisticsByRepositoryConstraintTest
-    extends AbstractArchivaDatabaseTestCase
+    extends AbstractArchivaDatabaseTestCase 
 {
     private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
                                                      long newfiles )
@@ -76,4 +76,27 @@
         assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 2 ) ).getRepositoryId() );
         assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 3 ) ).getRepositoryId() );
     }
+    
+    public void testStatsWithDateRange()
+        throws Exception
+    {
+        Constraint constraint =
+            new RepositoryContentStatisticsByRepositoryConstraint( "internal", toDate( "2007/10/18 8:00:00" ),
+                                                                   toDate( "2007/10/20 8:00:00" ) );
+        List results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
+        assertNotNull( "Stats: results (not null)", results );
+        assertEquals( "Stats: results.size", 3, results.size() );
+
+        assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 0 ) ).getRepositoryId() );
+        assertEquals( toDate( "2007/10/20 8:00:00" ),
+                      ( (RepositoryContentStatistics) results.get( 0 ) ).getWhenGathered() );
+
+        assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 1 ) ).getRepositoryId() );
+        assertEquals( toDate( "2007/10/19 8:00:00" ),
+                      ( (RepositoryContentStatistics) results.get( 1 ) ).getWhenGathered() );
+
+        assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 2 ) ).getRepositoryId() );
+        assertEquals( toDate( "2007/10/18 8:00:00" ),
+                      ( (RepositoryContentStatistics) results.get( 2 ) ).getWhenGathered() );
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java Wed Oct  1 03:27:16 2008
@@ -22,6 +22,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
 import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.ArtifactDAO;
 import org.apache.maven.archiva.database.SimpleConstraint;
 import org.apache.maven.archiva.model.ArchivaArtifact;
@@ -62,9 +63,31 @@
     public void testConstraint()
         throws Exception
     {
-        ArchivaArtifact artifact;
+        setUpArtifacts();
 
-        // Setup artifacts in fresh DB.
+        assertConstraint( new String[] {}, new UniqueArtifactIdConstraint( "org.apache" ) );
+        assertConstraint( new String[] { "commons-lang" }, new UniqueArtifactIdConstraint( "commons-lang" ) );
+        assertConstraint( new String[] { "test-one" }, new UniqueArtifactIdConstraint( "org.apache.maven.test" ) );
+        assertConstraint( new String[] { "test-two", "test-bar" },
+                          new UniqueArtifactIdConstraint( "org.apache.maven.shared" ) );
+        assertConstraint( new String[] { "modellong" }, new UniqueArtifactIdConstraint( "org.codehaus.modello" ) );
+    }
+    
+    public void testConstraintDisregardGroupId()
+        throws Exception
+    {
+        setUpArtifacts();
+        
+        assertConstraintWithMultipleResultTypes( new String[] { "commons-lang", "test-one", "test-two", "test-two", "test-bar", "modellong" },
+                          new UniqueArtifactIdConstraint( "testable_repo", true ) );
+    }
+
+    private void setUpArtifacts()
+        throws ArchivaDatabaseException
+    {
+        ArchivaArtifact artifact;
+        
+     // Setup artifacts in fresh DB.
         artifact = createArtifact( "commons-lang", "commons-lang", "2.0" );
         artifactDao.saveArtifact( artifact );
 
@@ -88,26 +111,41 @@
 
         artifact = createArtifact( "org.codehaus.modello", "modellong", "3.0" );
         artifactDao.saveArtifact( artifact );
-
-        assertConstraint( new String[] {}, new UniqueArtifactIdConstraint( "org.apache" ) );
-        assertConstraint( new String[] { "commons-lang" }, new UniqueArtifactIdConstraint( "commons-lang" ) );
-        assertConstraint( new String[] { "test-one" }, new UniqueArtifactIdConstraint( "org.apache.maven.test" ) );
-        assertConstraint( new String[] { "test-two", "test-bar" },
-                          new UniqueArtifactIdConstraint( "org.apache.maven.shared" ) );
-        assertConstraint( new String[] { "modellong" }, new UniqueArtifactIdConstraint( "org.codehaus.modello" ) );
     }
-
+    
+    private void assertConstraintWithMultipleResultTypes( String[] artifactIds, SimpleConstraint constraint )
+        throws Exception
+    {
+        String prefix = "Unique Artifact IDs: ";
+    
+        List<Object[]> results = dao.query( constraint );
+        assertNotNull( prefix + "Not Null", results );
+        assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
+    
+        List<String> expectedArtifactIds = Arrays.asList( artifactIds );
+    
+        Iterator<Object[]> it = results.iterator();
+        while ( it.hasNext() )
+        {
+            Object[] actualArtifactIds = (Object[]) it.next();            
+            String actualArtifactId = ( String ) actualArtifactIds[1];
+            assertTrue( prefix + "artifactId result should not be blank.", StringUtils.isNotBlank( actualArtifactId ) );
+            assertTrue( prefix + " artifactId result <" + actualArtifactId + "> exists in expected artifactIds.",
+                        expectedArtifactIds.contains( actualArtifactId ) );            
+        }
+    }
+    
     private void assertConstraint( String[] artifactIds, SimpleConstraint constraint )
     {
         String prefix = "Unique Artifact IDs: ";
 
-        List results = dao.query( constraint );
+        List<String> results = dao.query( constraint );
         assertNotNull( prefix + "Not Null", results );
         assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
 
-        List expectedArtifactIds = Arrays.asList( artifactIds );
+        List<String> expectedArtifactIds = Arrays.asList( artifactIds );
 
-        Iterator it = results.iterator();
+        Iterator<String> it = results.iterator();
         while ( it.hasNext() )
         {
             String actualArtifactId = (String) it.next();

Modified: archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java Wed Oct  1 03:27:16 2008
@@ -230,8 +230,8 @@
 
         assertConstraint( new String[] { "org.codehaus.modello", "org.codehaus.mojo", "org.apache.archiva" },
                           new UniqueGroupIdConstraint( observableRepositories ) );
-    }
-
+    }   
+    
     private void assertConstraint( String[] expectedGroupIds, SimpleConstraint constraint )
         throws Exception
     {

Modified: archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml Wed Oct  1 03:27:16 2008
@@ -48,6 +48,11 @@
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
   </build>

Added: archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/ArchivaReportException.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/ArchivaReportException.java?rev=700729&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/ArchivaReportException.java (added)
+++ archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/ArchivaReportException.java Wed Oct  1 03:27:16 2008
@@ -0,0 +1,40 @@
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * ArchivaReportException
+ * 
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version $Id: ArchivaReportException.java
+ */
+public class ArchivaReportException
+    extends Exception
+{
+    public ArchivaReportException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public ArchivaReportException( String message )
+    {
+        super( message );
+    }
+}

Added: archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java?rev=700729&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java (added)
+++ archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatistics.java Wed Oct  1 03:27:16 2008
@@ -0,0 +1,234 @@
+package org.apache.maven.archiva.reporting;
+
+import java.util.Date;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * RepositoryStatistics
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
+public class RepositoryStatistics
+{
+    private String repositoryId;
+    
+    private long fileCount = 0;
+    
+    private long totalSize = 0;
+    
+    private long projectCount = 0;
+    
+    private long groupCount = 0;
+    
+    private long artifactCount = 0;
+    
+    private long pluginCount = 0;
+    
+    private long archetypeCount = 0;
+    
+    private long jarCount = 0;
+    
+    private long warCount = 0;
+    
+    private long earCount = 0;
+    
+    private long dllCount = 0;
+    
+    private long exeCount = 0;
+    
+    private long pomCount = 0;
+    
+    private long deploymentCount = 0;
+    
+    private long downloadCount = 0;
+    
+    private Date dateOfScan;
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public long getFileCount()
+    {
+        return fileCount;
+    }
+
+    public void setFileCount( long fileCount )
+    {
+        this.fileCount = fileCount;
+    }
+
+    public long getTotalSize()
+    {
+        return totalSize;
+    }
+
+    public void setTotalSize( long totalSize )
+    {
+        this.totalSize = totalSize;
+    }
+
+    public long getProjectCount()
+    {
+        return projectCount;
+    }
+
+    public void setProjectCount( long projectCount )
+    {
+        this.projectCount = projectCount;
+    }
+
+    public long getGroupCount()
+    {
+        return groupCount;
+    }
+
+    public void setGroupCount( long groupCount )
+    {
+        this.groupCount = groupCount;
+    }
+
+    public long getArtifactCount()
+    {
+        return artifactCount;
+    }
+
+    public void setArtifactCount( long artifactCount )
+    {
+        this.artifactCount = artifactCount;
+    }
+
+    public long getPluginCount()
+    {
+        return pluginCount;
+    }
+
+    public void setPluginCount( long pluginCount )
+    {
+        this.pluginCount = pluginCount;
+    }
+
+    public long getArchetypeCount()
+    {
+        return archetypeCount;
+    }
+
+    public void setArchetypeCount( long archetypeCount )
+    {
+        this.archetypeCount = archetypeCount;
+    }
+
+    public long getJarCount()
+    {
+        return jarCount;
+    }
+
+    public void setJarCount( long jarCount )
+    {
+        this.jarCount = jarCount;
+    }
+
+    public long getWarCount()
+    {
+        return warCount;
+    }
+
+    public void setWarCount( long warCount )
+    {
+        this.warCount = warCount;
+    }
+
+    public long getEarCount()
+    {
+        return earCount;
+    }
+
+    public void setEarCount( long earCount )
+    {
+        this.earCount = earCount;
+    }
+
+    public long getDllCount()
+    {
+        return dllCount;
+    }
+
+    public void setDllCount( long dllCount )
+    {
+        this.dllCount = dllCount;
+    }
+
+    public long getExeCount()
+    {
+        return exeCount;
+    }
+
+    public void setExeCount( long exeCount )
+    {
+        this.exeCount = exeCount;
+    }
+
+    public long getPomCount()
+    {
+        return pomCount;
+    }
+
+    public void setPomCount( long pomCount )
+    {
+        this.pomCount = pomCount;
+    }
+
+    public long getDeploymentCount()
+    {
+        return deploymentCount;
+    }
+
+    public void setDeploymentCount( long deploymentCount )
+    {
+        this.deploymentCount = deploymentCount;
+    }
+
+    public long getDownloadCount()
+    {
+        return downloadCount;
+    }
+
+    public void setDownloadCount( long downloadCount )
+    {
+        this.downloadCount = downloadCount;
+    }
+
+    public Date getDateOfScan()
+    {
+        return dateOfScan;
+    }
+
+    public void setDateOfScan( Date dateOfScan )
+    {
+        this.dateOfScan = dateOfScan;
+    }
+}

Added: archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java?rev=700729&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java (added)
+++ archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/RepositoryStatisticsReportGenerator.java Wed Oct  1 03:27:16 2008
@@ -0,0 +1,50 @@
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.util.Date;
+import java.util.List;
+
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+/**
+ * RepositoryStatisticsReportGenerator
+ * 
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version $Id: RepositoryStatisticsReportGenerator.java
+ */
+public interface RepositoryStatisticsReportGenerator
+{
+    public static final String JAR_TYPE = "jar";
+    
+    public static final String WAR_TYPE = "war";
+    
+    public static final String POM_TYPE = "pom";
+    
+    public static final String MAVEN_PLUGIN = "maven-plugin";
+    
+    public static final String ARCHETYPE = "archetype";
+    
+    public List<RepositoryStatistics> generateReport( List<RepositoryContentStatistics> repoContentStats, String repository, Date startDate, Date endDate, DataLimits limits )
+        throws ArchivaReportException;
+    
+    public List<RepositoryStatistics> generateReport( List<RepositoryContentStatistics> repoContentStats, String repository, Date startDate, Date endDate )
+        throws ArchivaReportException;
+}

Added: archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java?rev=700729&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java (added)
+++ archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/main/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGenerator.java Wed Oct  1 03:27:16 2008
@@ -0,0 +1,147 @@
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SimpleRepositoryStatisticsReportGenerator
+ * 
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version $Id: SimpleRepositoryStatisticsReportGenerator.java
+ * 
+ * @plexus.component role="org.apache.maven.archiva.reporting.RepositoryStatisticsReportGenerator" role-hint="simple"
+ */
+public class SimpleRepositoryStatisticsReportGenerator
+    implements RepositoryStatisticsReportGenerator
+{   
+    private Logger log = LoggerFactory.getLogger( SimpleRepositoryStatisticsReportGenerator.class );
+    
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ArchivaDAO dao;
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.maven.archiva.reporting.RepositoryStatisticsReportGenerator#generateReport(java.util.List
+     *      repoContentStats, java.util.String repository, java.util.Date startDate, java.util.Date endDate,
+     *      org.apache.maven.archiva.reporting.DataLimits limits )
+     */
+    public List<RepositoryStatistics> generateReport( List<RepositoryContentStatistics> repoContentStats,
+                                                      String repository, Date startDate, Date endDate, DataLimits limits )
+        throws ArchivaReportException
+    {   
+        if( limits.getCurrentPage() > limits.getCountOfPages() )
+        {
+            throw new ArchivaReportException( "The requested page exceeds the total number of pages." );
+        }
+         
+        int start = ( limits.getPerPageCount() * limits.getCurrentPage() ) - limits.getPerPageCount();
+        int end = ( start + limits.getPerPageCount() ) - 1;
+        
+        if( end > repoContentStats.size() )
+        {
+            end = repoContentStats.size() - 1;
+        }
+        
+        return constructRepositoryStatistics( repoContentStats, repository, endDate, start, end );
+    }
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.maven.archiva.reporting.RepositoryStatisticsReportGenerator#generateReport(java.util.List
+     *      repoContentStats, java.util.String repository, java.util.Date startDate, java.util.Date endDate)
+     */
+    public List<RepositoryStatistics> generateReport( List<RepositoryContentStatistics> repoContentStats, String repository, Date startDate, Date endDate )
+        throws ArchivaReportException
+    {
+        return constructRepositoryStatistics( repoContentStats, repository, endDate, 0, repoContentStats.size() - 1 );
+    }
+
+    private List<RepositoryStatistics> constructRepositoryStatistics(
+                                                                      List<RepositoryContentStatistics> repoContentStats,
+                                                                      String repository, Date endDate,
+                                                                      int start, int end )
+    {
+        ArtifactDAO artifactDao = dao.getArtifactDAO();    
+        
+        List<RepositoryStatistics> repoStatisticsList = new ArrayList<RepositoryStatistics>();
+        for( int i = start; i <= end; i++ )
+        {   
+            RepositoryContentStatistics repoContentStat = (RepositoryContentStatistics) repoContentStats.get( i );
+            RepositoryStatistics repoStatistics = new RepositoryStatistics();
+            repoStatistics.setRepositoryId( repository );
+            
+            // get only the latest                
+            repoStatistics.setArtifactCount( repoContentStat.getTotalArtifactCount() );
+            repoStatistics.setGroupCount( repoContentStat.getTotalGroupCount() );
+            repoStatistics.setProjectCount( repoContentStat.getTotalProjectCount() );
+            repoStatistics.setTotalSize( repoContentStat.getTotalSize() );
+            repoStatistics.setFileCount( repoContentStat.getTotalFileCount() );
+            repoStatistics.setDateOfScan( repoContentStat.getWhenGathered() );
+                
+            try
+            {
+                //TODO use the repo content stats whenGathered date instead of endDate for single repo reports
+                List types = artifactDao.queryArtifacts( 
+                         new ArtifactsByRepositoryConstraint( repository, JAR_TYPE, endDate, "whenGathered" ) );
+                repoStatistics.setJarCount( types.size() );
+                
+                types = artifactDao.queryArtifacts( 
+                        new ArtifactsByRepositoryConstraint( repository, WAR_TYPE, endDate, "whenGathered" ) );
+                repoStatistics.setWarCount( types.size() );
+                
+                types = artifactDao.queryArtifacts( 
+                        new ArtifactsByRepositoryConstraint( repository, MAVEN_PLUGIN, endDate, "whenGathered" ) );
+                repoStatistics.setPluginCount( 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/
+                
+            }
+            catch( ArchivaDatabaseException e )
+            {
+                log.error( "Error occurred while querying artifacts from the database.", e.getMessage() );                 
+            }            
+                            
+            repoStatisticsList.add( repoStatistics );  
+        }
+        
+        return repoStatisticsList;
+    }
+        
+    public void setDao( ArchivaDAO dao )
+    {
+        this.dao = dao;
+    }
+}

Added: archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java?rev=700729&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java (added)
+++ archiva/trunk/archiva-modules/archiva-reporting/archiva-report-manager/src/test/java/org/apache/maven/archiva/reporting/SimpleRepositoryStatisticsReportGeneratorTest.java Wed Oct  1 03:27:16 2008
@@ -0,0 +1,356 @@
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.easymock.MockControl;
+import org.easymock.internal.AlwaysMatcher;
+
+/**
+ * SimpleRepositoryStatisticsReportGeneratorTest
+ * 
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version $Id: SimpleRepositoryStatisticsReportGenerator.java
+ * 
+ * @plexus.component role="org.apache.maven.archiva.reporting.RepositoryStatisticsReportGenerator" role-hint="simple"
+ */
+public class SimpleRepositoryStatisticsReportGeneratorTest 
+    extends PlexusInSpringTestCase
+{    
+    private MockControl daoControl;
+    
+    private ArchivaDAO dao;
+    
+    private MockControl artifactDaoControl;
+    
+    private ArtifactDAO artifactDao;
+    
+    private SimpleRepositoryStatisticsReportGenerator generator;
+    
+    private static final String REPO = "test-repo";
+    
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        
+        daoControl = MockControl.createControl( ArchivaDAO.class );        
+        dao = ( ArchivaDAO ) daoControl.getMock();
+        
+        generator = new SimpleRepositoryStatisticsReportGenerator();
+        generator.setDao( dao );
+        
+        artifactDaoControl = MockControl.createControl( ArtifactDAO.class );
+        artifactDaoControl.setDefaultMatcher( new AlwaysMatcher() );
+        artifactDao = ( ArtifactDAO ) artifactDaoControl.getMock();       
+    }
+    
+    private Date toDate( int year, int month, int date, int hour, int min, int sec )
+    {
+        Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set( year, month, date, hour, min, sec );        
+        
+        return cal.getTime();        
+    }
+    
+    private List<ArchivaArtifact> createArtifacts( String type )
+    {
+        List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>();
+        artifacts.add( createArtifact( REPO, "org.apache.archiva", "repository-statistics-" + type, "1.0", type ) );
+        artifacts.add( createArtifact( REPO, "org.apache.archiva", "repository-statistics-" + type, "1.1", type ) );
+        artifacts.add( createArtifact( REPO, "org.apache.archiva", "repository-statistics-" + type, "1.2", type ) );
+        artifacts.add( createArtifact( REPO, "org.apache.archiva", "repository-statistics-" + type, "2.0", type ) );
+        artifacts.add( createArtifact( REPO, "org.apache.archiva", "repository-statistics-" + type, "3.0", type ) );
+
+        return artifacts;
+    }    
+
+    private ArchivaArtifact createArtifact( String repoId, String groupId, String artifactId, String version, String type )
+    {
+        ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, null, type );
+        artifact.getModel().setLastModified( new Date() );
+        artifact.getModel().setRepositoryId( repoId );
+
+        return artifact;
+    }
+    
+    private RepositoryContentStatistics createRepositoryContentStatistics( Date startDate, String repositoryId )
+    {
+        RepositoryContentStatistics repoContentStats = new RepositoryContentStatistics();
+        repoContentStats.setRepositoryId( repositoryId );
+        repoContentStats.setDuration( 10000 );
+        repoContentStats.setNewFileCount( 100 );
+        repoContentStats.setTotalArtifactCount( 200 );
+        repoContentStats.setTotalFileCount( 250 );
+        repoContentStats.setTotalGroupCount( 100 );
+        repoContentStats.setTotalProjectCount( 180 );
+        repoContentStats.setTotalSize( 200000 );
+        repoContentStats.setWhenGathered( startDate );
+        
+        return repoContentStats;
+    }
+    
+    private List<RepositoryContentStatistics> createStatisticsHistoryForSingleRepositoryTest( String repoId )
+    {
+        List<RepositoryContentStatistics> repoContentStatsList = new ArrayList<RepositoryContentStatistics>();
+        
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 11, 1, 0, 0, 0 ), repoId ) );        
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 10, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 10, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 9, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 9, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 8, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 8, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 7, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 7, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 6, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 6, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 5, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 5, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 4, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 4, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 3, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 3, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 2, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 2, 1, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 1, 16, 0, 0, 0 ), repoId ) );
+        repoContentStatsList.add( createRepositoryContentStatistics( toDate( 2008, 1, 1, 0, 0, 0 ), repoId ) );
+        
+        return repoContentStatsList;
+    }   
+    
+    public void testSimpleReportWithPagination()
+        throws Exception
+    {   
+        Date startDate = toDate( 2008, 1, 1, 0, 0, 0 );
+        Date endDate = toDate( 2008, 11, 30, 0, 0, 0 );
+                
+        DataLimits limits = new DataLimits();
+        limits.setPerPageCount( 5 );
+        limits.setCurrentPage( 1 );
+        limits.setCountOfPages( 5 );
+        limits.setTotalCount( 21 );      
+                
+        List<ArchivaArtifact> jarArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.JAR_TYPE );        
+        List<ArchivaArtifact> warArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.WAR_TYPE );
+        List<ArchivaArtifact> mavenPlugins = createArtifacts( RepositoryStatisticsReportGenerator.MAVEN_PLUGIN );
+        
+        List<RepositoryContentStatistics> repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO );
+        
+        // get first page
+        daoControl.expectAndReturn( dao.getArtifactDAO(), artifactDao );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.JAR_TYPE, endDate, "whenGathered") ), jarArtifacts, 5 );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.WAR_TYPE, endDate, "whenGathered") ), warArtifacts, 5 );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins, 5 );
+        
+        daoControl.replay(); 
+        artifactDaoControl.replay();
+        
+        List<RepositoryStatistics> data = generator.generateReport( repoContentStats, REPO, startDate, endDate, limits );
+        
+        daoControl.verify();
+        artifactDaoControl.verify();
+        
+        assertEquals( 5, data.size() );
+        
+        RepositoryStatistics stats = (RepositoryStatistics) data.get( 0 );        
+        assertEquals( REPO, stats.getRepositoryId() );
+        assertEquals( 200, stats.getArtifactCount() );
+        assertEquals( 5, stats.getJarCount() );
+        assertEquals( 5, stats.getWarCount() );
+        assertEquals( 5, stats.getPluginCount() );
+        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() );
+        
+        // get last page
+        limits.setCurrentPage( 5 );
+        
+        daoControl.reset();
+        artifactDaoControl.reset();
+        
+        artifactDaoControl.setDefaultMatcher( new AlwaysMatcher() );
+        
+        daoControl.expectAndReturn( dao.getArtifactDAO(), artifactDao );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.JAR_TYPE, endDate, "whenGathered") ), jarArtifacts );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.WAR_TYPE, endDate, "whenGathered") ), warArtifacts );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins );
+        
+        daoControl.replay(); 
+        artifactDaoControl.replay();
+        
+        data = generator.generateReport( repoContentStats, REPO, startDate, endDate, limits );
+        
+        daoControl.verify();
+        artifactDaoControl.verify();
+        
+        assertEquals( 1, data.size() );
+        
+        stats = (RepositoryStatistics) data.get( 0 );        
+        assertEquals( REPO, stats.getRepositoryId() );
+        assertEquals( 200, stats.getArtifactCount() );
+        assertEquals( 5, stats.getJarCount() );
+        assertEquals( 5, stats.getWarCount() );
+        assertEquals( 5, stats.getPluginCount() );
+        assertEquals( toDate( 2008, 1, 1, 0, 0, 0 ).getTime(), stats.getDateOfScan().getTime() );  
+    }
+    
+    public void testSimpleReportWithoutPagination()
+        throws Exception
+    {
+        Date startDate = toDate( 2008, 1, 1, 0, 0, 0 );
+        Date endDate = toDate( 2008, 11, 30, 0, 0, 0 );
+                        
+        List<ArchivaArtifact> jarArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.JAR_TYPE );        
+        List<ArchivaArtifact> warArtifacts = createArtifacts( RepositoryStatisticsReportGenerator.WAR_TYPE );
+        List<ArchivaArtifact> mavenPlugins = createArtifacts( RepositoryStatisticsReportGenerator.MAVEN_PLUGIN );
+        
+        List<RepositoryContentStatistics> repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO );
+        
+        // get first page
+        daoControl.expectAndReturn( dao.getArtifactDAO(), artifactDao );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.JAR_TYPE, endDate, "whenGathered") ), jarArtifacts, 21 );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.WAR_TYPE, endDate, "whenGathered") ), warArtifacts, 21 );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins, 21 );
+        
+        daoControl.replay(); 
+        artifactDaoControl.replay();
+        
+        List<RepositoryStatistics> data = generator.generateReport( repoContentStats, REPO, startDate, endDate );
+        
+        daoControl.verify();
+        artifactDaoControl.verify();
+        
+        assertEquals( 21, data.size() );
+        
+        RepositoryStatistics stats = (RepositoryStatistics) data.get( 0 );        
+        assertEquals( REPO, stats.getRepositoryId() );
+        assertEquals( 200, stats.getArtifactCount() );
+        assertEquals( 5, stats.getJarCount() );
+        assertEquals( 5, stats.getWarCount() );
+        assertEquals( 5, stats.getPluginCount() );
+        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() );
+    }
+    
+    public void testSimpleReportNoArtifactCountStatisticsAvailable()
+        throws Exception
+    {
+        Date startDate = toDate( 2008, 1, 1, 0, 0, 0 );
+        Date endDate = toDate( 2008, 11, 30, 0, 0, 0 );
+                
+        DataLimits limits = new DataLimits();
+        limits.setPerPageCount( 5 );
+        limits.setCurrentPage( 1 );
+        limits.setCountOfPages( 5 );
+        limits.setTotalCount( 21 );      
+                
+        List<ArchivaArtifact> jarArtifacts = new ArrayList<ArchivaArtifact>();        
+        List<ArchivaArtifact> warArtifacts = new ArrayList<ArchivaArtifact>();
+        List<ArchivaArtifact> mavenPlugins = new ArrayList<ArchivaArtifact>();
+        
+        List<RepositoryContentStatistics> repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO );
+                
+        daoControl.expectAndReturn( dao.getArtifactDAO(), artifactDao );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.JAR_TYPE, endDate, "whenGathered") ), jarArtifacts, 5 );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.WAR_TYPE, endDate, "whenGathered") ), warArtifacts, 5 );
+        
+        artifactDaoControl.expectAndReturn( artifactDao.queryArtifacts( 
+                new ArtifactsByRepositoryConstraint( REPO, RepositoryStatisticsReportGenerator.MAVEN_PLUGIN, endDate, "whenGathered") ), mavenPlugins, 5 );
+        
+        daoControl.replay(); 
+        artifactDaoControl.replay();
+        
+        List<RepositoryStatistics> data = generator.generateReport( repoContentStats, REPO, startDate, endDate, limits );
+        
+        daoControl.verify();
+        artifactDaoControl.verify();
+        
+        assertEquals( 5, data.size() );
+        
+        RepositoryStatistics stats = (RepositoryStatistics) data.get( 0 );        
+        assertEquals( REPO, stats.getRepositoryId() );
+        assertEquals( 200, stats.getArtifactCount() );
+        assertEquals( 0, stats.getJarCount() );
+        assertEquals( 0, stats.getWarCount() );
+        assertEquals( 0, stats.getPluginCount() );
+        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
+    }
+    
+    public void testSimpleReportWithPaginationInvalidRequestedPage()
+        throws Exception
+    {
+        Date startDate = toDate( 2008, 1, 1, 0, 0, 0 );
+        Date endDate = toDate( 2008, 11, 30, 0, 0, 0 );
+                
+        DataLimits limits = new DataLimits();
+        limits.setPerPageCount( 5 );
+        limits.setCurrentPage( 10 );
+        limits.setCountOfPages( 5 );
+        limits.setTotalCount( 21 );      
+        
+        List<RepositoryContentStatistics> repoContentStats = createStatisticsHistoryForSingleRepositoryTest( REPO );
+        
+        try
+        {
+            List<RepositoryStatistics> data = generator.generateReport( repoContentStats, REPO, startDate, endDate, limits );
+            fail( "An ArchivaReportException should have been thrown." );
+        }
+        catch ( ArchivaReportException a )
+        {
+            
+        }
+        // requested page exceeds total number of pages
+    }
+}

Modified: archiva/trunk/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java (original)
+++ archiva/trunk/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java Wed Oct  1 03:27:16 2008
@@ -20,10 +20,14 @@
  */
 
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint;
 import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
 import org.apache.maven.archiva.model.RepositoryContentStatistics;
 import org.apache.maven.archiva.repository.RepositoryException;
@@ -38,6 +42,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.util.List;
 
 /**
@@ -112,19 +117,95 @@
 
             log.info( "Finished repository task: " + stats.toDump( arepo ) );
             
-            // I hate jpox and modello
-            RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
-            dbstats.setDuration( stats.getDuration() );
-            dbstats.setNewFileCount( stats.getNewFileCount() );
-            dbstats.setRepositoryId( stats.getRepositoryId() );
-            dbstats.setTotalFileCount( stats.getTotalFileCount() );
-            dbstats.setWhenGathered( stats.getWhenGathered() );
+            RepositoryContentStatistics dbstats = constructRepositoryStatistics( arepo, sinceWhen, results, stats );
             
-            dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );
+            dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );            
         }
         catch ( RepositoryException e )
-        {
+        {   
             throw new TaskExecutionException( "Repository error when executing repository job.", e );
-        }        
+        }    
     }
+
+    private RepositoryContentStatistics constructRepositoryStatistics( ManagedRepositoryConfiguration arepo,
+                                                                       long sinceWhen,
+                                                                       List<RepositoryContentStatistics> results,
+                                                                       RepositoryScanStatistics stats )        
+    {
+        // I hate jpox and modello <-- and so do I
+        RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
+        dbstats.setDuration( stats.getDuration() );
+        dbstats.setNewFileCount( stats.getNewFileCount() );
+        dbstats.setRepositoryId( stats.getRepositoryId() );
+        dbstats.setTotalFileCount( stats.getTotalFileCount() );
+        dbstats.setWhenGathered( stats.getWhenGathered() );
+                
+        // MRM-84
+       /*
+        List<RepositoryContentStatistics> secondResults = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
+        if ( CollectionUtils.isNotEmpty( results ) )
+        {
+            RepositoryContentStatistics lastStats = secondResults.get( 0 );
+            sinceWhen = lastStats.getWhenGathered().getTime() + lastStats.getDuration();
+        }        
+        */
+        
+        // total artifact count
+        try
+        {
+            List artifacts = dao.getArtifactDAO().queryArtifacts( 
+                      new ArtifactsByRepositoryConstraint( arepo.getId(), stats.getWhenGathered(), "groupId", true ) );            
+            dbstats.setTotalArtifactCount( artifacts.size() );
+        }
+        catch ( ObjectNotFoundException oe )
+        {
+            log.error( "Object not found in the database : " + oe.getMessage() );
+        }
+        catch ( ArchivaDatabaseException ae )
+        {   
+            log.error( "Error occurred while querying artifacts for artifact count : " + ae.getMessage() );
+        }
+
+        
+        // total repo size
+        long size = FileUtils.sizeOfDirectory( new File( arepo.getLocation() ) );
+        dbstats.setTotalSize( size );
+        
+        /*
+         TODO:
+          
+          // total unique groups
+        List<String> repos = new ArrayList<String>();
+        repos.add( arepo.getId() ); 
+        try
+        {
+            List<String> groupIds = dao.getArtifactDAO().queryArtifacts( new UniqueGroupIdConstraint( repos ) );            
+            dbstats.setTotalGroupCount( groupIds.size() );
+        }
+        catch ( ObjectNotFoundException oe )
+        {
+            
+        }
+        catch ( ArchivaDatabaseException ae )
+        {
+            
+        }
+        
+        // total unique projects
+        try
+        {
+            List<Object[]> artifactIds = dao.getArtifactDAO().queryArtifacts( new UniqueArtifactIdConstraint( arepo.getId(), true ) );            
+            dbstats.setTotalProjectCount( artifactIds.size() );
+        }
+        catch ( ObjectNotFoundException oe )
+        {
+            
+        }
+        catch ( ArchivaDatabaseException ae )
+        {
+
+        }*/
+                
+        return dbstats;
+    }    
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java?rev=700729&r1=700728&r2=700729&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java Wed Oct  1 03:27:16 2008
@@ -89,7 +89,7 @@
         Calendar greaterThanThisDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
         greaterThanThisDate.add( Calendar.DATE, -( getNumberOfDaysBeforeNow() ) );
         
-        Constraint artifactsByRepo = new ArtifactsByRepositoryConstraint( repoId, greaterThanThisDate.getTime(), "whenGathered" );
+        Constraint artifactsByRepo = new ArtifactsByRepositoryConstraint( repoId, greaterThanThisDate.getTime(), "whenGathered", false );
         List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( artifactsByRepo );
 
         List<RssFeedEntry> entries = processData( artifacts, true );



Mime
View raw message