Programs for which there was already an attempt to record them will no
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / main / ProgramActionExecutor.java
index 4b2476d06dd2653deb38dca28f36e9d64aba2b2e..51aef60f1a2148f58300f1c085b642e4028a322f 100644 (file)
@@ -112,7 +112,6 @@ public class ProgramActionExecutor {
 
     /**
      * Makes sure that the actions are performed.
-     * 
      */
     public void commit() {
         Set<TimeInterval> previouslyRecorded = new HashSet<TimeInterval>();
@@ -153,6 +152,8 @@ public class ProgramActionExecutor {
     public Element getReport() {
         DocumentFactory factory = DocumentFactory.getInstance();
         Element report = factory.createElement("report");
+        
+        Set<Program> reportedPrograms = new HashSet<Program>();
 
         for (RecordingResult result : RecordingResult.values()) {
             if (_recordings.get(result).size() > 0) {
@@ -161,6 +162,7 @@ public class ProgramActionExecutor {
 
                 for (Program program : _recordings.get(result)) {
                     recordingResult.add(program.asXml());
+                    reportedPrograms.add(program);
                 }
             }
         }
@@ -174,7 +176,16 @@ public class ProgramActionExecutor {
                     categoryElem.addAttribute("name", category);
                 }
                 for (Program program : _interestingShows.get(category)) {
-                    categoryElem.add(program.asXml());
+                    if ( !reportedPrograms.contains(program)) {
+                        categoryElem.add(program.asXml());
+                    } else { 
+                        LOG.info("Category '" + category + "', program " + program + " already reported");
+                    }
+                }
+                if ( categoryElem.elements().size() == 0 ) {
+                    // Remove empty category element. 
+                    LOG.info("Removing element for category '" + category + "'");
+                    interesting.remove(categoryElem);
                 }
             }