]> source.dussan.org Git - archiva.git/commitdiff
[MRM-166] better display of ungenerated reports, and only list metadata that has...
authorBrett Porter <brett@apache.org>
Mon, 11 Sep 2006 00:01:48 +0000 (00:01 +0000)
committerBrett Porter <brett@apache.org>
Mon, 11 Sep 2006 00:01:48 +0000 (00:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@442039 13f79535-47bb-0310-9956-ffa450edef68

archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java
archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java
archiva-webapp/src/main/resources/xwork.xml
archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp

index ca4a44c4b467dc2b43a0e3d5c475e5954fc847ef..a2f9bf74b74be78ae0680ceecb9d89d0f278b31d 100644 (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();
index 0942a328bfd0754f0978bd8e3df9e067c8d2daaf..86db54f3bec4c58514b235a58063d781f99abf2b 100644 (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 )
index 4bea0e16539929e14f403af6cd2241c65c47a0fe..b9d78897c8595d18e38cbf5e96e178b71f4573fc 100644 (file)
     <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>
index ad043764d7cbbd1ca796c2ec10ae1d9c69cf96ae..4f91730a13d0fb7f199ee6a19cd903e321472ad7 100644 (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>
 <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 --%>
     </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>
               </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>