[MRM-166] better display of ungenerated reports, and only list metadata that has had failures or warnings

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@442039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-09-11 00:01:48 +00:00
parent b57273dff3
commit 40b955d387
4 changed files with 65 additions and 25 deletions

View File

@ -27,7 +27,9 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
/**
* @todo i18n, including message formatting and parameterisation
@ -52,6 +54,8 @@ public class ReportingDatabase
private final ReportGroup reportGroup;
private Set metadataWithProblems;
public ReportingDatabase( ReportGroup reportGroup )
{
this( reportGroup, new Reporting() );
@ -152,6 +156,10 @@ public class ReportingDatabase
public void addFailure( RepositoryMetadata metadata, String reason )
{
MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() );
if ( !metadataWithProblems.contains( results ) )
{
metadataWithProblems.add( results );
}
results.addFailure( createResults( reason ) );
numFailures++;
updateTimings();
@ -160,14 +168,25 @@ public class ReportingDatabase
public void addWarning( RepositoryMetadata metadata, String reason )
{
MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() );
if ( !metadataWithProblems.contains( results ) )
{
metadataWithProblems.add( results );
}
results.addWarning( createResults( reason ) );
numWarnings++;
updateTimings();
}
public Set getMetadataWithProblems()
{
return metadataWithProblems;
}
private void initMetadataMap()
{
Map map = new HashMap();
Set problems = new LinkedHashSet();
for ( Iterator i = reporting.getMetadata().iterator(); i.hasNext(); )
{
MetadataResults result = (MetadataResults) i.next();
@ -178,8 +197,14 @@ public class ReportingDatabase
numFailures += result.getFailures().size();
numWarnings += result.getWarnings().size();
if ( !result.getFailures().isEmpty() || !result.getWarnings().isEmpty() )
{
problems.add( result );
}
}
metadataMap = map;
metadataWithProblems = problems;
}
private static String getMetadataKey( String groupId, String artifactId, String version )
@ -237,6 +262,8 @@ public class ReportingDatabase
numWarnings -= results.getWarnings().size();
results.getWarnings().clear();
metadataWithProblems.remove( results );
}
private MetadataResults getMetadataResults( RepositoryMetadata metadata, long lastModified )
@ -315,6 +342,7 @@ public class ReportingDatabase
artifactMap.clear();
metadataMap.clear();
metadataWithProblems.clear();
reporting.getArtifacts().clear();
reporting.getMetadata().clear();

View File

@ -22,12 +22,12 @@ import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ConfigurationStore;
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
import org.apache.maven.archiva.discoverer.DiscovererException;
import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
import org.apache.maven.archiva.reporting.ReportExecutor;
import org.apache.maven.archiva.reporting.ReportGroup;
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;
@ -46,11 +46,6 @@ public class ReportsAction
extends ActionSupport
implements Preparable
{
/**
* @plexus.requirement
*/
private ReportingStore reportingStore;
/**
* @plexus.requirement
*/
@ -110,7 +105,7 @@ public class ReportsAction
{
ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
ReportingDatabase database = reportingStore.getReportsFromStore( repository, reportGroup );
ReportingDatabase database = executor.getReportDatabase( repository, reportGroup );
databases.add( database );
}
@ -129,6 +124,15 @@ public class ReportsAction
return SUCCESS;
}
generateReport( database, repositoryConfiguration, reportGroup, repository );
return SUCCESS;
}
private void generateReport( ReportingDatabase database, RepositoryConfiguration repositoryConfiguration,
ReportGroup reportGroup, ArtifactRepository repository )
throws DiscovererException, ReportingStoreException
{
database.setInProgress( true );
List blacklistedPatterns = new ArrayList();
@ -159,8 +163,6 @@ public class ReportsAction
{
database.setInProgress( false );
}
return SUCCESS;
}
public void setReportGroup( String reportGroup )

View File

@ -234,8 +234,8 @@
<action name="runReport" class="reportsAction" method="runReport">
<interceptor-ref name="configuredStack"/>
<interceptor-ref name="execAndWait"/>
<result name="wait" type="redirect-action">reports</result>
<result name="success" type="redirect-action">reports</result>
<result name="wait" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
<result name="success" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
</action>
</package>
</xwork>

View File

@ -54,6 +54,7 @@
<c:set var="url">
<ww:url action="runReport" namespace="/admin">
<ww:param name="repositoryId" value="%{'${database.repository.id}'}"/>
<ww:param name="reportGroup" value="reportGroup"/>
</ww:url>
</c:set>
<a href="${url}">Regenerate Report</a>
@ -68,18 +69,27 @@
<h2>Repository: ${database.repository.name}</h2>
<p>
Status:
<img src="<c:url value="/images/icon_error_sml.gif"/>" width="15" height="15" alt=""/>
${database.numFailures}
<img src="<c:url value="/images/icon_warning_sml.gif"/>" width="15" height="15" alt=""/>
${database.numWarnings}
<c:choose>
<c:when test="${!empty(database.reporting.lastModified)}">
Status:
<img src="<c:url value="/images/icon_error_sml.gif"/>" width="15" height="15" alt=""/>
${database.numFailures}
<img src="<c:url value="/images/icon_warning_sml.gif"/>" width="15" height="15" alt=""/>
${database.numWarnings}
<span style="font-size: x-small">
<%-- TODO! use better formatting here --%>
Last updated: ${database.reporting.lastModified},
execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes
<fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds
</span>
<span style="font-size: x-small">
<%-- TODO! use better formatting here --%>
Last updated: ${database.reporting.lastModified},
execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes
<fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds
</span>
</c:when>
<c:otherwise>
<b>
This report has not yet been generated. <a href="${url}">Generate Report</a>
</b>
</c:otherwise>
</c:choose>
</p>
<%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%>
@ -145,9 +155,9 @@
</p>
</c:if>
</c:if>
<c:if test="${!empty(database.reporting.metadata)}">
<c:if test="${!empty(database.metadataWithProblems)}">
<h3>Metadata</h3>
<c:forEach items="${database.reporting.metadata}" var="metadata" begin="0" end="2">
<c:forEach items="${database.metadataWithProblems}" var="metadata" begin="0" end="2">
<ul>
<c:forEach items="${metadata.failures}" var="result">
<li class="errorBullet">${result.reason}</li>
@ -206,7 +216,7 @@
</td>
--%>
</c:forEach>
<c:if test="${fn:length(database.reporting.metadata) gt 3}">
<c:if test="${fn:length(database.metadataWithProblems) gt 3}">
<p>
<b>... more ...</b>
</p>