]> source.dussan.org Git - archiva.git/commitdiff
[MRM-166] select repository to show in reports page
authorBrett Porter <brett@apache.org>
Sat, 9 Sep 2006 15:47:24 +0000 (15:47 +0000)
committerBrett Porter <brett@apache.org>
Sat, 9 Sep 2006 15:47:24 +0000 (15:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441799 13f79535-47bb-0310-9956-ffa450edef68

archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java
archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp

index 79f84a0852d73d0bd96bcdf26b8e51d00a65bdcc..73fb380c6c22899d2901b507151558ac7e9fdeca 100644 (file)
@@ -17,6 +17,7 @@ package org.apache.maven.archiva.web.action;
  */
 
 import com.opensymphony.xwork.ActionSupport;
+import com.opensymphony.xwork.Preparable;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ConfigurationStore;
 import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
@@ -26,6 +27,7 @@ import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
 import org.apache.maven.archiva.reporting.ReportExecutor;
 import org.apache.maven.archiva.reporting.ReportingDatabase;
 import org.apache.maven.archiva.reporting.ReportingStore;
+import org.apache.maven.archiva.reporting.ReportingStoreException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 
@@ -40,6 +42,7 @@ import java.util.List;
  */
 public class ReportsAction
     extends ActionSupport
+    implements Preparable
 {
     /**
      * @plexus.requirement
@@ -65,33 +68,45 @@ public class ReportsAction
      */
     private ReportExecutor executor;
 
+    private Configuration configuration;
+
     public String execute()
         throws Exception
     {
         databases = new ArrayList();
 
-        Configuration configuration = configurationStore.getConfigurationFromStore();
-
-        for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+        if ( repositoryId != null && !repositoryId.equals( "-" ) )
         {
-            RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
-
-            ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
-
-            ReportingDatabase database = reportingStore.getReportsFromStore( repository );
+            RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
+            getReport( repositoryConfiguration );
+        }
+        else
+        {
+            for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+            {
+                RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
 
-            databases.add( database );
+                getReport( repositoryConfiguration );
+            }
         }
         return SUCCESS;
     }
 
+    private void getReport( RepositoryConfiguration repositoryConfiguration )
+        throws ReportingStoreException
+    {
+        ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
+
+        ReportingDatabase database = reportingStore.getReportsFromStore( repository );
+
+        databases.add( database );
+    }
+
     public String runReport()
         throws Exception
     {
         // TODO: this should be one that runs in the background - see the showcase
 
-        Configuration configuration = configurationStore.getConfigurationFromStore();
-
         RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
         ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
 
@@ -149,4 +164,15 @@ public class ReportsAction
     {
         return databases;
     }
+
+    public void prepare()
+        throws Exception
+    {
+        configuration = configurationStore.getConfigurationFromStore();
+    }
+
+    public Configuration getConfiguration()
+    {
+        return configuration;
+    }
 }
index 7e96731a33b01997ca995449bc7d658bf38f76d2..563558d419d8e649823f5d711bdf172565df06d8 100644 (file)
 
 <div id="contentArea">
 
-<%-- TODO!: select report, repository and filter --%>
+<%-- TODO!: select report, filter --%>
+<ww:form action="reports" namespace="/admin">
+  <ww:select list="configuration.repositories" listKey="id" listValue="name" label="Repository" headerKey="-"
+             headerValue="(All repositories)" name="repositoryId"/>
+  <ww:submit value="Get Report"/>
+</ww:form>
 
 <ww:set name="databases" value="databases"/>
 <c:forEach items="${databases}" var="database">