Revision: 17074
          http://sourceforge.net/p/gate/code/17074
Author:   valyt
Date:     2013-11-11 13:48:34 +0000 (Mon, 11 Nov 2013)
Log Message:
-----------
Bugfix: document IDs are now not just strings, so we need to match the string 
coming from the existing report to the idText in the DocumentID value.

Also added equals and hashcode implementations for DocumentID, for good measure.

Modified Paths:
--------------
    gcp/trunk/src/gate/cloud/batch/Batch.java
    gcp/trunk/src/gate/cloud/batch/DocumentID.java

Modified: gcp/trunk/src/gate/cloud/batch/Batch.java
===================================================================
--- gcp/trunk/src/gate/cloud/batch/Batch.java   2013-11-11 02:19:42 UTC (rev 
17073)
+++ gcp/trunk/src/gate/cloud/batch/Batch.java   2013-11-11 13:48:34 UTC (rev 
17074)
@@ -26,7 +26,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -141,6 +140,7 @@
     }
     if(restarting) {
       try {
+        // in the report XML, the document IDs are only represented as Strings
         Set<String> completedDocuments = new HashSet<String>();
         logger.debug("Processing existing report file");
         InputStream bakIn =
@@ -213,8 +213,11 @@
         }
         // filter the documents already processed
         List<DocumentID> unprocessedDocs = new ArrayList<DocumentID>();
-        unprocessedDocs.addAll(Arrays.asList(documentIDs));
-        unprocessedDocs.removeAll(completedDocuments);
+        for(DocumentID docId : documentIDs) {
+          if(!completedDocuments.contains(docId.getIdText())) {
+            unprocessedDocs.add(docId);
+          }
+        }
         unprocessedDocumentIDs = unprocessedDocs.toArray(
                 new DocumentID[unprocessedDocs.size()]);
       } catch(XMLStreamException e) {

Modified: gcp/trunk/src/gate/cloud/batch/DocumentID.java
===================================================================
--- gcp/trunk/src/gate/cloud/batch/DocumentID.java      2013-11-11 02:19:42 UTC 
(rev 17073)
+++ gcp/trunk/src/gate/cloud/batch/DocumentID.java      2013-11-11 13:48:34 UTC 
(rev 17074)
@@ -101,4 +101,29 @@
     }
     return toString;
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result =
+        prime * result + ((attributes == null) ? 0 : attributes.hashCode());
+    result = prime * result + ((idText == null) ? 0 : idText.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if(this == obj) return true;
+    if(obj == null) return false;
+    if(getClass() != obj.getClass()) return false;
+    DocumentID other = (DocumentID)obj;
+    if(attributes == null) {
+      if(other.attributes != null) return false;
+    } else if(!attributes.equals(other.attributes)) return false;
+    if(idText == null) {
+      if(other.idText != null) return false;
+    } else if(!idText.equals(other.idText)) return false;
+    return true;
+  }
 }
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to