Revision: 17850
          http://sourceforge.net/p/gate/code/17850
Author:   markagreenwood
Date:     2014-04-17 11:59:42 +0000 (Thu, 17 Apr 2014)
Log Message:
-----------
if a new annotation is created using a specified ID then we now check to ensure 
that the next ID we would use automatically is greater than the one just used. 
This ensures we never accidentally trample over an existing annotation

Modified Paths:
--------------
    gate/trunk/src/main/gate/annotation/AnnotationSetImpl.java
    gate/trunk/src/main/gate/corpora/DocumentImpl.java

Modified: gate/trunk/src/main/gate/annotation/AnnotationSetImpl.java
===================================================================
--- gate/trunk/src/main/gate/annotation/AnnotationSetImpl.java  2014-04-17 
06:19:01 UTC (rev 17849)
+++ gate/trunk/src/main/gate/annotation/AnnotationSetImpl.java  2014-04-17 
11:59:42 UTC (rev 17850)
@@ -908,6 +908,12 @@
     // construct an annotation
     annFactory.createAnnotationInSet(this, id, nodes[0], nodes[1], type,
             features);
+    
+    //try to ensure that if someone adds an annotation directly by ID
+    //the other methods don't trample all over it later
+    if (id > doc.peakAtNextAnnotationId()) {
+      doc.setNextAnnotationId(id+1);
+    }
   } // add(id, start, end, type, features)
 
   /** Construct the positional index. */

Modified: gate/trunk/src/main/gate/corpora/DocumentImpl.java
===================================================================
--- gate/trunk/src/main/gate/corpora/DocumentImpl.java  2014-04-17 06:19:01 UTC 
(rev 17849)
+++ gate/trunk/src/main/gate/corpora/DocumentImpl.java  2014-04-17 11:59:42 UTC 
(rev 17850)
@@ -2169,6 +2169,11 @@
   public Integer getNextAnnotationId() {
     return new Integer(nextAnnotationId++);
   } // getNextAnnotationId
+  
+  /** look at the next annotation ID without incrementing it */
+  public Integer peakAtNextAnnotationId() {
+    return nextAnnotationId;
+  }
 
   /** Generate and return the next node ID */
   public Integer getNextNodeId() {

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


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to