Revision: 16743
          http://sourceforge.net/p/gate/code/16743
Author:   ian_roberts
Date:     2013-07-18 10:34:03 +0000 (Thu, 18 Jul 2013)
Log Message:
-----------
Handle renumbering of entries to match federated index document IDs.

Modified Paths:
--------------
    mimir/trunk/mimir-test/src/gate/mimir/test/RenderZipCollection.java

Modified: mimir/trunk/mimir-test/src/gate/mimir/test/RenderZipCollection.java
===================================================================
--- mimir/trunk/mimir-test/src/gate/mimir/test/RenderZipCollection.java 
2013-07-18 10:25:42 UTC (rev 16742)
+++ mimir/trunk/mimir-test/src/gate/mimir/test/RenderZipCollection.java 
2013-07-18 10:34:03 UTC (rev 16743)
@@ -46,6 +46,9 @@
 
     File indexDir = new File(args[0]);
     File outputDir = new File(args[1]);
+    // renumbering rules if required
+    int multiplier = Integer.getInteger("federatedIndex.size", 1);
+    int offset = Integer.getInteger("federatedIndex.offset", 0);
     // load the IndexConfig to obtain the right renderer
     IndexConfig indexConfig =
             IndexConfig.readConfigFromFile(new File(indexDir,
@@ -78,7 +81,7 @@
           }
           if(dd != null) {
             // and write the rendered form to the new zip (in UTF-8)
-            ZipEntry outEntry = new ZipEntry(inEntry.getName());
+            ZipEntry outEntry = new ZipEntry(renumber(inEntry.getName(), 
multiplier, offset));
             rendOut.putNextEntry(outEntry);
             try(BufferedWriter w = new BufferedWriter(new 
OutputStreamWriter(new FilterOutputStream(rendOut) {
               @Override
@@ -97,5 +100,15 @@
       }
     }
   }
+  
+  /**
+   * Renumber the original name to match the ID it would have in a federated 
index
+   * if this were the (0-based) <code>offset</code>th index in a federation of 
size
+   * <code>multiplier</code>.
+   * @throws NumberFormatException
+   */
+  public static String renumber(String originalName, int multiplier, int 
offset) throws NumberFormatException {
+    return String.valueOf((Integer.parseInt(originalName) * multiplier) + 
offset);
+  }
 
 }

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


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to