[MRM-166] select repository to show in reports page

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441799 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-09-09 15:47:24 +00:00
parent 8630479fc6
commit 1a3026414e
2 changed files with 43 additions and 12 deletions

View 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();
if ( repositoryId != null && !repositoryId.equals( "-" ) )
{
RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
getReport( repositoryConfiguration );
}
else
{
for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
{
RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
getReport( repositoryConfiguration );
}
}
return SUCCESS;
}
private void getReport( RepositoryConfiguration repositoryConfiguration )
throws ReportingStoreException
{
ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
ReportingDatabase database = reportingStore.getReportsFromStore( repository );
databases.add( database );
}
return SUCCESS;
}
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;
}
}

View File

@ -32,7 +32,12 @@
<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">